@Test public void testReject() { Assert.assertEquals( ArrayStack.newStackFromTopToBottom("2", "3"), this.unmodifiableStackString.reject(StringPredicates.contains("1"))); Assert.assertEquals( FastList.newListWith("2", "3"), this.unmodifiableStackString.reject( StringPredicates.contains("1"), FastList.<String>newList())); }
@Test public void delegatingMethods() { Assert.assertEquals(this.mutableCollection.notEmpty(), this.unmodifiableCollection.notEmpty()); Assert.assertEquals(this.mutableCollection.isEmpty(), this.unmodifiableCollection.isEmpty()); Assert.assertEquals(this.mutableCollection.size(), this.unmodifiableCollection.size()); Assert.assertEquals(this.mutableCollection.getFirst(), this.unmodifiableCollection.getFirst()); Assert.assertEquals(this.mutableCollection.getLast(), this.unmodifiableCollection.getLast()); Assert.assertEquals( this.mutableCollection.count(Predicates.alwaysTrue()), this.unmodifiableCollection.count(Predicates.alwaysTrue())); Verify.assertSize(4, this.unmodifiableCollection.select(Predicates.alwaysTrue())); Verify.assertSize( 4, this.unmodifiableCollection.select(Predicates.alwaysTrue(), FastList.<String>newList())); Verify.assertSize(1, this.unmodifiableCollection.selectWith(Predicates2.equal(), METALLICA)); Verify.assertSize( 1, this.unmodifiableCollection.selectWith( Predicates2.equal(), METALLICA, FastList.<String>newList())); Verify.assertSize(2, this.unmodifiableCollection.reject(StringPredicates.contains("p"))); Verify.assertSize( 2, this.unmodifiableCollection.reject( StringPredicates.contains("p"), FastList.<String>newList())); Verify.assertSize(3, this.unmodifiableCollection.rejectWith(Predicates2.equal(), METALLICA)); Verify.assertSize( 3, this.unmodifiableCollection.rejectWith( Predicates2.equal(), METALLICA, FastList.<String>newList())); Verify.assertSize(4, this.unmodifiableCollection.collect(Functions.getStringPassThru())); Verify.assertSize( 4, this.unmodifiableCollection.collect( Functions.getStringPassThru(), FastList.<String>newList())); Function<String, Collection<String>> flattenFunction = new Function<String, Collection<String>>() { public Collection<String> valueOf(String object) { return FastList.newListWith(object, object); } }; Verify.assertSize(8, this.unmodifiableCollection.flatCollect(flattenFunction)); Verify.assertSize( 8, this.unmodifiableCollection.flatCollect(flattenFunction, FastList.<String>newList())); Verify.assertSize( 4, this.unmodifiableCollection.collectIf( Predicates.alwaysTrue(), Functions.getStringPassThru())); Verify.assertSize( 4, this.unmodifiableCollection.collectIf( Predicates.alwaysTrue(), Functions.getStringPassThru(), FastList.<String>newList())); Assert.assertEquals( METALLICA, this.unmodifiableCollection.detect(StringPredicates.contains("allic"))); Assert.assertEquals( "Not found", this.unmodifiableCollection.detectIfNone( StringPredicates.contains("donna"), new PassThruFunction0<String>("Not found"))); Assert.assertEquals( METALLICA, this.unmodifiableCollection.detectWith(Predicates2.equal(), METALLICA)); Assert.assertEquals( "Not found", this.unmodifiableCollection.detectWithIfNone( Predicates2.equal(), "Madonna", new PassThruFunction0<String>("Not found"))); Assert.assertEquals(4, this.unmodifiableCollection.count(Predicates.alwaysTrue())); Assert.assertEquals(1, this.unmodifiableCollection.countWith(Predicates2.equal(), METALLICA)); Assert.assertTrue(this.unmodifiableCollection.anySatisfy(StringPredicates.contains("allic"))); Assert.assertTrue(this.unmodifiableCollection.anySatisfyWith(Predicates2.equal(), METALLICA)); Assert.assertTrue(this.unmodifiableCollection.allSatisfy(Predicates.notNull())); Assert.assertTrue(this.unmodifiableCollection.allSatisfyWith(Predicates2.alwaysTrue(), "")); Assert.assertEquals(this.mutableCollection, this.unmodifiableCollection.toList()); Verify.assertListsEqual( Lists.mutable.of("Bon Jovi", "Europe", METALLICA, "Scorpions"), this.unmodifiableCollection.toSortedList()); Verify.assertListsEqual( Lists.mutable.of("Scorpions", METALLICA, "Europe", "Bon Jovi"), this.unmodifiableCollection.toSortedList(Collections.reverseOrder())); Verify.assertSize(4, this.unmodifiableCollection.toSet()); Verify.assertSize( 4, this.unmodifiableCollection.toMap( Functions.getStringPassThru(), Functions.getStringPassThru())); }