Skip to content

Commit

Permalink
Fixing missing collection data and anchors on cards
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonHHouse committed Oct 13, 2020
1 parent 8a2a7b4 commit 5569182
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ public final class MovieFromCollection {
@NotNull
private final String title;
@NotNull
private final String tmdbId;
private final Integer tmdbId;
@NotNull
private final Boolean owned;

@JsonCreator
public MovieFromCollection(@JsonProperty(value = "title") @Nullable String title,
@JsonProperty(value = "tmdbId") @Nullable String tmdbId,
@JsonProperty(value = "tmdbId") @Nullable Integer tmdbId,
@JsonProperty(value = "owned") @Nullable Boolean owned) {
this.title = StringUtils.isEmpty(title) ? "" : title;
this.tmdbId = StringUtils.isEmpty(tmdbId) ? "" : tmdbId;
this.tmdbId = tmdbId == null ? -1 : tmdbId;
this.owned = owned != null && owned;
}

Expand All @@ -30,7 +30,7 @@ public String getTitle() {
}

@NotNull
public String getTmdbId() {
public Integer getTmdbId() {
return tmdbId;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/src/main/java/com/jasonhhouse/gaps/Schedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@JsonDeserialize(using = ScheduleDeserializer.class)
public enum Schedule {

HOURLY("Hourly", "0 18 * * * ?", 0),
HOURLY("Hourly", "0 35 * * * ?", 0),
DAILY_4AM("Daily", "0 0 4 * * ?", 1),
EVERY_MONDAY("Weekly", "0 0 4 * * MON", 2),
EVERY_TWO_WEEKS("Bi-weekly", "0 0 4 1,15 * ?", 3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ class BasicMovieFromCollectionTest {

@Test
void MovieFromCollectionTest_Invalid_Owned (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", "1234", true);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, true);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of owned field");
}

@Test
void MovieFromCollectionTest_Invalid_Id (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", "9874", false);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 9874, false);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of ID field");
}

@Test
void MovieFromCollectionTest_Invalid_Name (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", "1234", false);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false);

assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of name field");
}

@Test
void MovieFromCollectionTest_Valid (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", "1234", false);
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, false);

assertEquals(movieFromCollection1, movieFromCollection2, "Movies should be equal");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ void setUp() {

@Test
void testReadingFromJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":\"123QWE\",\"owned\":true}", MovieFromCollection.class);
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", MovieFromCollection.class);
assertEquals("TITLE", movieFromCollection.getTitle(), "Title should be 'TITLE'");
assertEquals("123QWE", movieFromCollection.getTmdbId(), "tmdbId should be '123QWE'");
assertEquals(123, movieFromCollection.getTmdbId(), "tmdbId should be '123'");
assertTrue(movieFromCollection.getOwned(), "Title should be 'TITLE'");
}

@Test
void testWritingToJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE","123QWE",true);
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE",123,true);
String json = objectMapper.writeValueAsString(movieFromCollection);
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":\"123QWE\",\"owned\":true}", json, "JSON output should be equal");
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", json, "JSON output should be equal");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public GapsSearchService(@Qualifier("real") UrlGenerator urlGenerator, SimpMessa
public void run(@NotNull String machineIdentifier,@NotNull Integer key) {
LOGGER.info("run( {}, {} )", machineIdentifier, key);

//ToDo
if(key.equals(1)) {
return;
}

PlexProperties plexProperties = fileIoService.readProperties();
Optional<PlexServer> optionalPlexServer = plexProperties.getPlexServers().stream().filter(tempPlexServer -> tempPlexServer.getMachineIdentifier().equals(machineIdentifier)).findFirst();
PlexServer plexServer;
Expand Down Expand Up @@ -465,13 +470,13 @@ private void handleCollection(PlexProperties plexProperties, String machineIdent
LOGGER.warn("Could not parse date");
}
}
String id = jsonNode.get(ID).textValue();
Integer tmdbId = jsonNode.get(ID).intValue();

BasicMovie collectionBasicMovie = new BasicMovie.Builder(title, year).build();
LOGGER.info(collectionBasicMovie.toString());

Boolean owned = ownedBasicMovies.contains(collectionBasicMovie);
moviesInCollection.add(new MovieFromCollection(title, id, owned));
moviesInCollection.add(new MovieFromCollection(title, tmdbId, owned));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class PlexQueryImpl implements PlexQuery {

public static final String ID_IDX_START = "://";
public static final String ID_IDX_END = "?";
private static final long TIMEOUT = 2500;
private static final long TIMEOUT = 5000;
private static final Logger LOGGER = LoggerFactory.getLogger(PlexQueryImpl.class);

private final UrlGenerator urlGenerator;
Expand Down
20 changes: 11 additions & 9 deletions GapsWeb/src/main/resources/templates/recommended.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,24 +180,26 @@ <h2 class="top-margin" id="searchTitle">Searching for Movies</h2>
<div class="col-12 col-md">
<div class="card-body">
<h5 class="card-title">{{name}} ({{year}})</h5>
<h6 class="card-title">{{collection}}</h6>
<h6 class="card-title">{{collectionTitle}}</h6>
<p class="card-text text-muted long-text">{{overview}}</p>
<p class="card-text"><small class="text-info">English</small></p>
<div>
<span class="card-text">Owned</span><br>
{{#each movies_in_collection}}
{{#if this.owned}}
<a href="https://www.themoviedb.org/movie/{{this.id}}" class="card-link" target="_blank" rel="noopener noreferrer">{{this.title}}</a>
{{/if}}
{{#each moviesInCollection}}
{{#if this.owned}}
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}" href="https://www.themoviedb.org/movie/{{this.tmdbId}}" class="card-link" target="_blank"
rel="noopener noreferrer">{{this.title}}</a>
{{/if}}
{{/each}}
</div>
<br>
<div>
<span class="card-text">Missing</span><br>
{{#each movies_in_collection}}
{{#if (isNotOwned this.owned)}}
<a href="https://www.themoviedb.org/movie/{{this.id}}" class="card-link" target="_blank" rel="noopener noreferrer">{{this.title}}</a>
{{/if}}
{{#each moviesInCollection}}
{{#if (isNotOwned this.owned)}}
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}" href="https://www.themoviedb.org/movie/{{this.tmdbId}}" class="card-link" target="_blank"
rel="noopener noreferrer">{{this.title}}</a>
{{/if}}
{{/each}}
</div>
</div>
Expand Down
5 changes: 1 addition & 4 deletions cypress/integration/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,9 @@ export function redLibraryBefore() {

cy.populatePlexConfiguration(atob('MTkyLjE2OC4xLjg='), atob('MzI0MDA='), atob('bVF3NHVhd3hUeVlFbXFOVXJ2Qno='));

cy.get('#addPlexServer')
cy.get('#addPlexServer', { timeout: 15000 })
.click();

// Wait for timeout from plex
cy.wait(10000);

cy.get('#plexSpinner')
.should('not.be.visible');

Expand Down
7 changes: 2 additions & 5 deletions cypress/integration/configuration/plex.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Plex Configuration Tests', () => {
cy.get('#testPlexServer')
.click();

cy.get('#plexSpinner')
cy.get('#plexSpinner', { timeout: 15000 })
.should('not.be.visible');

cy.get('#plexTestError')
Expand Down Expand Up @@ -108,10 +108,7 @@ describe('Plex Configuration Tests', () => {
cy.get('#addPlexServer')
.click();

// Wait for timeout from plex
cy.wait(5000);

cy.get('#plexSpinner')
cy.get('#plexSpinner', { timeout: 15000 })
.should('not.be.visible');

cy.get('#plexTestError')
Expand Down
4 changes: 1 addition & 3 deletions cypress/integration/configuration/tmdb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ describe('TMDB Configuration Tests', () => {
cy.get('#testTmdbKey')
.click();

cy.wait(2000);

cy.get('#tmdbTestError')
cy.get('#tmdbTestError', { timeout: 5000 })
.should('be.visible');

cy.get('#tmdbTestSuccess')
Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/notifications/discord.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,12 @@ describe('Check Discord Notification Agent', () => {
cy.get('#testDiscord')
.click();

cy.wait(2000);
cy.get('#discordTestError', { timeout: 5000 })
.should(CYPRESS_VALUES.beVisible);

cy.get('#discordTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);

cy.get('#discordTestError')
.should(CYPRESS_VALUES.beVisible);

cy.get('#discordSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);

Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/notifications/email.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,14 +473,12 @@ describe('Check Email Notification Agent', () => {
cy.get('#testEmail')
.click();

cy.wait(2000);
cy.get('#emailTestError', { timeout: 5000 })
.should(CYPRESS_VALUES.beVisible);

cy.get('#emailTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);

cy.get('#emailTestError')
.should(CYPRESS_VALUES.beVisible);

cy.get('#emailSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);

Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/notifications/gotify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,12 @@ describe('Check Gotify Notification Agent', () => {
cy.get('#testGotify')
.click();

cy.wait(2000);
cy.get('#gotifyTestError', { timeout: 5000 })
.should(CYPRESS_VALUES.beVisible);

cy.get('#gotifyTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);

cy.get('#gotifyTestError')
.should(CYPRESS_VALUES.beVisible);

cy.get('#gotifySaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);

Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/notifications/pushBullet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,12 @@ describe('Check PushBullet Notification Agent', () => {
cy.get('#testPushBullet')
.click();

cy.wait(2000);
cy.get('#pushBulletTestError', { timeout: 5000 })
.should(CYPRESS_VALUES.beVisible);

cy.get('#pushBulletTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);

cy.get('#pushBulletTestError')
.should(CYPRESS_VALUES.beVisible);

cy.get('#pushBulletSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);

Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/notifications/pushOver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,12 @@ describe('Check PushOver Notification Agent', () => {
cy.get('#testPushOver')
.click();

cy.wait(2000);
cy.get('#pushOverTestError', { timeout: 5000 })
.should(CYPRESS_VALUES.beVisible);

cy.get('#pushOverTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);

cy.get('#pushOverTestError')
.should(CYPRESS_VALUES.beVisible);

cy.get('#pushOverSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);

Expand Down
6 changes: 2 additions & 4 deletions cypress/integration/notifications/telegram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,12 @@ describe('Check Telegram Notification Agent', () => {
cy.get('#testTelegram')
.click();

cy.wait(2000);
cy.get('#telegramTestError', { timeout: 5000 })
.should(CYPRESS_VALUES.beVisible);

cy.get('#telegramTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);

cy.get('#telegramTestError')
.should(CYPRESS_VALUES.beVisible);

cy.get('#telegramSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);

Expand Down
30 changes: 21 additions & 9 deletions cypress/integration/recommended/searchRecommendedMovies.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ describe('Search for Recommended', () => {
cy.get('[data-cy=searchForMovies]')
.click();

cy.wait(5000);

cy.get('#movies_info')
cy.get('#movies_info', { timeout: 5000 })
.should('have.text', 'Showing 1 to 7 of 7 entries');

cy.get('[data-cy=tt0432348-176]')
.should('have.text', 'Saw');

cy.get('[data-cy=tt0432348-215]')
.should('have.text', 'Saw II');
});

it('Research Movies', () => {
Expand All @@ -87,17 +91,25 @@ describe('Search for Recommended', () => {
cy.get('[data-cy=searchForMovies]')
.click();

cy.wait(5000);

cy.get('#movies_info')
cy.get('#movies_info', { timeout: 5000 })
.should('have.text', 'Showing 1 to 7 of 7 entries');

cy.get('[data-cy=tt0432348-176]')
.should('have.text', 'Saw');

cy.get('[data-cy=tt0432348-215]')
.should('have.text', 'Saw II');

cy.get('#movieContainer > [onclick="searchForMovies()"]')
.click();

cy.wait(5000);

cy.get('#movies_info')
cy.get('#movies_info', { timeout: 5000 })
.should('have.text', 'Showing 1 to 7 of 7 entries');

cy.get('[data-cy=tt0432348-176]')
.should('have.text', 'Saw');

cy.get('[data-cy=tt0432348-215]')
.should('have.text', 'Saw II');
});
});
4 changes: 1 addition & 3 deletions cypress/integration/rss/rss.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ describe('Searched RSS', () => {
cy.get('[data-cy=searchForMovies]')
.click();

cy.wait(5000);

cy.get('#movies_info')
cy.get('#movies_info', { timeout: 5000 })
.should('have.text', 'Showing 1 to 7 of 7 entries');

cy.visit('/rssCheck', { onBeforeLoad: spyOnAddEventListener });
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
// require('./commands')

0 comments on commit 5569182

Please sign in to comment.