### Question:
CompositeValidator implements Validator { @Override public void validate(InputStream contents, Collection<Issue> issues) { ByteArrayInputOutputStream reusableStream = new ByteArrayInputOutputStream(); try { IO.copy(contents, reusableStream); } catch (IOException e) { addExceptionIssue(e, issues); } for (Validator validator : validators) { try (InputStream stream = reusableStream.getInputStream()) { validator.validate(stream, issues); } catch (IOException e) { addExceptionIssue(e, issues); } } } CompositeValidator(Validator... validators); @Override void validate(InputStream contents, Collection<Issue> issues); @Override String toString();  }### Answer:
@Test public void callsAllComponents() throws IOException { Validator v1 = mock(Validator.class); Validator v2 = mock(Validator.class); Validator composite = new CompositeValidator(v1, v2); Collection<Issue> issues = new ArrayList<>(); AtomicReference<byte[]> bytes1 = captureValidatedBytes(v1, issues); AtomicReference<byte[]> bytes2 = captureValidatedBytes(v2, issues); String contents = RANDOM.string(); try (InputStream stream = new StringStream(contents)) { composite.validate(stream, issues); } assertArrayEquals("Bytes supplied to child 1", contents.getBytes("UTF8"), bytes1.get()); assertArrayEquals("Bytes supplied to child 2", bytes1.get(), bytes2.get()); }