### Question:
GenerateWhile extends LoopGenerator<E> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof GenerateWhile<?>)) { return false; } GenerateWhile<?> other = (GenerateWhile<?>) obj; return other.getWrappedGenerator().equals(getWrappedGenerator()) && other.test.equals(test); } GenerateWhile(Generator<? extends E> wrapped, Predicate<? super E> test); void run(final Procedure<? super E> proc); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void testEquals() { Generator<Integer> anotherGenerate = new GenerateWhile<Integer>( IteratorToGeneratorAdapter.adapt(new IntegerRange(1, 10)), isLessThanFive); assertEquals(generateWhile, generateWhile); assertEquals(generateWhile, anotherGenerate); assertTrue(!generateWhile.equals((GenerateWhile<Integer>)null)); Generator<Integer> aGenerateWithADifferentPredicate = new GenerateWhile<Integer>( IteratorToGeneratorAdapter.adapt(new IntegerRange(1, 10)), new Predicate<Integer>() { public boolean test(Integer obj) { return obj < FIVE; } }); assertTrue(!generateWhile.equals(aGenerateWithADifferentPredicate)); Generator<Integer> aGenerateWithADifferentWrapped = new GenerateWhile<Integer>( IteratorToGeneratorAdapter.adapt(new IntegerRange(1,11)), isLessThanFive); assertTrue(!generateWhile.equals(aGenerateWithADifferentWrapped)); }