@Test public void testCreateSummarySheet() throws Exception { final String SUMMARY = "Summary"; final String MOVIE_COUNT = "Movie Count"; final String SOAP_COUNT = "Soap Count"; final String SIZE = "Size"; Sheet summarySheet = null; Row row = null; MovieManager.createSummarySheet(summary); InputStream input = new FileInputStream(outputFile); Workbook wb = WorkbookFactory.create(input); summarySheet = wb.getSheet(SUMMARY); assertNotNull(summarySheet); row = summarySheet.getRow(0); assertEquals(summarySheet.getMergedRegion(0).getFirstRow(), 0); assertEquals(summarySheet.getMergedRegion(0).getLastRow(), 0); assertEquals(summarySheet.getMergedRegion(0).getFirstColumn(), 0); assertEquals(summarySheet.getMergedRegion(0).getLastColumn(), 2); assertEquals(row.getCell(0).getStringCellValue(), SUMMARY); row = summarySheet.getRow(1); assertEquals(row.getCell(0).getStringCellValue(), MOVIE_COUNT); assertEquals(row.getCell(1).getStringCellValue(), SOAP_COUNT); assertEquals(row.getCell(2).getStringCellValue(), SIZE); input.close(); }
public static void createSummarySheet(Summary summary) throws Exception { final String SUMMARY = "Summary"; final String MOVIE_COUNT = "Movie Count"; final String SOAP_COUNT = "Soap Count"; final String SIZE = "Size"; final String GENRE_SUMMARY = "Genre Summary"; Workbook wb = createWorkbook(outputFile); List<GenreSummary> genreSummaryList = summary.getGenreSummary(); Sheet summarySheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); summarySheet = createNewSheet(wb, SUMMARY); row = summarySheet.createRow(0); summarySheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2)); createCell(row, 0, headerCellStyle, SUMMARY, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(2); createCell(row, 0, bodyCellStyle, summary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, summary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(summary.getSumOfSizeOfAllTitles()), Cell.CELL_TYPE_STRING); for (GenreSummary genreSummary : genreSummaryList) { row = summarySheet.createRow(summarySheet.getLastRowNum() + 2); summarySheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 0, 2)); createCell(row, 0, headerCellStyle, GENRE_SUMMARY + " (" + genreSummary.getGenre() + ")", Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, bodyCellStyle, genreSummary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, genreSummary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(genreSummary .getSumOfSizeOfAllTitlesInThisGenre()), Cell.CELL_TYPE_STRING); autoSizeColumns(summarySheet); } writeToDisk(wb); }
MovieManager { public static void createSummarySheet(Summary summary) throws Exception { final String SUMMARY = "Summary"; final String MOVIE_COUNT = "Movie Count"; final String SOAP_COUNT = "Soap Count"; final String SIZE = "Size"; final String GENRE_SUMMARY = "Genre Summary"; Workbook wb = createWorkbook(outputFile); List<GenreSummary> genreSummaryList = summary.getGenreSummary(); Sheet summarySheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); summarySheet = createNewSheet(wb, SUMMARY); row = summarySheet.createRow(0); summarySheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2)); createCell(row, 0, headerCellStyle, SUMMARY, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(2); createCell(row, 0, bodyCellStyle, summary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, summary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(summary.getSumOfSizeOfAllTitles()), Cell.CELL_TYPE_STRING); for (GenreSummary genreSummary : genreSummaryList) { row = summarySheet.createRow(summarySheet.getLastRowNum() + 2); summarySheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 0, 2)); createCell(row, 0, headerCellStyle, GENRE_SUMMARY + " (" + genreSummary.getGenre() + ")", Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, bodyCellStyle, genreSummary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, genreSummary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(genreSummary .getSumOfSizeOfAllTitlesInThisGenre()), Cell.CELL_TYPE_STRING); autoSizeColumns(summarySheet); } writeToDisk(wb); } }
MovieManager { public static void createSummarySheet(Summary summary) throws Exception { final String SUMMARY = "Summary"; final String MOVIE_COUNT = "Movie Count"; final String SOAP_COUNT = "Soap Count"; final String SIZE = "Size"; final String GENRE_SUMMARY = "Genre Summary"; Workbook wb = createWorkbook(outputFile); List<GenreSummary> genreSummaryList = summary.getGenreSummary(); Sheet summarySheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); summarySheet = createNewSheet(wb, SUMMARY); row = summarySheet.createRow(0); summarySheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2)); createCell(row, 0, headerCellStyle, SUMMARY, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(2); createCell(row, 0, bodyCellStyle, summary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, summary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(summary.getSumOfSizeOfAllTitles()), Cell.CELL_TYPE_STRING); for (GenreSummary genreSummary : genreSummaryList) { row = summarySheet.createRow(summarySheet.getLastRowNum() + 2); summarySheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 0, 2)); createCell(row, 0, headerCellStyle, GENRE_SUMMARY + " (" + genreSummary.getGenre() + ")", Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, bodyCellStyle, genreSummary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, genreSummary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(genreSummary .getSumOfSizeOfAllTitlesInThisGenre()), Cell.CELL_TYPE_STRING); autoSizeColumns(summarySheet); } writeToDisk(wb); } MovieManager();  MovieManager(File inputDir, File outputFile); }
MovieManager { public static void createSummarySheet(Summary summary) throws Exception { final String SUMMARY = "Summary"; final String MOVIE_COUNT = "Movie Count"; final String SOAP_COUNT = "Soap Count"; final String SIZE = "Size"; final String GENRE_SUMMARY = "Genre Summary"; Workbook wb = createWorkbook(outputFile); List<GenreSummary> genreSummaryList = summary.getGenreSummary(); Sheet summarySheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); summarySheet = createNewSheet(wb, SUMMARY); row = summarySheet.createRow(0); summarySheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2)); createCell(row, 0, headerCellStyle, SUMMARY, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(2); createCell(row, 0, bodyCellStyle, summary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, summary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(summary.getSumOfSizeOfAllTitles()), Cell.CELL_TYPE_STRING); for (GenreSummary genreSummary : genreSummaryList) { row = summarySheet.createRow(summarySheet.getLastRowNum() + 2); summarySheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 0, 2)); createCell(row, 0, headerCellStyle, GENRE_SUMMARY + " (" + genreSummary.getGenre() + ")", Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, bodyCellStyle, genreSummary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, genreSummary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(genreSummary .getSumOfSizeOfAllTitlesInThisGenre()), Cell.CELL_TYPE_STRING); autoSizeColumns(summarySheet); } 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 createSummarySheet(Summary summary) throws Exception { final String SUMMARY = "Summary"; final String MOVIE_COUNT = "Movie Count"; final String SOAP_COUNT = "Soap Count"; final String SIZE = "Size"; final String GENRE_SUMMARY = "Genre Summary"; Workbook wb = createWorkbook(outputFile); List<GenreSummary> genreSummaryList = summary.getGenreSummary(); Sheet summarySheet = null; Row row = null; CellStyle headerCellStyle = createHeaderCellStyle(wb.createCellStyle(), wb.createFont()); CellStyle bodyCellStyle = createBodyCellStyle(wb.createCellStyle(), wb.createFont()); summarySheet = createNewSheet(wb, SUMMARY); row = summarySheet.createRow(0); summarySheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 2)); createCell(row, 0, headerCellStyle, SUMMARY, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(2); createCell(row, 0, bodyCellStyle, summary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, summary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(summary.getSumOfSizeOfAllTitles()), Cell.CELL_TYPE_STRING); for (GenreSummary genreSummary : genreSummaryList) { row = summarySheet.createRow(summarySheet.getLastRowNum() + 2); summarySheet.addMergedRegion(new CellRangeAddress(row.getRowNum(), row.getRowNum(), 0, 2)); createCell(row, 0, headerCellStyle, GENRE_SUMMARY + " (" + genreSummary.getGenre() + ")", Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, headerCellStyle, MOVIE_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 1, headerCellStyle, SOAP_COUNT, Cell.CELL_TYPE_STRING); createCell(row, 2, headerCellStyle, SIZE, Cell.CELL_TYPE_STRING); row = summarySheet.createRow(summarySheet.getLastRowNum() + 1); createCell(row, 0, bodyCellStyle, genreSummary.getMovieTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 1, bodyCellStyle, genreSummary.getSoapTitleCount(), Cell.CELL_TYPE_NUMERIC); createCell(row, 2, bodyCellStyle, formatter.format(genreSummary .getSumOfSizeOfAllTitlesInThisGenre()), Cell.CELL_TYPE_STRING); autoSizeColumns(summarySheet); } 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; }