@Test public void Element_from_list_request_returns_result_of_picking_strategy() { List<Object> list = new ArrayList<Object>(); list.add(new Object()); ElementFromListRequest request = new ElementFromListRequest(list); Object specimen = new Object(); when(this.mockElementStrategy.get(list)).thenReturn(specimen); Object result = this.relay.create(request, null); assertSame(specimen, result); }
@Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof ElementFromListRequest)) { return new NoSpecimen(); } ElementFromListRequest listRequest = (ElementFromListRequest) request; if (listRequest.getList().isEmpty()) { throw new ObjectCreationException("List of elements was empty"); } return this.strategy.get(listRequest.getList()); }
ElementFromListRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof ElementFromListRequest)) { return new NoSpecimen(); } ElementFromListRequest listRequest = (ElementFromListRequest) request; if (listRequest.getList().isEmpty()) { throw new ObjectCreationException("List of elements was empty"); } return this.strategy.get(listRequest.getList()); } }
ElementFromListRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof ElementFromListRequest)) { return new NoSpecimen(); } ElementFromListRequest listRequest = (ElementFromListRequest) request; if (listRequest.getList().isEmpty()) { throw new ObjectCreationException("List of elements was empty"); } return this.strategy.get(listRequest.getList()); } ElementFromListRelay(ElementFromListStrategy strategy); }
ElementFromListRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof ElementFromListRequest)) { return new NoSpecimen(); } ElementFromListRequest listRequest = (ElementFromListRequest) request; if (listRequest.getList().isEmpty()) { throw new ObjectCreationException("List of elements was empty"); } return this.strategy.get(listRequest.getList()); } ElementFromListRelay(ElementFromListStrategy strategy); @Override Object create(Object request, SpecimenContext context); }
ElementFromListRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof ElementFromListRequest)) { return new NoSpecimen(); } ElementFromListRequest listRequest = (ElementFromListRequest) request; if (listRequest.getList().isEmpty()) { throw new ObjectCreationException("List of elements was empty"); } return this.strategy.get(listRequest.getList()); } ElementFromListRelay(ElementFromListStrategy strategy); @Override Object create(Object request, SpecimenContext context);  }