VerifyMojo extends AbstractITestMojo { List<CheckReport> collectReports() throws MojoFailureException { List<CheckReport> reports; try { reports = new ArrayList<>(readReportsFromFile(summaryFile)); if (summaryFiles != null) { for (File file : summaryFiles) { reports.addAll(readReportsFromFile(file)); } } } catch (final Exception e) { throw new MojoFailureException("Failed to read check report summary file.", e); } return reports; }    }
@Test(expected = MojoFailureException.class) public void testCollectReports_throws() throws Exception { final File testOutDir = new File(testOutBaseDir, "testCollectReports_throws"); FileUtils.deleteDirectory(testOutDir); testOutDir.mkdirs(); VerifyMojo mojo = new VerifyMojo(); final File summaryFile = new File(testOutDir, "summaryDir"); summaryFile.mkdirs(); mojo.summaryFile = summaryFile; mojo.collectReports(); }
@Test(expected = MojoFailureException.class) public void testCollectReports_addThrows() throws Exception { final File testOutDir = new File(testOutBaseDir, "testCollectReports_addThrows"); FileUtils.deleteDirectory(testOutDir); testOutDir.mkdirs(); VerifyMojo mojo = new VerifyMojo(); final File summaryFile = new File(testOutDir, "summary.json"); final File addSummaryFile = new File(testOutDir, "summary2.json"); addSummaryFile.mkdirs(); mojo.summaryFile = summaryFile; mojo.summaryFiles.add(addSummaryFile); mojo.collectReports(); }