@Test public void testCreateGenreSheets() throws Exception { Sheet genreSheet = null; Row row = null; MovieManager.createGenreSheet(movieService.filterMovieSetByGenre( movieSet, ACTION_AND_ADVENTURE.toString()), ACTION_AND_ADVENTURE.toString()); MovieManager .createGenreSheet( movieService.filterMovieSetByGenre(movieSet, HORROR.toString()), HORROR.toString()); InputStream input = new FileInputStream(outputFile); Workbook wb = WorkbookFactory.create(input); genreSheet = wb.getSheet(ACTION_AND_ADVENTURE.toString()); assertNotNull(genreSheet); row = genreSheet.getRow(1); assertEquals(row.getCell(0).getStringCellValue(), "3-10 To Yuma.mkv"); row = genreSheet.getRow(3); assertEquals(row.getCell(0).getStringCellValue(), "Casino Royal.mkv"); genreSheet = wb.getSheet(HORROR.toString()); assertNotNull(genreSheet); row = genreSheet.getRow(1); assertEquals(row.getCell(0).getStringCellValue(), "I Saw The Devil.mkv"); assertEquals(row.getCell(3).getStringCellValue(), "I Saw The Devil (2010)"); row = genreSheet.getRow(2); assertEquals(row.getCell(0).getStringCellValue(), "Inferno.mkv"); assertEquals(row.getCell(3).getStringCellValue(), "The Three Mothers Trilogy"); input.close(); }
public static void createGenreSheet(Set<Movie> filteredMovieSetByGenre, String genre) throws Exception { final String MOVIE_NAME = "Movie Name"; final String RELEASE_YEAR = "Release Year"; final String FILESIZE = "Filesize"; final String PARENT = "Parent"; Workbook wb = createWorkbook(outputFile); Sheet worksheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); Iterator<Movie> it = null; Movie movie = null; worksheet = createNewSheet(wb, genre.toString()); List<Movie> movies = new ArrayList<Movie>(); movies.addAll(filteredMovieSetByGenre); Collections.sort(movies, new MovieComparator<Movie>()); it = movies.iterator(); row = worksheet.createRow(0); createCell(row, 0, headerCellStyle, MOVIE_NAME, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, RELEASE_YEAR, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, FILESIZE, Cell.CELL_TYPE_STRING); createCell(row, 3, headerCellStyle, PARENT, Cell.CELL_TYPE_STRING); for (int i = 0; it.hasNext(); i++) { row = worksheet.createRow(i + 1); movie = it.next(); createCell(row, 0, bodyCellStyle, movie.getName() + movie.getFileExtension(), Cell.CELL_TYPE_STRING); createCell(row, 1, bodyCellStyle, movie.getYear(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(movie.getFilesize()), Cell.CELL_TYPE_STRING); createCell(row, 3, bodyCellStyle, movie.getParent(), Cell.CELL_TYPE_STRING); Cell cell = row.getCell(1); if (((short) cell.getNumericCellValue()) == Movie.UNKNOWN_RELEASE_YEAR) { cell.setCellValue(EMPTY); } } autoSizeColumns(worksheet); writeToDisk(wb); }
MovieManager { public static void createGenreSheet(Set<Movie> filteredMovieSetByGenre, String genre) throws Exception { final String MOVIE_NAME = "Movie Name"; final String RELEASE_YEAR = "Release Year"; final String FILESIZE = "Filesize"; final String PARENT = "Parent"; Workbook wb = createWorkbook(outputFile); Sheet worksheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); Iterator<Movie> it = null; Movie movie = null; worksheet = createNewSheet(wb, genre.toString()); List<Movie> movies = new ArrayList<Movie>(); movies.addAll(filteredMovieSetByGenre); Collections.sort(movies, new MovieComparator<Movie>()); it = movies.iterator(); row = worksheet.createRow(0); createCell(row, 0, headerCellStyle, MOVIE_NAME, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, RELEASE_YEAR, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, FILESIZE, Cell.CELL_TYPE_STRING); createCell(row, 3, headerCellStyle, PARENT, Cell.CELL_TYPE_STRING); for (int i = 0; it.hasNext(); i++) { row = worksheet.createRow(i + 1); movie = it.next(); createCell(row, 0, bodyCellStyle, movie.getName() + movie.getFileExtension(), Cell.CELL_TYPE_STRING); createCell(row, 1, bodyCellStyle, movie.getYear(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(movie.getFilesize()), Cell.CELL_TYPE_STRING); createCell(row, 3, bodyCellStyle, movie.getParent(), Cell.CELL_TYPE_STRING); Cell cell = row.getCell(1); if (((short) cell.getNumericCellValue()) == Movie.UNKNOWN_RELEASE_YEAR) { cell.setCellValue(EMPTY); } } autoSizeColumns(worksheet); writeToDisk(wb); } }
MovieManager { public static void createGenreSheet(Set<Movie> filteredMovieSetByGenre, String genre) throws Exception { final String MOVIE_NAME = "Movie Name"; final String RELEASE_YEAR = "Release Year"; final String FILESIZE = "Filesize"; final String PARENT = "Parent"; Workbook wb = createWorkbook(outputFile); Sheet worksheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); Iterator<Movie> it = null; Movie movie = null; worksheet = createNewSheet(wb, genre.toString()); List<Movie> movies = new ArrayList<Movie>(); movies.addAll(filteredMovieSetByGenre); Collections.sort(movies, new MovieComparator<Movie>()); it = movies.iterator(); row = worksheet.createRow(0); createCell(row, 0, headerCellStyle, MOVIE_NAME, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, RELEASE_YEAR, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, FILESIZE, Cell.CELL_TYPE_STRING); createCell(row, 3, headerCellStyle, PARENT, Cell.CELL_TYPE_STRING); for (int i = 0; it.hasNext(); i++) { row = worksheet.createRow(i + 1); movie = it.next(); createCell(row, 0, bodyCellStyle, movie.getName() + movie.getFileExtension(), Cell.CELL_TYPE_STRING); createCell(row, 1, bodyCellStyle, movie.getYear(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(movie.getFilesize()), Cell.CELL_TYPE_STRING); createCell(row, 3, bodyCellStyle, movie.getParent(), Cell.CELL_TYPE_STRING); Cell cell = row.getCell(1); if (((short) cell.getNumericCellValue()) == Movie.UNKNOWN_RELEASE_YEAR) { cell.setCellValue(EMPTY); } } autoSizeColumns(worksheet); writeToDisk(wb); } MovieManager();  MovieManager(File inputDir, File outputFile); }
MovieManager { public static void createGenreSheet(Set<Movie> filteredMovieSetByGenre, String genre) throws Exception { final String MOVIE_NAME = "Movie Name"; final String RELEASE_YEAR = "Release Year"; final String FILESIZE = "Filesize"; final String PARENT = "Parent"; Workbook wb = createWorkbook(outputFile); Sheet worksheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); Iterator<Movie> it = null; Movie movie = null; worksheet = createNewSheet(wb, genre.toString()); List<Movie> movies = new ArrayList<Movie>(); movies.addAll(filteredMovieSetByGenre); Collections.sort(movies, new MovieComparator<Movie>()); it = movies.iterator(); row = worksheet.createRow(0); createCell(row, 0, headerCellStyle, MOVIE_NAME, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, RELEASE_YEAR, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, FILESIZE, Cell.CELL_TYPE_STRING); createCell(row, 3, headerCellStyle, PARENT, Cell.CELL_TYPE_STRING); for (int i = 0; it.hasNext(); i++) { row = worksheet.createRow(i + 1); movie = it.next(); createCell(row, 0, bodyCellStyle, movie.getName() + movie.getFileExtension(), Cell.CELL_TYPE_STRING); createCell(row, 1, bodyCellStyle, movie.getYear(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(movie.getFilesize()), Cell.CELL_TYPE_STRING); createCell(row, 3, bodyCellStyle, movie.getParent(), Cell.CELL_TYPE_STRING); Cell cell = row.getCell(1); if (((short) cell.getNumericCellValue()) == Movie.UNKNOWN_RELEASE_YEAR) { cell.setCellValue(EMPTY); } } autoSizeColumns(worksheet); writeToDisk(wb); } MovieManager();  MovieManager(File inputDir, File outputFile); static void validateFile(File... files); static GenreSummary getSummaryByGenre(String genre); static Summary getSummary(); static Map<String, Set<Movie>> getMovieSetGroupedByGenre(); static void createSummarySheet(Summary summary); static void createGenreSheet(Set<Movie> filteredMovieSetByGenre,
			String genre); static Summary getSummary(
			Map<String, Set<Movie>> movieSetGroupedByGenre); }
