Skip to content

Commit

Permalink
Merge pull request #186 from JasonHHouse/bugfix/issue_185
Browse files Browse the repository at this point in the history
Bugfix/issue 185
  • Loading branch information
JasonHHouse authored Oct 13, 2020
2 parents 39b8ca2 + 5569182 commit eb86553
Show file tree
Hide file tree
Showing 92 changed files with 50,589 additions and 1,528 deletions.
4 changes: 2 additions & 2 deletions Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.2</version>
<version>0.8.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>com.jasonhhouse</groupId>
<artifactId>Plex</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>
</dependency>

<dependency>
Expand Down
14 changes: 7 additions & 7 deletions Core/src/main/java/com/jasonhhouse/gaps/BasicMovie.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public final class BasicMovie implements Comparable<BasicMovie> {
@NotNull
private final String posterUrl;
@NotNull
private String imdbId;
@NotNull
private final String language;
@NotNull
private final String overview;
Expand All @@ -44,6 +42,8 @@ public final class BasicMovie implements Comparable<BasicMovie> {
@NotNull
private final String key;
@NotNull
private String imdbId;
@NotNull
private String collectionTitle;
@NotNull
private Integer collectionId;
Expand Down Expand Up @@ -85,10 +85,6 @@ public void setCollectionId(@NotNull Integer collectionId) {
this.collectionId = collectionId;
}

public void setTmdbId(int tmdbId) {
this.tmdbId = tmdbId;
}

public @NotNull String getName() {
return name;
}
Expand Down Expand Up @@ -117,6 +113,10 @@ public void setImdbId(@NotNull String imdbId) {
return tmdbId;
}

public void setTmdbId(int tmdbId) {
this.tmdbId = tmdbId;
}

public void setTmdbId(@NotNull Integer tmdbId) {
this.tmdbId = tmdbId;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ public Builder(@JsonProperty(value = "name") @NotNull String name,
return this;
}

public @NotNull Builder setTmdbId(@NotNull Integer tmdbId) {
public @NotNull Builder setTmdbId(@NotNull Integer tmdbId) {
this.tmdbId = tmdbId;
return this;
}
Expand Down
19 changes: 13 additions & 6 deletions Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package com.jasonhhouse.gaps;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class MovieFromCollection {
@NotNull
private final String title;
@NotNull
private final String tmdbId;
private final Integer tmdbId;
@NotNull
private final Boolean owned;

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

@NotNull
Expand All @@ -23,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 @@ -16,7 +16,9 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jasonhhouse.gaps.PlexServer;
import com.jasonhhouse.gaps.Schedule;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -26,7 +28,7 @@
public final class PlexProperties {

@NotNull
private final Set<PlexServer> plexServers;
private final List<PlexServer> plexServers;
@NotNull
private String movieDbApiKey;
@NotNull
Expand All @@ -49,7 +51,7 @@ public final class PlexProperties {
private Schedule schedule;

@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public PlexProperties(@JsonProperty(value = "plexServers") @Nullable Set<PlexServer> plexServers,
public PlexProperties(@JsonProperty(value = "plexServers") @Nullable List<PlexServer> plexServers,
@JsonProperty(value = "telegramProperties") @Nullable TelegramProperties telegramProperties,
@JsonProperty(value = "pushBulletProperties") @Nullable PushBulletProperties pushBulletProperties,
@JsonProperty(value = "emailProperties") @Nullable EmailProperties emailProperties,
Expand All @@ -60,7 +62,7 @@ public PlexProperties(@JsonProperty(value = "plexServers") @Nullable Set<PlexSer
@JsonProperty(value = "movieDbApiKey") @Nullable String movieDbApiKey,
@JsonProperty(value = "password") @Nullable String password,
@JsonProperty(value = "schedule") @Nullable Schedule schedule) {
this.plexServers = plexServers == null ? new HashSet<>() : plexServers;
this.plexServers = plexServers == null ? new ArrayList<>() : plexServers;
this.telegramProperties = telegramProperties == null ? TelegramProperties.getDefault() : telegramProperties;
this.pushBulletProperties = pushBulletProperties == null ? PushBulletProperties.getDefault() : pushBulletProperties;
this.emailProperties = emailProperties == null ? EmailProperties.getDefault() : emailProperties;
Expand All @@ -74,7 +76,7 @@ public PlexProperties(@JsonProperty(value = "plexServers") @Nullable Set<PlexSer
}

public PlexProperties() {
this.plexServers = new HashSet<>();
this.plexServers = new ArrayList<>();
this.telegramProperties = TelegramProperties.getDefault();
this.pushBulletProperties = PushBulletProperties.getDefault();
this.emailProperties = EmailProperties.getDefault();
Expand All @@ -88,7 +90,7 @@ public PlexProperties() {
}

@NotNull
public Set<PlexServer> getPlexServers() {
public List<PlexServer> getPlexServers() {
return plexServers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package com.jasonhhouse.gaps.service;

import org.jetbrains.annotations.NotNull;

/**
* Handles the process of searching, movies, counts, and canceling
*/
Expand All @@ -19,7 +21,7 @@ public interface GapsSearch {
/**
* Kicks of searching for all missing movies
*/
void run(String machineIdentifier, Integer key);
void run(@NotNull String machineIdentifier, @NotNull Integer key);

/**
* Cancel the current search
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
@@ -0,0 +1,49 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

package com.jasonhhouse.gaps;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.properties.DiscordProperties;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class MovieFromCollectionTest {

@NotNull
private ObjectMapper objectMapper;

@BeforeEach
void setUp() {
objectMapper = new ObjectMapper();
}

@Test
void testReadingFromJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", MovieFromCollection.class);
assertEquals("TITLE", movieFromCollection.getTitle(), "Title should be 'TITLE'");
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",123,true);
String json = objectMapper.writeValueAsString(movieFromCollection);
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", json, "JSON output should be equal");
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.2.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.3.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.2.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.3.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.2.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.3.jar /usr/app/gaps.jar

COPY startDebug.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.2.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.3.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.raspbian
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.2.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.3.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.riscv64
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.2.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.3.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
8 changes: 4 additions & 4 deletions GapsWeb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.2</version>
<version>0.8.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,19 +21,19 @@
<dependency>
<groupId>com.jasonhhouse</groupId>
<artifactId>Core</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>
</dependency>

<dependency>
<groupId>com.jasonhhouse</groupId>
<artifactId>Plex</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>
</dependency>

<dependency>
<groupId>com.jasonhhouse</groupId>
<artifactId>RadarrV3</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>
</dependency>

<dependency>
Expand Down
Loading

0 comments on commit eb86553

Please sign in to comment.