### Question:
FactoryMethodRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if(!(request instanceof FactoryMethodRequest)) { return new NoSpecimen(); } FactoryMethodRequest factoryMethodRequest = (FactoryMethodRequest)request; Method method = factoryMethodRequest.getMethod(); List<Object> parameters = ParameterUtils.getMethodParameters(method, factoryMethodRequest.getContainingType(), context); if(parameters == null) { return new NoSpecimen(); } try { Object[] paramsArray = parameters.toArray(new Object[parameters.size()]); return method.invoke(null, paramsArray); } catch (Exception e) { throw new ObjectCreationException(String.format("Unable to invoke factory method %s", method), e); } }  @Override Object create(Object request, SpecimenContext context);  }### Answer:
@Test public void non_factory_method_request_returns_no_specimen() { Object specimen = this.relay.create(String.class, mockSpecimenContext); assertEquals(new NoSpecimen(), specimen); }
@Test(expected = ObjectCreationException.class) public void throws_exception_if_method_parameters_are_invalid() throws NoSuchMethodException { when(mockSpecimenContext.resolve(SpecimenType.of(String.class))).thenReturn(1); when(mockSpecimenContext.resolve(SpecimenType.of(int.class))).thenReturn("string"); this.relay.create(getRequest(), mockSpecimenContext); }
@Test public void method_is_invoked_with_parameters_from_specimen_context() throws NoSuchMethodException { when(mockSpecimenContext.resolve(SpecimenType.of(String.class))).thenReturn("string"); when(mockSpecimenContext.resolve(SpecimenType.of(int.class))).thenReturn(1); Object specimen = this.relay.create(getRequest(), mockSpecimenContext); assertTrue(specimen instanceof TypeWithFactoryMethod); assertEquals("string", ((TypeWithFactoryMethod) specimen).getSymbol()); assertEquals(1, ((TypeWithFactoryMethod) specimen).getSize()); }