### Question:
CompositeBuilder extends ArrayList<SpecimenBuilder> implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { for (SpecimenBuilder builder : this) { Object result = builder.create(request, context); if (isSpecimen(result)) { return result; } } return new NoSpecimen(); } CompositeBuilder(SpecimenBuilder... builders);  CompositeBuilder(Iterable<SpecimenBuilder> builders); @Override Object create(Object request, SpecimenContext context);  }### Answer:
@Test public void first_builder_returns_result_is_the_return_value() { Object builderAResult = new Object(); when(mockBuilderA.create(request, mockContext)).thenReturn(builderAResult); Object result = compositeBuilder.create(request, mockContext); assertSame(builderAResult, result); }
@Test public void first_builder_returns_result_does_not_call_create_on_other_builders() { Object builderAResult = new Object(); when(mockBuilderA.create(request, mockContext)).thenReturn(builderAResult); compositeBuilder.create(request, mockContext); verify(mockBuilderB, never()).create(request, mockContext); }
@Test public void first_builder_returns_no_specimen_returns_result_of_next_builder_with_valid_result() { Object builderBResult = new Object(); when(mockBuilderA.create(request, mockContext)).thenReturn(new NoSpecimen()); when(mockBuilderB.create(request, mockContext)).thenReturn(builderBResult); Object result = compositeBuilder.create(request, mockContext); assertSame(builderBResult, result); }
@Test public void no_builders_can_satisfy_request_returns_no_specimen() { when(mockBuilderA.create(request, mockContext)).thenReturn(new NoSpecimen()); when(mockBuilderB.create(request, mockContext)).thenReturn(new NoSpecimen()); Object result = compositeBuilder.create(request, mockContext); assertEquals(new NoSpecimen(), result); }