### Question:
CompositeDataHandler implements DataHandler { @Override public Optional<byte[]> handle(final byte[] data) { for (final DataHandler dataHandler : dataHandlers) { final Optional<byte[]> handleResult = dataHandler.handle(data); if (handleResult.isPresent()) { return handleResult; } } return Optional.empty(); } CompositeDataHandler(final Collection<? extends DataHandler> dataHandlers); @Override Optional<byte[]> handle(final byte[] data);  }### Answer:
@Test public void testWithGenericDataHandlers() { final CompositeDataHandler dataHandler = new CompositeDataHandler( ImmutableList.of( data -> Optional.empty(), data -> Optional.of(RESPONSE_DATA_1), data -> Optional.of(RESPONSE_DATA_2), data -> Optional.of(RESPONSE_DATA_3) ) ); final Optional<byte[]> handleResult = dataHandler.handle(REQUEST_DATA); assertThat(handleResult, is(optionalWithValue(equalTo(RESPONSE_DATA_1)))); }
@Test public void testWithOrderedDataHandlers() { final CompositeDataHandler dataHandler = new CompositeDataHandler( ImmutableList.<DataHandler>of( data -> Optional.empty(), data -> Optional.of(RESPONSE_DATA_1), new OrderedDataHandler(-1, data -> Optional.of(RESPONSE_DATA_2)), new OrderedDataHandler(-2, data -> Optional.of(RESPONSE_DATA_3)) ) ); final Optional<byte[]> handleResult = dataHandler.handle(REQUEST_DATA); assertThat(handleResult, is(optionalWithValue(equalTo(RESPONSE_DATA_3)))); }