@Test public void collect_target() { ImmutableBag<String> strings = this.newBag(); HashBag<String> target = HashBag.<String>newBag(); HashBag<String> actual = strings.collect(Functions.getStringPassThru(), target); Assert.assertEquals(strings, actual); Assert.assertSame(target, actual); Assert.assertEquals( strings, strings.collect(Functions.getStringPassThru(), FastList.<String>newList()).toBag()); }
@Test public void selectByOccurrences() { ImmutableBag<String> strings = this.newBag().selectByOccurrences(IntPredicates.isEven()); ImmutableBag<Integer> collect = strings.collect(Integer::valueOf); Verify.assertAllSatisfy(collect, IntegerPredicates.isEven()); }