@Test public void resolving_first_request_as_no_specimen_returns_no_specimen() { when(mockSpecimenContext.resolve(String.class)).thenReturn(new NoSpecimen()); when(mockSpecimenContext.resolve(int.class)).thenReturn(1); Object result = this.relay.create(new KeyValueRequest(String.class, int.class), mockSpecimenContext); assertEquals(new NoSpecimen(), result); }
@Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof KeyValueRequest)) { return new NoSpecimen(); } KeyValueRequest kvRequest = (KeyValueRequest)request; Object keyResult = context.resolve(kvRequest.getKeyType()); if(keyResult instanceof NoSpecimen) return new NoSpecimen(); Object valueResult = context.resolve(kvRequest.getValueType()); if(valueResult instanceof NoSpecimen) return new NoSpecimen(); return new KeyValuePair(keyResult, valueResult); }
KeyValuePairRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof KeyValueRequest)) { return new NoSpecimen(); } KeyValueRequest kvRequest = (KeyValueRequest)request; Object keyResult = context.resolve(kvRequest.getKeyType()); if(keyResult instanceof NoSpecimen) return new NoSpecimen(); Object valueResult = context.resolve(kvRequest.getValueType()); if(valueResult instanceof NoSpecimen) return new NoSpecimen(); return new KeyValuePair(keyResult, valueResult); } }
KeyValuePairRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof KeyValueRequest)) { return new NoSpecimen(); } KeyValueRequest kvRequest = (KeyValueRequest)request; Object keyResult = context.resolve(kvRequest.getKeyType()); if(keyResult instanceof NoSpecimen) return new NoSpecimen(); Object valueResult = context.resolve(kvRequest.getValueType()); if(valueResult instanceof NoSpecimen) return new NoSpecimen(); return new KeyValuePair(keyResult, valueResult); }  }
KeyValuePairRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof KeyValueRequest)) { return new NoSpecimen(); } KeyValueRequest kvRequest = (KeyValueRequest)request; Object keyResult = context.resolve(kvRequest.getKeyType()); if(keyResult instanceof NoSpecimen) return new NoSpecimen(); Object valueResult = context.resolve(kvRequest.getValueType()); if(valueResult instanceof NoSpecimen) return new NoSpecimen(); return new KeyValuePair(keyResult, valueResult); }  @Override Object create(Object request, SpecimenContext context); }
KeyValuePairRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof KeyValueRequest)) { return new NoSpecimen(); } KeyValueRequest kvRequest = (KeyValueRequest)request; Object keyResult = context.resolve(kvRequest.getKeyType()); if(keyResult instanceof NoSpecimen) return new NoSpecimen(); Object valueResult = context.resolve(kvRequest.getValueType()); if(valueResult instanceof NoSpecimen) return new NoSpecimen(); return new KeyValuePair(keyResult, valueResult); }  @Override Object create(Object request, SpecimenContext context);  }