@Test public void testGetSummaryByGenre() { GenreSummary genreSummary = null; genreSummary = movieService.getSummaryByGenre(movieService .filterMovieSetByGenre(movieSet, ACTION_AND_ADVENTURE.toString()), ACTION_AND_ADVENTURE .toString()); assertEquals( "Incorrect movieTitleCount for " + ACTION_AND_ADVENTURE.toString(), 5, genreSummary.getMovieTitleCount()); assertEquals( "Incorrect soapTitleCount for " + ACTION_AND_ADVENTURE.toString(), 0, genreSummary.getSoapTitleCount()); genreSummary = movieService .getSummaryByGenre( movieService.filterMovieSetByGenre(movieSet, HORROR.toString()), HORROR.toString()); assertEquals("Incorrect movieTitleCount for " + HORROR.toString(), 6, genreSummary.getMovieTitleCount()); assertEquals("Incorrect soapTitleCount for " + HORROR.toString(), 0, genreSummary.getSoapTitleCount()); }
@SuppressWarnings("unused") @Override public GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre, String genre) { Iterator<Movie> it = null; Movie currentMovie = null; String currentMovieParent = null; short currentMovieYear = 0; Movie previousMovie = null; String previousMovieParent = null; int movieTitleCount = 0; int soapTitleCount = 0; long sumOfSizeOfAllTitlesInThisGenre = 0L; GenreSummary genreSummary = null; it = movieSetFilteredByGenre.iterator(); for (int i = 0; it.hasNext(); i++) { currentMovie = it.next(); currentMovieParent = currentMovie.getParent(); currentMovieYear = currentMovie.getYear(); logger.debug("Current movie: " + currentMovie); if (currentMovieYear == Movie.UNKNOWN_RELEASE_YEAR) { logger.debug("Current movie is a soap. " + "Soap count is incremented."); soapTitleCount++; } else { if (!isParentNotASeries(currentMovieParent)) { logger.debug("Current movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!isParentNotASeries(previousMovieParent)) { logger.debug("Previous movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!(currentMovieParent.equals(previousMovieParent))) { logger.debug("Current movie parent is not equal to " + "previous movie parent. " + "Movie count is incremented."); movieTitleCount++; } else { logger.debug("Movie count is not incremented."); } } logger.debug("Movie count: " + movieTitleCount); previousMovie = currentMovie; previousMovieParent = currentMovieParent; sumOfSizeOfAllTitlesInThisGenre += currentMovie.getFilesize(); } genreSummary = new GenreSummary(); genreSummary.setGenre(genre); genreSummary.setMovieTitleCount(movieTitleCount); genreSummary.setSoapTitleCount(soapTitleCount); genreSummary .setSumOfSizeOfAllTitlesInThisGenre(sumOfSizeOfAllTitlesInThisGenre); return genreSummary; }
MovieServiceImpl implements MovieService { @SuppressWarnings("unused") @Override public GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre, String genre) { Iterator<Movie> it = null; Movie currentMovie = null; String currentMovieParent = null; short currentMovieYear = 0; Movie previousMovie = null; String previousMovieParent = null; int movieTitleCount = 0; int soapTitleCount = 0; long sumOfSizeOfAllTitlesInThisGenre = 0L; GenreSummary genreSummary = null; it = movieSetFilteredByGenre.iterator(); for (int i = 0; it.hasNext(); i++) { currentMovie = it.next(); currentMovieParent = currentMovie.getParent(); currentMovieYear = currentMovie.getYear(); logger.debug("Current movie: " + currentMovie); if (currentMovieYear == Movie.UNKNOWN_RELEASE_YEAR) { logger.debug("Current movie is a soap. " + "Soap count is incremented."); soapTitleCount++; } else { if (!isParentNotASeries(currentMovieParent)) { logger.debug("Current movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!isParentNotASeries(previousMovieParent)) { logger.debug("Previous movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!(currentMovieParent.equals(previousMovieParent))) { logger.debug("Current movie parent is not equal to " + "previous movie parent. " + "Movie count is incremented."); movieTitleCount++; } else { logger.debug("Movie count is not incremented."); } } logger.debug("Movie count: " + movieTitleCount); previousMovie = currentMovie; previousMovieParent = currentMovieParent; sumOfSizeOfAllTitlesInThisGenre += currentMovie.getFilesize(); } genreSummary = new GenreSummary(); genreSummary.setGenre(genre); genreSummary.setMovieTitleCount(movieTitleCount); genreSummary.setSoapTitleCount(soapTitleCount); genreSummary .setSumOfSizeOfAllTitlesInThisGenre(sumOfSizeOfAllTitlesInThisGenre); return genreSummary; } }
MovieServiceImpl implements MovieService { @SuppressWarnings("unused") @Override public GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre, String genre) { Iterator<Movie> it = null; Movie currentMovie = null; String currentMovieParent = null; short currentMovieYear = 0; Movie previousMovie = null; String previousMovieParent = null; int movieTitleCount = 0; int soapTitleCount = 0; long sumOfSizeOfAllTitlesInThisGenre = 0L; GenreSummary genreSummary = null; it = movieSetFilteredByGenre.iterator(); for (int i = 0; it.hasNext(); i++) { currentMovie = it.next(); currentMovieParent = currentMovie.getParent(); currentMovieYear = currentMovie.getYear(); logger.debug("Current movie: " + currentMovie); if (currentMovieYear == Movie.UNKNOWN_RELEASE_YEAR) { logger.debug("Current movie is a soap. " + "Soap count is incremented."); soapTitleCount++; } else { if (!isParentNotASeries(currentMovieParent)) { logger.debug("Current movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!isParentNotASeries(previousMovieParent)) { logger.debug("Previous movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!(currentMovieParent.equals(previousMovieParent))) { logger.debug("Current movie parent is not equal to " + "previous movie parent. " + "Movie count is incremented."); movieTitleCount++; } else { logger.debug("Movie count is not incremented."); } } logger.debug("Movie count: " + movieTitleCount); previousMovie = currentMovie; previousMovieParent = currentMovieParent; sumOfSizeOfAllTitlesInThisGenre += currentMovie.getFilesize(); } genreSummary = new GenreSummary(); genreSummary.setGenre(genre); genreSummary.setMovieTitleCount(movieTitleCount); genreSummary.setSoapTitleCount(soapTitleCount); genreSummary .setSumOfSizeOfAllTitlesInThisGenre(sumOfSizeOfAllTitlesInThisGenre); return genreSummary; } MovieServiceImpl(); }
MovieServiceImpl implements MovieService { @SuppressWarnings("unused") @Override public GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre, String genre) { Iterator<Movie> it = null; Movie currentMovie = null; String currentMovieParent = null; short currentMovieYear = 0; Movie previousMovie = null; String previousMovieParent = null; int movieTitleCount = 0; int soapTitleCount = 0; long sumOfSizeOfAllTitlesInThisGenre = 0L; GenreSummary genreSummary = null; it = movieSetFilteredByGenre.iterator(); for (int i = 0; it.hasNext(); i++) { currentMovie = it.next(); currentMovieParent = currentMovie.getParent(); currentMovieYear = currentMovie.getYear(); logger.debug("Current movie: " + currentMovie); if (currentMovieYear == Movie.UNKNOWN_RELEASE_YEAR) { logger.debug("Current movie is a soap. " + "Soap count is incremented."); soapTitleCount++; } else { if (!isParentNotASeries(currentMovieParent)) { logger.debug("Current movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!isParentNotASeries(previousMovieParent)) { logger.debug("Previous movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!(currentMovieParent.equals(previousMovieParent))) { logger.debug("Current movie parent is not equal to " + "previous movie parent. " + "Movie count is incremented."); movieTitleCount++; } else { logger.debug("Movie count is not incremented."); } } logger.debug("Movie count: " + movieTitleCount); previousMovie = currentMovie; previousMovieParent = currentMovieParent; sumOfSizeOfAllTitlesInThisGenre += currentMovie.getFilesize(); } genreSummary = new GenreSummary(); genreSummary.setGenre(genre); genreSummary.setMovieTitleCount(movieTitleCount); genreSummary.setSoapTitleCount(soapTitleCount); genreSummary .setSumOfSizeOfAllTitlesInThisGenre(sumOfSizeOfAllTitlesInThisGenre); return genreSummary; } MovieServiceImpl(); @Override SortedSet<Movie> getMovieSet(String path); String getMovieDirectory(); @Override Set<Movie> filterMovieSetByGenre(Set<Movie> movieSet, String genre); @Override Map<String, Set<Movie>> groupMovieSetByGenre(Set<Movie> movieSet); @Override Summary getSummary(Map<String, Set<Movie>> movieSetGroupedByGenre); @SuppressWarnings("unused") @Override GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre,
			String genre); }
