### Question:
ConstantGenerator extends AbstractGenerator<T> { @Override public boolean equals(Object other) { return EqualsBuilder.reflectionEquals(this, other); } ConstantGenerator(T value); @Override T next(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void shouldAlwaysReturnTheSuppliedValueForNext() throws Exception { final String expectedValue = "Hello"; final ConstantGenerator<String> generator = new ConstantGenerator<String>(expectedValue); Iterable<String> values = take(toGeneratable(generator), 1000); assertThat(values, hasAllElementsSatisfying(new SelfDescribingPredicate<String>() { @Override public boolean evaluate(String actualValue) { return actualValue.equals(expectedValue); } @Override public String describe() { return "value equal to: " + expectedValue; } })); }
@Test public void shouldBeEqualIfHasTheSameValue() throws Exception { ConstantGenerator<Integer> firstGenerator = new ConstantGenerator<Integer>(1439); ConstantGenerator<Integer> secondGenerator = new ConstantGenerator<Integer>(1439); boolean equal = firstGenerator.equals(secondGenerator); assertThat(equal, is(true)); }
@Test public void shouldNotBeEqualIfHasDifferentValue() throws Exception { ConstantGenerator<Integer> firstGenerator = new ConstantGenerator<Integer>(1439); ConstantGenerator<Integer> secondGenerator = new ConstantGenerator<Integer>(22984); boolean equal = firstGenerator.equals(secondGenerator); assertThat(equal, is(false)); }