public void testToList() { assertEquals(Lists.newArrayList(1, 2, 3, 4), fluent(1, 2, 3, 4).toList()); }
public void testToList_empty() { assertTrue(fluent().toList().isEmpty()); }
public void testCopyInto_SetAllDuplicates() { assertThat(fluent(1, 3, 5).copyInto(Sets.newHashSet(1, 2, 3, 5))).containsExactly(1, 2, 3, 5); }
public void testToSet() { assertThat(fluent(1, 2, 3, 4).toSet()).containsExactly(1, 2, 3, 4).inOrder(); }
public void testToMap() { assertThat(fluent(1, 2, 3).toMap(Functions.toStringFunction()).entrySet()) .containsExactly( Maps.immutableEntry(1, "1"), Maps.immutableEntry(2, "2"), Maps.immutableEntry(3, "3")) .inOrder(); }
public void testToMultiset_empty() { assertThat(fluent().toMultiset()).isEmpty(); }
public void testJoin() { assertEquals("2,1,3,4", fluent(2, 1, 3, 4).join(Joiner.on(","))); }
public void testToSet_empty() { assertTrue(fluent().toSet().isEmpty()); }
public void testToSortedList_withDuplicates() { assertEquals( Lists.newArrayList(4, 3, 1, 1), fluent(1, 4, 1, 3).toSortedList(Ordering.<Integer>natural().reverse())); }
public void testCopyInto_List() { assertThat(fluent(1, 3, 5).copyInto(Lists.newArrayList(1, 2))) .containsExactly(1, 2, 1, 3, 5) .inOrder(); }
public void testCycle_removingAllElementsStopsCycle() { FluentIterable<Integer> cycle = fluent(1, 2).cycle(); Iterator<Integer> iterator = cycle.iterator(); iterator.next(); iterator.remove(); iterator.next(); iterator.remove(); assertFalse(iterator.hasNext()); assertFalse(cycle.iterator().hasNext()); }
public void testToSortedList_withComparator() { assertEquals( Lists.newArrayList(4, 3, 2, 1), fluent(4, 1, 3, 2).toSortedList(Ordering.<Integer>natural().reverse())); }
public void testToSortedSet_removeDuplicates() { assertThat(fluent(1, 4, 1, 3).toSortedSet(Ordering.<Integer>natural().reverse())) .containsExactly(4, 3, 1) .inOrder(); }
public void testToMultiset() { assertThat(fluent(1, 2, 1, 3, 2, 4).toMultiset()).containsExactly(1, 1, 2, 2, 3, 4).inOrder(); }
public void testToSortedSet() { assertThat(fluent(1, 4, 2, 3).toSortedSet(Ordering.<Integer>natural().reverse())) .containsExactly(4, 3, 2, 1) .inOrder(); }
public void testUniqueIndex_nullKey() { try { fluent(1, 2, 3).uniqueIndex(Functions.constant(null)); fail(); } catch (NullPointerException expected) { } }
public void testIndex_nullValue() { try { ImmutableListMultimap<String, Integer> unused = fluent(1, null, 2).index(Functions.constant("foo")); fail(); } catch (NullPointerException expected) { } }
public void testToMap_nullValue() { try { fluent(1, 2, 3).toMap(Functions.constant(null)); fail(); } catch (NullPointerException expected) { } }
public void testIndex_nullKey() { try { ImmutableListMultimap<Object, Integer> unused = fluent(1, 2, 3).index(Functions.constant(null)); fail(); } catch (NullPointerException expected) { } }
public void testToMap_nullKey() { try { fluent(1, null, 2).toMap(Functions.constant("foo")); fail(); } catch (NullPointerException expected) { } }