### Question:
SeededStringBuilder implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if(!(request instanceof SeededRequest)) return new NoSpecimen(); SeededRequest seededRequest = (SeededRequest)request; if(!(seededRequest.getSeed() instanceof String)) return new NoSpecimen(); if(!seededRequest.getRequest().equals(String.class)) return new NoSpecimen(); String seed = (String)seededRequest.getSeed(); Object innerRequest = seededRequest.getRequest(); Object specimen = context.resolve(innerRequest); if(!(specimen instanceof String)) return new NoSpecimen(); return seed + specimen; }  @Override Object create(Object request, SpecimenContext context);  }### Answer:
@Test public void Non_seeded_request_returns_new_no_specimen() { Object result = this.builder.create(new Object(), this.mockSpecimenContext); assertEquals(new NoSpecimen(), result); }
@Test public void Non_string_instance_seed_returns_new_no_specimen() { SeededRequest request = new SeededRequest(1, String.class); Object result = this.builder.create(request, this.mockSpecimenContext); assertEquals(new NoSpecimen(), result); }
@Test public void Non_string_class_inner_request_returns_new_no_specimen() { SeededRequest request = new SeededRequest("seed", int.class); Object result = this.builder.create(request, this.mockSpecimenContext); assertEquals(new NoSpecimen(), result); }
@Test public void Returns_result_of_context_resolve_for_inner_request_prefixed_with_seed() { when(this.mockSpecimenContext.resolve(String.class)).thenReturn("world!"); SeededRequest request = new SeededRequest("hello, ", String.class); Object result = this.builder.create(request, this.mockSpecimenContext); assertEquals("hello, world!", result); }
@Test public void Returns_no_specimen_if_context_result_is_not_a_string() { when(this.mockSpecimenContext.resolve(String.class)).thenReturn(1); SeededRequest request = new SeededRequest("seed", String.class); Object result = this.builder.create(request, this.mockSpecimenContext); assertEquals(new NoSpecimen(), result); }