diff --git a/Core/pom.xml b/Core/pom.xml
index eb55078..63d4589 100644
--- a/Core/pom.xml
+++ b/Core/pom.xml
@@ -42,5 +42,14 @@
jackson-databind
2.10.1
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+
+
\ No newline at end of file
diff --git a/Core/src/main/java/com/jasonhhouse/gaps/GapsSearch.java b/Core/src/main/java/com/jasonhhouse/gaps/GapsSearch.java
index 596e659..185fc20 100644
--- a/Core/src/main/java/com/jasonhhouse/gaps/GapsSearch.java
+++ b/Core/src/main/java/com/jasonhhouse/gaps/GapsSearch.java
@@ -13,17 +13,38 @@ package com.jasonhhouse.gaps;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jetbrains.annotations.NotNull;
+/**
+ * Handles the process of searching, movies, counts, and canceling
+ */
public interface GapsSearch {
+ /**
+ * Kicks of searching for all missing movies
+ */
void run();
+ /**
+ * @return The total count of movies to be searched
+ */
@NotNull Integer getTotalMovieCount();
+ /**
+ * @return The current count of movies searched
+ */
@NotNull Integer getSearchedMovieCount();
+ /**
+ * @return The movies that are missing from collections
+ */
@NotNull CopyOnWriteArrayList getRecommendedMovies();
+ /**
+ * Cancel the current search
+ */
void cancelSearch();
+ /**
+ * @return Returns true if currently searching
+ */
boolean isSearching();
}
\ No newline at end of file
diff --git a/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java b/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java
index 17ddab9..b6864fe 100644
--- a/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java
+++ b/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java
@@ -13,11 +13,27 @@ package com.jasonhhouse.gaps;
import java.util.List;
import org.jetbrains.annotations.NotNull;
+/**
+ * Blackboard service interface for storing the PlexSearch object controllers
+ */
public interface GapsService {
+ /**
+ * @return Returns the PlexSearch instance as a singleton
+ */
PlexSearch getPlexSearch();
+ /**
+ * Updates PlexLibrary's to add them if not added and set them selected or unselected if added
+ *
+ * @param plexLibraries The libraries to add or update
+ */
void updateLibrarySelections(@NotNull List plexLibraries);
+ /**
+ * Updates the plex search object itself to the singleton object
+ *
+ * @param plexSearch The object to copy into the plex search singleton
+ */
void updatePlexSearch(PlexSearch plexSearch);
}
diff --git a/Core/src/main/java/com/jasonhhouse/gaps/PlexQuery.java b/Core/src/main/java/com/jasonhhouse/gaps/PlexQuery.java
index 3662ef9..9ebddab 100644
--- a/Core/src/main/java/com/jasonhhouse/gaps/PlexQuery.java
+++ b/Core/src/main/java/com/jasonhhouse/gaps/PlexQuery.java
@@ -13,8 +13,15 @@ package com.jasonhhouse.gaps;
import java.util.List;
import org.jetbrains.annotations.NotNull;
+/**
+ * Interface to handle connecting to a Plex instance and returning the known movie libraries
+ */
public interface PlexQuery {
+ /**
+ * @param plexSearch Needs to have the IP Address, port, and plex token to connect
+ * @return The list of libraries that are of type movie for that Plex server
+ */
@NotNull List getLibraries(@NotNull PlexSearch plexSearch);
}
diff --git a/Core/src/test/java/com/jasonhhouse/gaps/json/MovieSerializerTest.java b/Core/src/test/java/com/jasonhhouse/gaps/json/MovieSerializerTest.java
new file mode 100644
index 0000000..1187585
--- /dev/null
+++ b/Core/src/test/java/com/jasonhhouse/gaps/json/MovieSerializerTest.java
@@ -0,0 +1,48 @@
+package com.jasonhhouse.gaps.json;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.jasonhhouse.gaps.Movie;
+import java.io.StringWriter;
+import java.io.Writer;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+public class MovieSerializerTest {
+
+ @Test
+ void serializeAndDeserialize() throws Exception {
+ MovieSerializer movieSerializer = new MovieSerializer();
+ MovieDeserializer movieDeserializer = new MovieDeserializer();
+
+ Movie movie = new Movie.Builder("Alien", 1979)
+ .setTvdbId(1345)
+ .setCollection("Aliens Collection")
+ .setCollectionId(5423)
+ .setImdbId("IMDB ID")
+ .setPosterUrl("POSTER URL")
+ .build();
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ Writer jsonWriter = new StringWriter();
+ JsonFactory factory = new JsonFactory();
+ JsonGenerator jsonGenerator = factory.createGenerator(jsonWriter);
+ SerializerProvider serializerProvider = objectMapper.getSerializerProvider();
+
+ movieSerializer.serialize(movie, jsonGenerator, serializerProvider);
+ jsonGenerator.flush();
+
+ JsonParser jsonParser = factory.createParser(jsonWriter.toString());
+ DeserializationContext deserializationContext = objectMapper.getDeserializationContext();
+ jsonParser.setCodec(objectMapper);
+
+ Movie movie1 = movieDeserializer.deserialize(jsonParser, deserializationContext);
+ assertEquals(movie1, movie, "Failed to serialize then deserialize a movie");
+ }
+}
diff --git a/GapsWeb/pom.xml b/GapsWeb/pom.xml
index 3b000e7..efdd7f2 100644
--- a/GapsWeb/pom.xml
+++ b/GapsWeb/pom.xml
@@ -147,7 +147,6 @@
org.junit.jupiter
junit-jupiter-api
- 5.5.2
test
diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java
index c552f4f..a0a7a51 100644
--- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java
+++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java
@@ -218,7 +218,7 @@ public class GapsSearchService implements GapsSearch {
/**
* Using TMDB api (V3), get access to user list and add recommended movies to
*/
- private @Nullable String getTmdbAuthorization() {
+ /* private @Nullable String getTmdbAuthorization() {
// Create the request_token request
OkHttpClient client = new OkHttpClient();
@@ -286,7 +286,7 @@ public class GapsSearchService implements GapsSearch {
LOGGER.error("Unable to create session id: " + e.getMessage());
return null;
}
- }
+ }*/
/**
* Using TMDB api (V3), get access to user list and add recommended movies to
@@ -336,7 +336,7 @@ public class GapsSearchService implements GapsSearch {
}*/
/**
- * Connect to plex via the URL and parse all of the movies from the returned XML creating a HashSet of movies the
+ * Connect to plex via the URL and parse all the movies from the returned XML creating a HashSet of movies the
* user has.
*/
private void findAllPlexMovies() throws SearchCancelledException {
@@ -358,7 +358,7 @@ public class GapsSearchService implements GapsSearch {
for (String url : urls) {
//Cancel search if needed
if (cancelSearch.get()) {
- throw new SearchCancelledException("Search was cancelled");
+ throw new SearchCancelledException("Search cancelled");
}
try {
@@ -813,7 +813,7 @@ public class GapsSearchService implements GapsSearch {
}
- public static class UserInputThreadCountdown implements Runnable {
+ /* public static class UserInputThreadCountdown implements Runnable {
int time_limit = 60;
@@ -837,7 +837,7 @@ public class GapsSearchService implements GapsSearch {
System.in.close();
}
- }
+ }*/
private List generatePlexUrls() {
LOGGER.info(gapsService.getPlexSearch().getLibraries().toString());
diff --git a/pom.xml b/pom.xml
index 7595dd9..5c19c2f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,14 @@
annotations
17.0.0
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.5.2
+ test
+
+