### Question:
RandomPositiveIntegerGenerator implements Generator<Integer> { @Override public Integer next() { return from + random.nextInt(to - from); } RandomPositiveIntegerGenerator(int from, int to);  RandomPositiveIntegerGenerator(); @Override Integer next();  }### Answer:
@Test public void shouldReturnPositiveIntegerBetweenZeroAndIntegerMAX() { Generator<Integer> randomPositiveIntegerGenerator = new RandomPositiveIntegerGenerator(); for (int i = 0; i < 100; i++) { assertThat(randomPositiveIntegerGenerator.next(), greaterThanOrEqualTo(0)); } }
@Test public void shouldReturnPositiveIntegerBetweenFromInclusiveAndToExclusive() { int from = 13; int to = 20; Generator<Integer> randomPositiveIntegerGenerator = new RandomPositiveIntegerGenerator(from, to); Set<Integer> generatedNumbers = newHashSet(); for (int i = 0; i < 100; i++) { Integer integer = randomPositiveIntegerGenerator.next(); assertThat(integer, greaterThanOrEqualTo(from)); assertThat(integer, lessThan(to)); generatedNumbers.add(integer); } assertThat(generatedNumbers, hasSize(greaterThan(5))); }
@Test public void shouldReturnSameNumberEveryTime() { int from = 13; int to = from + 1; Generator<Integer> randomPositiveIntegerGenerator = new RandomPositiveIntegerGenerator(from, to); for (int i = 0; i < 100; i++) { assertThat(randomPositiveIntegerGenerator.next(), is(from)); } }