@Test public void should_create_numbers_in_specified_range() { int min = 10; int max = 100; this.generator = new NumberInRangeGenerator(min, max); for (int i = 0; i < max - min; i++) { Integer value = (Integer) this.generator.create(Integer.class, null); assertTrue(value.toString(), value >= 10); assertTrue(value.toString(), value <= 100); } }
@Override public Object create(Object request, SpecimenContext context) { if (request.equals(Byte.class)) { return (byte) getNextRandom(); } else if (request.equals(Short.class)) { return (short) getNextRandom(); } else if (request.equals(Integer.class)) { return (int) getNextRandom(); } else if (request.equals(Long.class)) { return getNextRandom(); } else if (request.equals(Float.class)) { return (float) getNextRandom(); } else if (request.equals(Double.class)) { return (double) getNextRandom(); } else if (request.equals(BigDecimal.class)) { return BigDecimal.valueOf(getNextRandom()); } else if (request.equals(BigInteger.class)) { return BigInteger.valueOf(getNextRandom()); } return new NoSpecimen(); }
NumberInRangeGenerator implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (request.equals(Byte.class)) { return (byte) getNextRandom(); } else if (request.equals(Short.class)) { return (short) getNextRandom(); } else if (request.equals(Integer.class)) { return (int) getNextRandom(); } else if (request.equals(Long.class)) { return getNextRandom(); } else if (request.equals(Float.class)) { return (float) getNextRandom(); } else if (request.equals(Double.class)) { return (double) getNextRandom(); } else if (request.equals(BigDecimal.class)) { return BigDecimal.valueOf(getNextRandom()); } else if (request.equals(BigInteger.class)) { return BigInteger.valueOf(getNextRandom()); } return new NoSpecimen(); } }
NumberInRangeGenerator implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (request.equals(Byte.class)) { return (byte) getNextRandom(); } else if (request.equals(Short.class)) { return (short) getNextRandom(); } else if (request.equals(Integer.class)) { return (int) getNextRandom(); } else if (request.equals(Long.class)) { return getNextRandom(); } else if (request.equals(Float.class)) { return (float) getNextRandom(); } else if (request.equals(Double.class)) { return (double) getNextRandom(); } else if (request.equals(BigDecimal.class)) { return BigDecimal.valueOf(getNextRandom()); } else if (request.equals(BigInteger.class)) { return BigInteger.valueOf(getNextRandom()); } return new NoSpecimen(); } NumberInRangeGenerator();  NumberInRangeGenerator(long... limits); }
NumberInRangeGenerator implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (request.equals(Byte.class)) { return (byte) getNextRandom(); } else if (request.equals(Short.class)) { return (short) getNextRandom(); } else if (request.equals(Integer.class)) { return (int) getNextRandom(); } else if (request.equals(Long.class)) { return getNextRandom(); } else if (request.equals(Float.class)) { return (float) getNextRandom(); } else if (request.equals(Double.class)) { return (double) getNextRandom(); } else if (request.equals(BigDecimal.class)) { return BigDecimal.valueOf(getNextRandom()); } else if (request.equals(BigInteger.class)) { return BigInteger.valueOf(getNextRandom()); } return new NoSpecimen(); } NumberInRangeGenerator();  NumberInRangeGenerator(long... limits); @Override Object create(Object request, SpecimenContext context); }
NumberInRangeGenerator implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (request.equals(Byte.class)) { return (byte) getNextRandom(); } else if (request.equals(Short.class)) { return (short) getNextRandom(); } else if (request.equals(Integer.class)) { return (int) getNextRandom(); } else if (request.equals(Long.class)) { return getNextRandom(); } else if (request.equals(Float.class)) { return (float) getNextRandom(); } else if (request.equals(Double.class)) { return (double) getNextRandom(); } else if (request.equals(BigDecimal.class)) { return BigDecimal.valueOf(getNextRandom()); } else if (request.equals(BigInteger.class)) { return BigInteger.valueOf(getNextRandom()); } return new NoSpecimen(); } NumberInRangeGenerator();  NumberInRangeGenerator(long... limits); @Override Object create(Object request, SpecimenContext context);  }