@SuppressWarnings("unchecked") @Test public void testSinglePageResultReturnsSame() { FluentIterable<String> initial = FluentIterable.from(ImmutableSet.of("foo", "bar")); Supplier<FluentIterable<String>> nextIterable = createMock(Supplier.class); expect(nextIterable.get()).andReturn(initial); EasyMock.replay(nextIterable); AdvanceUntilEmptyIterable<String> iterable = new AdvanceUntilEmptyIterable<String>(nextIterable); Assert.assertSame(iterable.get(0), initial); EasyMock.verify(nextIterable); }
@SuppressWarnings("unchecked") @Test public void testConcatStopsWhenEmpty() { Supplier<FluentIterable<String>> nextIterable = createMock(Supplier.class); expect(nextIterable.get()).andReturn(FluentIterable.from(ImmutableSet.of("foo", "bar"))); expect(nextIterable.get()).andReturn(FluentIterable.from(ImmutableSet.of("boo", "baz"))); expect(nextIterable.get()).andReturn(FluentIterable.from(ImmutableSet.of("ham", "cheeze"))); expect(nextIterable.get()).andReturn(FluentIterable.from(ImmutableSet.<String>of())); EasyMock.replay(nextIterable); AdvanceUntilEmptyIterable<String> iterable = new AdvanceUntilEmptyIterable<String>(nextIterable); Assert.assertEquals( iterable.concat().toSet(), ImmutableSet.of("foo", "bar", "boo", "baz", "ham", "cheeze")); EasyMock.verify(nextIterable); }