OfdbPlugin implements MovieDatabasePlugin { @Override public boolean scan(Movie movie) { imdbp.scan(movie); String ofdbUrl = getMovieId(movie); if (StringTools.isNotValidString(ofdbUrl)) { LOG.debug("OFDb url not available : {}", movie.getTitle()); return Boolean.FALSE; } LOG.debug("OFDb url available ({}), updating media info", ofdbUrl); return updateMediaInfo(movie, ofdbUrl); } OfdbPlugin(); @Override String getPluginID(); String getMovieId(Movie movie); String getMovieId(String title, String year); @Override boolean scan(Movie movie); @Override boolean scanNFO(String nfo, Movie movie); @Override void scanTVShowTitles(Movie movie); @Override boolean scan(Person person); static final String OFDB_PLUGIN_ID; }
@Test public void testScan() { LOG.info("Scan"); Movie movie = new Movie(); movie.setId(OfdbPlugin.OFDB_PLUGIN_ID, "http: OverrideTools.putMoviePriorities(OverrideFlag.TITLE, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.ORIGINALTITLE, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.YEAR, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.COUNTRY, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.PLOT, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.OUTLINE, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.GENRES, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.DIRECTORS, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.ACTORS, "ofdb,imdb"); OverrideTools.putMoviePriorities(OverrideFlag.WRITERS, "ofdb,imdb"); ofdbPlugin.scan(movie); assertEquals("Avatar - Aufbruch nach Pandora", movie.getTitle()); assertEquals("Avatar", movie.getOriginalTitle()); assertEquals("2009", movie.getYear()); assertEquals("Großbritannien / USA", movie.getCountriesAsString()); assertFalse(Movie.UNKNOWN.equals(movie.getPlot())); assertFalse(Movie.UNKNOWN.equals(movie.getOutline())); assertTrue(movie.getGenres().contains("Abenteuer")); assertTrue(movie.getGenres().contains("Action")); assertTrue(movie.getGenres().contains("Science-Fiction")); LinkedHashSet<String> testList = new LinkedHashSet<>(); testList.add("James Cameron"); assertEquals(Arrays.asList(testList.toArray()).toString(), Arrays.asList(Arrays.copyOf(movie.getDirectors().toArray(), 1)).toString()); testList.clear(); testList.add("Sam Worthington"); testList.add("Zoe Saldana"); assertEquals(Arrays.asList(testList.toArray()).toString(), Arrays.asList(Arrays.copyOf(movie.getCast().toArray(), 2)).toString()); testList.clear(); testList.add("James Cameron"); assertEquals(Arrays.asList(testList.toArray()).toString(), Arrays.asList(Arrays.copyOf(movie.getWriters().toArray(), 1)).toString()); }