MovieMeterPosterPlugin extends AbstractMoviePosterPlugin { @Override public String getIdFromMovieInfo(String title, String year) { String id = UNKNOWN; LOG.debug("Looking for MovieMeter ID for {} ({})", title, year); List<SearchResult> results; try { results = api.search(title); } catch (MovieMeterException ex) { LOG.warn("Failed to get Movie Meter search results for {} ({}): {}", title, year, ex.getMessage(), ex); return id; } if (results.isEmpty()) { return id; } int fYear = NumberUtils.toInt(year, 0); double maxMatch = 0.0; for (SearchResult sr : results) { if (fYear > 0 && sr.getYear() != fYear) { continue; } double result = StringUtils.getJaroWinklerDistance(title, sr.getTitle()); if (result > maxMatch) { LOG.trace("Better match found for {} ({}) = {} ({}) [{}]", title, year, sr.getTitle(), sr.getYear(), maxMatch); maxMatch = result; id = Integer.toString(sr.getId()); } } if (isValidString(id)) { LOG.debug("MovieMeter ID '{}' found for {} ({}), Match confidence: {}", id, title, year, maxMatch); } return id; } MovieMeterPosterPlugin(); @Override String getIdFromMovieInfo(String title, String year); @Override IImage getPosterUrl(String id); @Override IImage getPosterUrl(String title, String year); @Override String getName();  }
@Test public void testGetIdFromMovieInfo() { LOG.info("getIdFromMovieInfo"); for (TestData td : testData) { LOG.info("Testing {} ({})", td.title, td.year); String result = plugin.getIdFromMovieInfo(td.title, td.year); assertEquals("Wrong ID found for " + td.title, td.id, result); } }