Merge pull request #234 from JasonHHouse/improvement/collection_movie_years

Improvement/collection movie years
This commit is contained in:
Jason House
2021-06-02 23:43:33 -04:00
committed by GitHub
28 changed files with 84 additions and 61 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -14,14 +14,18 @@ public final class MovieFromCollection {
private final Integer tmdbId;
@NotNull
private final Boolean owned;
@NotNull
private final Integer year;
@JsonCreator
public MovieFromCollection(@JsonProperty(value = "title") @Nullable String title,
@JsonProperty(value = "tmdbId") @Nullable Integer tmdbId,
@JsonProperty(value = "owned") @Nullable Boolean owned) {
@JsonProperty(value = "owned") @Nullable Boolean owned,
@JsonProperty(value = "year") @Nullable Integer year) {
this.title = StringUtils.isEmpty(title) ? "" : title;
this.tmdbId = tmdbId == null ? -1 : tmdbId;
this.owned = owned != null && owned;
this.year = year == null ? -1 : year;
}
@NotNull
@@ -39,27 +43,30 @@ public final class MovieFromCollection {
return owned;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MovieFromCollection that = (MovieFromCollection) o;
return title.equals(that.title) &&
tmdbId.equals(that.tmdbId) &&
owned.equals(that.owned);
}
@Override
public int hashCode() {
return Objects.hash(title, tmdbId, owned);
public Integer getYear() {
return year;
}
@Override
public String toString() {
return "MovieFromCollection{" +
"title='" + title + '\'' +
", id='" + tmdbId + '\'' +
", tmdbId=" + tmdbId +
", owned=" + owned +
", year=" + year +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MovieFromCollection that = (MovieFromCollection) o;
return title.equals(that.title) && tmdbId.equals(that.tmdbId) && owned.equals(that.owned) && year.equals(that.year);
}
@Override
public int hashCode() {
return Objects.hash(title, tmdbId, owned, year);
}
}

View File

@@ -9,32 +9,40 @@ 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, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, true, 5);
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, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 9874, false, 5);
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, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false, 5);
assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of name field");
}
@Test
void MovieFromCollectionTest_Invalid_Year (){
MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false, 4);
assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of year 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, 5);
MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, false, 5);
assertEquals(movieFromCollection1, movieFromCollection2, "Movies should be equal");
}

View File

@@ -13,9 +13,6 @@ 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;
@@ -34,16 +31,17 @@ class MovieFromCollectionTest {
@Test
void testReadingFromJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", MovieFromCollection.class);
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true,\"year\":5}}", 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'");
assertEquals(5, movieFromCollection.getYear(), "year should be '5'");
}
@Test
void testWritingToJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE",123,true);
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE",123,true, 5);
String json = objectMapper.writeValueAsString(movieFromCollection);
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", json, "JSON output should be equal");
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true,\"year\":5}", json, "JSON output should be equal");
}
}

View File

@@ -32,7 +32,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar
COPY start.sh /usr/app/

View File

@@ -36,7 +36,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar
COPY start.sh /usr/app/

View File

@@ -32,7 +32,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar
COPY start.sh /usr/app/

View File

@@ -32,7 +32,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar
COPY start.sh /usr/app/

View File

@@ -36,7 +36,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.9.4.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.9.5.jar /usr/app/gaps.jar
COPY start.sh /usr/app/

View File

@@ -48,4 +48,4 @@ RMDIR /r $INSTDIR
SectionEnd
# name the installer
OutFile "gaps-0.9.4-installer.exe"
OutFile "gaps-0.9.5-installer.exe"

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -36,7 +36,6 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
@@ -500,7 +499,7 @@ public class GapsSearchService implements GapsSearch {
LOGGER.info(collectionBasicMovie.toString());
Boolean owned = ownedBasicMovies.contains(collectionBasicMovie);
moviesInCollection.add(new MovieFromCollection(title, tmdbId, owned));
moviesInCollection.add(new MovieFromCollection(title, tmdbId, owned, year));
});
}

View File

@@ -50,7 +50,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.9.4
version: 0.9.5
storageFolder: /usr/data
properties:
rssFeed: rssFeed.json

View File

@@ -124,6 +124,12 @@ jQuery(($) => {
isEqual(a, b) {
return a === b;
},
getYear(year) {
if (year && (year !== -1 || year !== 0)) {
return ` (${year})`;
}
return '';
},
});
libraryTitle = $('#libraryTitle');

View File

@@ -29,7 +29,7 @@
<img loading="lazy" th:src="@{/images/final-2.svg}" alt="Gaps Logo" style="width:50%;height:50%;" class="center">
<h3 class="top-margin">About</h3>
<h4 class="top-margin text-primary">v0.9.4</h4>
<h4 class="top-margin text-primary">v0.9.5</h4>
<p class="text-muted">Gaps searches through your Plex Server. It then queries
for known

View File

@@ -27,7 +27,7 @@
<div class="container bottom-margin">
<img loading="lazy" th:src="@{/images/final-2.svg}" alt="Gaps Logo" style="width:50%;height:50%;" class="center">
<h3 class="top-margin">v0.9.4</h3>
<h3 class="top-margin">v0.9.5</h3>
<p class="text-muted">Gaps searches through your Plex Server. It then queries
for known

