### Question:
ClassToConstructorRelay implements SpecimenBuilder { @Override public Object create(final Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } if (!this.specification.isSatisfiedBy(request)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType)request; Class rawTypeClass = specimenType.getRawType(); if (rawTypeClass.isInterface() || Modifier.isAbstract(rawTypeClass.getModifiers())) { return new NoSpecimen(); } List<Constructor<?>> constructors = constructorQuery.getConstructorsForClass(rawTypeClass); if (constructors == null || constructors.isEmpty()) { return new NoSpecimen(); } for (Constructor constructor : constructors) { try { GenericConstructorRequest constructorRequest = new GenericConstructorRequest(constructor, specimenType); Object specimen = context.resolve(constructorRequest); if (!(specimen instanceof NoSpecimen)) { return specimen; } } catch (ObjectCreationException e) { } } return new NoSpecimen(); } ClassToConstructorRelay(ConstructorQuery constructorQuery, Specification specification); @Override Object create(final Object request, SpecimenContext context);  }### Answer:
@Test public void if_request_does_not_satisfy_specification_returns_no_specimen() { when(this.mockSpecification.isSatisfiedBy(any(Object.class))).thenReturn(false); Object result = this.relay.create(TwoConstructorType.class, mockSpecimenContext); assertEquals(new NoSpecimen(), result); }
@Test public void if_constructor_query_returns_empty_create_returns_no_specimen() { when(this.mockConstructorQuery.getConstructorsForClass(TwoConstructorType.class)).thenReturn(new ArrayList<Constructor<?>>()); Object result = this.relay.create(TwoConstructorType.class, mockSpecimenContext); assertEquals(new NoSpecimen(), result); }
@Test public void returns_result_of_context_resolve() { Object contextResult = new Object(); when(mockSpecimenContext.resolve(any(Object.class))).thenReturn(contextResult); Object result = this.relay.create(SpecimenType.of(TwoConstructorType.class), mockSpecimenContext); assertSame(contextResult, result); }