@Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType) request; Class requestClass = specimenType.getRawType(); if (!Set.class.isAssignableFrom(requestClass)) { return new NoSpecimen(); } if (!requestClass.isInterface()) { return new NoSpecimen(); } return new HashSet(); }
@Test public void returns_a_number_in_the_specified_range() { RangeRequest request = new RangeRequest<Long>(SpecimenType.of(Long.class), 200L, 300L); Long result = (Long) this.numericRangeRelay.create(request, this.mockContext); assertTrue(result >= 200 && result < 300); }