@Override @Test public void noneSatisfy() { MutableList<Integer> list = this.getIntegerList(); Assert.assertTrue(Predicates.<Integer>noneSatisfy(String.class::isInstance).accept(list)); Assert.assertFalse(Predicates.noneSatisfy(Predicates.greaterThan(0)).accept(list)); }
@Override @Test public void allSatisfy() { MutableList<Integer> list = this.getIntegerList(); Assert.assertTrue(Predicates.<Integer>allSatisfy(Integer.class::isInstance).accept(list)); Assert.assertFalse(Predicates.allSatisfy(Predicates.greaterThan(2)).accept(list)); }
@Test public void reject() { Verify.assertEmpty(SingletonListTest.newWith(1).reject(Predicates.lessThan(3))); Verify.assertContainsAll( SingletonListTest.newWith(1) .reject(Predicates.greaterThan(3), UnifiedSet.<Integer>newSet()), 1); }
@Override @Test default void RichIterable_detect() { assertThat(this.newWith(3, 2, 1).detect(Predicates.greaterThan(0)), isOneOf(3, 2, 1)); assertThat(this.newWith(3, 2, 1).detect(Predicates.greaterThan(1)), isOneOf(3, 2)); assertThat(this.newWith(3, 2, 1).detect(Predicates.greaterThan(2)), is(3)); assertThat(this.newWith(3, 2, 1).detect(Predicates.greaterThan(3)), nullValue()); assertThat(this.newWith(3, 2, 1).detect(Predicates.lessThan(1)), nullValue()); assertThat(this.newWith(3, 2, 1).detect(Predicates.lessThan(2)), is(1)); assertThat(this.newWith(3, 2, 1).detect(Predicates.lessThan(3)), isOneOf(2, 1)); assertThat(this.newWith(3, 2, 1).detect(Predicates.lessThan(4)), isOneOf(3, 2, 1)); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.greaterThan(), 0), isOneOf(3, 2, 1)); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.greaterThan(), 1), isOneOf(3, 2)); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.greaterThan(), 2), is(3)); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.greaterThan(), 3), nullValue()); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.lessThan(), 1), nullValue()); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.lessThan(), 2), is(1)); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.lessThan(), 3), isOneOf(2, 1)); assertThat(this.newWith(3, 2, 1).detectWith(Predicates2.lessThan(), 4), isOneOf(3, 2, 1)); assertThat( this.newWith(3, 2, 1).detectIfNone(Predicates.greaterThan(0), () -> 4), isOneOf(3, 2, 1)); assertThat( this.newWith(3, 2, 1).detectIfNone(Predicates.greaterThan(1), () -> 4), isOneOf(3, 2)); assertThat(this.newWith(3, 2, 1).detectIfNone(Predicates.greaterThan(2), () -> 4), is(3)); assertThat(this.newWith(3, 2, 1).detectIfNone(Predicates.greaterThan(3), () -> 4), is(4)); assertThat(this.newWith(3, 2, 1).detectIfNone(Predicates.lessThan(1), () -> 4), is(4)); assertThat(this.newWith(3, 2, 1).detectIfNone(Predicates.lessThan(2), () -> 4), is(1)); assertThat(this.newWith(3, 2, 1).detectIfNone(Predicates.lessThan(3), () -> 4), isOneOf(2, 1)); assertThat( this.newWith(3, 2, 1).detectIfNone(Predicates.lessThan(4), () -> 4), isOneOf(3, 2, 1)); assertThat( this.newWith(3, 2, 1).detectWithIfNone(Predicates2.greaterThan(), 0, () -> 4), isOneOf(3, 2, 1)); assertThat( this.newWith(3, 2, 1).detectWithIfNone(Predicates2.greaterThan(), 1, () -> 4), isOneOf(3, 2)); assertThat( this.newWith(3, 2, 1).detectWithIfNone(Predicates2.greaterThan(), 2, () -> 4), is(3)); assertThat( this.newWith(3, 2, 1).detectWithIfNone(Predicates2.greaterThan(), 3, () -> 4), is(4)); assertThat(this.newWith(3, 2, 1).detectWithIfNone(Predicates2.lessThan(), 1, () -> 4), is(4)); assertThat(this.newWith(3, 2, 1).detectWithIfNone(Predicates2.lessThan(), 2, () -> 4), is(1)); assertThat( this.newWith(3, 2, 1).detectWithIfNone(Predicates2.lessThan(), 3, () -> 4), isOneOf(2, 1)); assertThat( this.newWith(3, 2, 1).detectWithIfNone(Predicates2.lessThan(), 4, () -> 4), isOneOf(3, 2, 1)); }
@Test public void select() { Verify.assertContainsAll(SingletonListTest.newWith(1).select(Predicates.lessThan(3)), 1); Verify.assertEmpty(SingletonListTest.newWith(1).select(Predicates.greaterThan(3))); }