MovieManager { public static void createGenreSheet(Set<Movie> filteredMovieSetByGenre, String genre) throws Exception { final String MOVIE_NAME = "Movie Name"; final String RELEASE_YEAR = "Release Year"; final String FILESIZE = "Filesize"; final String PARENT = "Parent"; Workbook wb = createWorkbook(outputFile); Sheet worksheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); Iterator<Movie> it = null; Movie movie = null; worksheet = createNewSheet(wb, genre.toString()); List<Movie> movies = new ArrayList<Movie>(); movies.addAll(filteredMovieSetByGenre); Collections.sort(movies, new MovieComparator<Movie>()); it = movies.iterator(); row = worksheet.createRow(0); createCell(row, 0, headerCellStyle, MOVIE_NAME, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, RELEASE_YEAR, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, FILESIZE, Cell.CELL_TYPE_STRING); createCell(row, 3, headerCellStyle, PARENT, Cell.CELL_TYPE_STRING); for (int i = 0; it.hasNext(); i++) { row = worksheet.createRow(i + 1); movie = it.next(); createCell(row, 0, bodyCellStyle, movie.getName() + movie.getFileExtension(), Cell.CELL_TYPE_STRING); createCell(row, 1, bodyCellStyle, movie.getYear(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(movie.getFilesize()), Cell.CELL_TYPE_STRING); createCell(row, 3, bodyCellStyle, movie.getParent(), Cell.CELL_TYPE_STRING); Cell cell = row.getCell(1); if (((short) cell.getNumericCellValue()) == Movie.UNKNOWN_RELEASE_YEAR) { cell.setCellValue(EMPTY); } } autoSizeColumns(worksheet); writeToDisk(wb); } MovieManager();  MovieManager(File inputDir, File outputFile); static void validateFile(File... files); static GenreSummary getSummaryByGenre(String genre); static Summary getSummary(); static Map<String, Set<Movie>> getMovieSetGroupedByGenre(); static void createSummarySheet(Summary summary); static void createGenreSheet(Set<Movie> filteredMovieSetByGenre,
			String genre); static Summary getSummary(
			Map<String, Set<Movie>> movieSetGroupedByGenre); static final String EMPTY; }