FilmaffinityPlugin extends ImdbPlugin { @Override public boolean scan(Movie movie) { String filmAffinityId = filmAffinityInfo.arrangeId(movie.getId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID)); if (StringTools.isNotValidString(filmAffinityId)) { filmAffinityId = filmAffinityInfo.getIdFromMovieInfo(movie.getTitle(), movie.getYear(), movie.getSeason()); } if (StringTools.isValidString(filmAffinityId)) { movie.setId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID, filmAffinityId); } return updateFilmAffinityMediaInfo(movie); } FilmaffinityPlugin(); @Override String getPluginID(); @Override boolean scan(Movie movie); @Override boolean scanNFO(String nfo, Movie movie);  }
@Test public void testScan() { LOG.info("testScan"); Movie movie = new Movie(); movie.setTitle("Blade Runner", Movie.UNKNOWN); movie.setYear("1982", Movie.UNKNOWN); assertEquals(true, faPlugin.scan(movie)); assertEquals("film358476.html", movie.getId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID)); assertEquals("112 m", movie.getRuntime()); assertEquals("Estados Unidos", movie.getCountriesAsString()); assertTrue(movie.getDirectors().size() > 0); assertTrue(movie.getWriters().size() > 0); assertTrue(movie.getCast().size() > 0); assertTrue(movie.getGenres().size() > 0); }
@Test public void testScanNoYear() { LOG.info("testScanNoYear"); Movie movie = new Movie(); movie.setTitle("Cloverfield", Movie.UNKNOWN); assertEquals(true, faPlugin.scan(movie)); assertEquals("2008", movie.getYear()); }
@Test public void testScanYear() { LOG.info("testScanYear"); Movie movie = new Movie(); movie.setTitle("Avatar", Movie.UNKNOWN); movie.setYear("2009", Movie.UNKNOWN); assertEquals(true, faPlugin.scan(movie)); assertEquals("2009", movie.getYear()); }
@Test public void testScanCountry1() { LOG.info("testScanCountry1"); Movie movie = new Movie(); movie.setTitle("25 grados en invierno", Movie.UNKNOWN); movie.setId(FilmAffinityInfo.FILMAFFINITY_PLUGIN_ID, "730391"); movie.setId(ImdbPlugin.IMDB_PLUGIN_ID, "tt0356317"); assertEquals(true, faPlugin.scan(movie)); assertEquals("Bélgica", movie.getCountriesAsString()); }
@Test public void testScanCountry2() { LOG.info("testScanCountry2"); Movie movie = new Movie(); movie.setTitle("Matrix Revolutions", Movie.UNKNOWN); assertEquals(true, faPlugin.scan(movie)); assertEquals("Estados Unidos", movie.getCountriesAsString()); }