@Test public void if_request_is_not_a_specimen_type_it_gets_wrapped_in_one_and_passed_to_the_inner_builder() { Class type = String.class; ArgumentCaptor<Object> requestCaptor = ArgumentCaptor.forClass(Object.class); ArgumentCaptor<SpecimenContext> contextCaptor = ArgumentCaptor.forClass(SpecimenContext.class); injector.create(type, mockContext); verify(mockBuilder).create(requestCaptor.capture(), contextCaptor.capture()); Object request = requestCaptor.getValue(); assertTrue(request instanceof SpecimenType); assertEquals(type, ((SpecimenType) request).getRawType()); }
@Override public Object create(final Object request, SpecimenContext context) { Object actualRequest; if(request instanceof Type) { actualRequest = SpecimenType.of((Type) request); } else { actualRequest = request; } return builder.create(actualRequest, context); }
SpecimenTypeInjector implements SpecimenBuilder { @Override public Object create(final Object request, SpecimenContext context) { Object actualRequest; if(request instanceof Type) { actualRequest = SpecimenType.of((Type) request); } else { actualRequest = request; } return builder.create(actualRequest, context); } }
SpecimenTypeInjector implements SpecimenBuilder { @Override public Object create(final Object request, SpecimenContext context) { Object actualRequest; if(request instanceof Type) { actualRequest = SpecimenType.of((Type) request); } else { actualRequest = request; } return builder.create(actualRequest, context); } SpecimenTypeInjector(SpecimenBuilder builder); }
SpecimenTypeInjector implements SpecimenBuilder { @Override public Object create(final Object request, SpecimenContext context) { Object actualRequest; if(request instanceof Type) { actualRequest = SpecimenType.of((Type) request); } else { actualRequest = request; } return builder.create(actualRequest, context); } SpecimenTypeInjector(SpecimenBuilder builder); @Override Object create(final Object request, SpecimenContext context); }
SpecimenTypeInjector implements SpecimenBuilder { @Override public Object create(final Object request, SpecimenContext context) { Object actualRequest; if(request instanceof Type) { actualRequest = SpecimenType.of((Type) request); } else { actualRequest = request; } return builder.create(actualRequest, context); } SpecimenTypeInjector(SpecimenBuilder builder); @Override Object create(final Object request, SpecimenContext context);  }