MovieServiceImpl implements MovieService { @SuppressWarnings("unused") @Override public GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre, String genre) { Iterator<Movie> it = null; Movie currentMovie = null; String currentMovieParent = null; short currentMovieYear = 0; Movie previousMovie = null; String previousMovieParent = null; int movieTitleCount = 0; int soapTitleCount = 0; long sumOfSizeOfAllTitlesInThisGenre = 0L; GenreSummary genreSummary = null; it = movieSetFilteredByGenre.iterator(); for (int i = 0; it.hasNext(); i++) { currentMovie = it.next(); currentMovieParent = currentMovie.getParent(); currentMovieYear = currentMovie.getYear(); logger.debug("Current movie: " + currentMovie); if (currentMovieYear == Movie.UNKNOWN_RELEASE_YEAR) { logger.debug("Current movie is a soap. " + "Soap count is incremented."); soapTitleCount++; } else { if (!isParentNotASeries(currentMovieParent)) { logger.debug("Current movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!isParentNotASeries(previousMovieParent)) { logger.debug("Previous movie parent is a series. " + "Movie count is incremented."); movieTitleCount++; } else if (!(currentMovieParent.equals(previousMovieParent))) { logger.debug("Current movie parent is not equal to " + "previous movie parent. " + "Movie count is incremented."); movieTitleCount++; } else { logger.debug("Movie count is not incremented."); } } logger.debug("Movie count: " + movieTitleCount); previousMovie = currentMovie; previousMovieParent = currentMovieParent; sumOfSizeOfAllTitlesInThisGenre += currentMovie.getFilesize(); } genreSummary = new GenreSummary(); genreSummary.setGenre(genre); genreSummary.setMovieTitleCount(movieTitleCount); genreSummary.setSoapTitleCount(soapTitleCount); genreSummary .setSumOfSizeOfAllTitlesInThisGenre(sumOfSizeOfAllTitlesInThisGenre); return genreSummary; } MovieServiceImpl(); @Override SortedSet<Movie> getMovieSet(String path); String getMovieDirectory(); @Override Set<Movie> filterMovieSetByGenre(Set<Movie> movieSet, String genre); @Override Map<String, Set<Movie>> groupMovieSetByGenre(Set<Movie> movieSet); @Override Summary getSummary(Map<String, Set<Movie>> movieSetGroupedByGenre); @SuppressWarnings("unused") @Override GenreSummary getSummaryByGenre(Set<Movie> movieSetFilteredByGenre,
			String genre);  }