### Question:
BatchValidator { Iterable<AnalyzeTask> validate(Iterable<Candidate> candidates) { return StreamUtils.stream(candidates, parallel) .map(this::createTask) .map(ValidationTask::validate) .collect(Collectors.toList()); }    }### Answer:
@Test public void test() { BatchValidator batchValidator = new BatchValidator(validator, parallel); Candidate candidate = Mockito.mock(Candidate.class); LatticeMD latticeMD = Mockito.mock(LatticeMD.class); MDSite lhs = Mockito.mock(MDSite.class); Collection<Rhs> rhs = Collections.emptyList(); ValidationResult validationResult = Mockito.mock(ValidationResult.class); when(candidate.getLatticeMd()).thenReturn(latticeMD); when(candidate.getRhs()).thenReturn(rhs); when(latticeMD.getLhs()).thenReturn(lhs); when(validator.validate(lhs, rhs)).thenReturn(validationResult); Iterable<AnalyzeTask> results = batchValidator .validate(Arrays.asList(candidate, candidate)); assertThat(results).hasSize(2); verify(validator, times(2)).validate(lhs, rhs); }