ResultsProcessor { public static void processResults(List<String> skippedRepos, List<IOException> exceptions, Logger logger) throws IOException { if (!skippedRepos.isEmpty()) { logger.info(REPOS_SKIPPED_MESSAGE, skippedRepos); } if (!exceptions.isEmpty()) { throw new IOException(String.format("There were %s errors with changing Dockerfiles.", exceptions.size())); } }  static void processResults(List<String> skippedRepos, List<IOException> exceptions, Logger logger); static final String REPOS_SKIPPED_MESSAGE; }
@Test(expectedExceptions = IOException.class) public void testProcessResultsHasExceptionsAndThrows() throws IOException { ResultsProcessor.processResults(new ArrayList<>(), Collections.singletonList(new IOException("test")), LoggerFactory.getLogger(ResultsProcessorTest.class)); }
@Test public void testProcessResultsHasSkippedReposAndExceptions() { Logger mockLogger = mock(Logger.class); List<String> skippedRepos = Collections.singletonList("skipped"); try { ResultsProcessor.processResults(skippedRepos, Collections.singletonList(new IOException("test")), mockLogger); fail(); } catch (IOException exception) { verify(mockLogger, times(1)).info(REPOS_SKIPPED_MESSAGE, skippedRepos); } }
@Test public void testProcessResultsHasNothingToReport() throws IOException { Logger mockLogger = mock(Logger.class); ResultsProcessor.processResults(new ArrayList<>(), new ArrayList<>(), mockLogger); verify(mockLogger, times(0)).info(any(), anyList()); }