### Question:
CandidateProcessor { Statistics validateAndAnalyze(Collection<Candidate> candidates) { log.debug("Will perform {} validations", Integer.valueOf(candidates.size())); Iterable<AnalyzeTask> results = validator.validate(candidates); results.forEach(violationHandler::addViolations); return analyzer.analyze(results); }    }### Answer:
@Test public void test() { CandidateProcessor processor = createProcessor(); Collection<Candidate> candidates = Collections.singletonList(Mockito.mock(Candidate.class)); AnalyzeTask task = Mockito.mock(AnalyzeTask.class); Collection<AnalyzeTask> results = Collections .singletonList(task); when(task.getResult()).thenReturn(Mockito.mock(ValidationResult.class)); when(validator.validate(candidates)).thenReturn(results); when(analyzer.analyze(results)).thenReturn(Mockito.mock(Statistics.class)); processor.validateAndAnalyze(candidates); verify(validator).validate(candidates); verify(analyzer).analyze(results); }