@Test public void noneSatisfy() { Assert.assertFalse(this.map.noneSatisfy(BooleanPredicates.isTrue())); Assert.assertFalse(this.map.noneSatisfy(BooleanPredicates.isFalse())); Assert.assertTrue( this.map.noneSatisfy( BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); Assert.assertFalse( this.map.noneSatisfy( BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); }
@Test public void count() { Assert.assertEquals(2L, this.map.count(BooleanPredicates.isTrue())); Assert.assertEquals(1L, this.map.count(BooleanPredicates.isFalse())); Assert.assertEquals( 3L, this.map.count( BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); Assert.assertEquals( 0L, this.map.count( BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse()))); }
@Test public void reject() { Assert.assertEquals( BooleanHashBag.newBagWith(false), this.map.reject(BooleanPredicates.isTrue()).toBag()); Assert.assertEquals( BooleanHashBag.newBagWith(true, true), this.map.reject(BooleanPredicates.isFalse()).toBag()); Assert.assertEquals( new BooleanHashBag(), this.map .reject(BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())) .toBag()); Assert.assertEquals( BooleanHashBag.newBagWith(true, true, false), this.map .reject(BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())) .toBag()); Assert.assertEquals( this.newWithKeysValues("1", true, "2", false), this.map.reject( new ObjectBooleanPredicate<String>() { public boolean accept(String object, boolean value) { return (Integer.parseInt(object) & 1) == 0 && value; } })); Assert.assertEquals( this.newWithKeysValues("0", true, "1", true), this.map.reject( new ObjectBooleanPredicate<String>() { public boolean accept(String object, boolean value) { return (Integer.parseInt(object) & 1) == 0 && !value; } })); Assert.assertEquals( this.newWithKeysValues("0", true, "1", true, "2", false), this.map.reject( new ObjectBooleanPredicate<String>() { public boolean accept(String object, boolean value) { return (Integer.parseInt(object) & 1) != 0 && !value; } })); }