@Test public void field_request_provides_seeded_request_with_name_and_type_to_context() throws NoSuchFieldException { this.fieldBuilder.create(getIntField(), mockSpecimenContext); ArgumentCaptor<SeededRequest> argument = ArgumentCaptor.forClass(SeededRequest.class); verify(mockSpecimenContext).resolve(argument.capture()); SeededRequest request = argument.getValue(); assertEquals("intField", request.getSeed()); assertEquals(request.getRequest(), Integer.class); }
@Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof Field)) { return new NoSpecimen(); } Field field = (Field) request; Type genericType = field.getGenericType(); SpecimenType specimenType = SpecimenType.of(genericType); String fieldName = field.getName(); Object actualRequest = getActualRequest(field, specimenType); return context.resolve(new SeededRequest(fieldName, actualRequest)); }
FieldRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof Field)) { return new NoSpecimen(); } Field field = (Field) request; Type genericType = field.getGenericType(); SpecimenType specimenType = SpecimenType.of(genericType); String fieldName = field.getName(); Object actualRequest = getActualRequest(field, specimenType); return context.resolve(new SeededRequest(fieldName, actualRequest)); } }
FieldRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof Field)) { return new NoSpecimen(); } Field field = (Field) request; Type genericType = field.getGenericType(); SpecimenType specimenType = SpecimenType.of(genericType); String fieldName = field.getName(); Object actualRequest = getActualRequest(field, specimenType); return context.resolve(new SeededRequest(fieldName, actualRequest)); } FieldRelay(RequestEnricher requestEnricher); }
FieldRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof Field)) { return new NoSpecimen(); } Field field = (Field) request; Type genericType = field.getGenericType(); SpecimenType specimenType = SpecimenType.of(genericType); String fieldName = field.getName(); Object actualRequest = getActualRequest(field, specimenType); return context.resolve(new SeededRequest(fieldName, actualRequest)); } FieldRelay(RequestEnricher requestEnricher); @Override Object create(Object request, SpecimenContext context); }
FieldRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof Field)) { return new NoSpecimen(); } Field field = (Field) request; Type genericType = field.getGenericType(); SpecimenType specimenType = SpecimenType.of(genericType); String fieldName = field.getName(); Object actualRequest = getActualRequest(field, specimenType); return context.resolve(new SeededRequest(fieldName, actualRequest)); } FieldRelay(RequestEnricher requestEnricher); @Override Object create(Object request, SpecimenContext context);  }