View File

@@ -156,7 +156,7 @@
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}"
href="https://www.themoviedb.org/movie/{{this.tmdbId}}" target="_blank"
class="list-group-item list-group-item-action"
rel="noopener noreferrer">{{this.title}}</a>
rel="noopener noreferrer">{{this.title}}{{getYear this.year}}</a>
{{/if}}
{{/each}}
</div>
@@ -170,12 +170,12 @@
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}"
class="list-group-item list-group-item-action active"
href="https://www.themoviedb.org/movie/{{this.tmdbId}}" target="_blank"
rel="noopener noreferrer">{{this.title}}</a>
rel="noopener noreferrer">{{this.title}}{{getYear this.year}}</a>
{{else}}
<a data-cy="{{@root.imdbId}}-{{this.tmdbId}}"
class="list-group-item list-group-item-action"
href="https://www.themoviedb.org/movie/{{this.tmdbId}}" target="_blank"
rel="noopener noreferrer">{{this.title}}</a>
rel="noopener noreferrer">{{this.title}}{{getYear this.year}}</a>
{{/if}}
{{/if}}
{{/each}}

View File

@@ -28,6 +28,11 @@
<img loading="lazy" th:src="@{/images/final-2.svg}" alt="Gaps Logo" style="width:50%;height:50%;" class="center">
<h3 class="top-margin">Updates</h3>
<h4 class="top-margin text-primary">v0.9.5</h4>
<ul class="text-muted">
<li>Adding years collection movies</li>
</ul>
<h4 class="top-margin text-primary">v0.9.4</h4>
<ul class="text-muted">
<li>Adding genres to owned and recommended movies</li>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.9.4</version>
<version>0.9.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -44,7 +44,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.9.4
version: 0.9.5
storageFolder: /{CUSTOM_FOLDER} #Change to folder that gaps has permission to read, write, and delete in.
properties:
rssFeed: rssFeed.json

2
build
View File

@@ -11,7 +11,7 @@
##
set -e
VERSION=0.9.4
VERSION=0.9.5
JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"
ZIP_VERSION="GapsAsJar-$VERSION.zip"
npm ci

View File

@@ -7,7 +7,7 @@ call npm run uglifyjs-pages
call mvn clean install
del GapsOnWindows\*.jar
del GapsOnWindows\README.md
copy GapsWeb\target\GapsWeb-0.9.4.jar GapsOnWindows\gaps.jar
copy GapsWeb\target\GapsWeb-0.9.5.jar GapsOnWindows\gaps.jar
copy README.md GapsOnWindows\
cd GapsOnWindows
makensis gaps.nsi

View File

@@ -21,7 +21,7 @@ describe('Verify About Page', () => {
.should('have.text', 'About');
cy.get('.container > :nth-child(3)')
.should('have.text', 'v0.9.4');
.should('have.text', 'v0.9.5');
cy.get('.container > :nth-child(6)')
.should('have.text', 'Software');

View File

@@ -97,10 +97,10 @@ describe('Search for Recommended', () => {
.should('have.text', 'Showing 1 to 7 of 7 entries');
cy.get('[data-cy=tt0432348-176]')
.should('have.text', 'Saw');
.should('have.text', 'Saw (2004)');
cy.get('[data-cy=tt0432348-215]')
.should('have.text', 'Saw II');
.should('have.text', 'Saw II (2005)');
});
it('Research Movies', () => {
@@ -119,10 +119,10 @@ describe('Search for Recommended', () => {
.should('have.text', 'Showing 1 to 7 of 7 entries');
cy.get('[data-cy=tt0432348-176]')
.should('have.text', 'Saw');
.should('have.text', 'Saw (2004)');
cy.get('[data-cy=tt0432348-215]')
.should('have.text', 'Saw II');
.should('have.text', 'Saw II (2005)');
cy.get('#movieContainer > [onclick="searchForMovies()"]')
.click();
@@ -131,9 +131,9 @@ describe('Search for Recommended', () => {
.should('have.text', 'Showing 1 to 7 of 7 entries');
cy.get('[data-cy=tt0432348-176]')
.should('have.text', 'Saw');
.should('have.text', 'Saw (2004)');
cy.get('[data-cy=tt0432348-215]')
.should('have.text', 'Saw II');
.should('have.text', 'Saw II (2005)');
});
});

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "gaps",
"version": "0.9.4",
"version": "0.9.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "gaps",
"version": "0.9.4",
"version": "0.9.5",
"description": "Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.",
"main": "/",
"dependencies": {

View File

@@ -17,7 +17,7 @@
</parent>
<groupId>com.jasonhhouse</groupId>
<artifactId>Gaps</artifactId>
<version>0.9.4</version>
<version>0.9.5</version>
<name>Gaps</name>
<description>Demo project for Spring Boot</description>
@@ -26,7 +26,7 @@
<apache.commons.lang3>3.9</apache.commons.lang3>
<apache.commons.text>1.9</apache.commons.text>
<commons.io>2.8.0</commons.io>
<gaps.version>0.9.4</gaps.version>
<gaps.version>0.9.5</gaps.version>
<google.findbugs>3.0.0</google.findbugs>
<guava>30.1-jre</guava>
<hibernate.core>5.2.12.Final</hibernate.core>