@Override @Test public void reject() { Verify.assertContainsAll(this.newWith(1, 2, 3, 4).reject(Predicates.lessThan(3)), 3, 4); Verify.assertContainsAll( this.newWith(1, 2, 3, 4).reject(Predicates.lessThan(3), UnifiedSet.newSet()), 3, 4); }
@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 into() { int sum = Interval.oneTo(5) .select(Predicates.lessThan(5)) .into(FastList.<Integer>newList()) .injectInto(0, AddFunction.INTEGER_TO_INT); Assert.assertEquals(10, sum); }
@Override public void noneSatisfy() { Assert.assertTrue(this.classUnderTest().noneSatisfy(Predicates.lessThan(0))); Assert.assertTrue(this.classUnderTest().noneSatisfy(Predicates.greaterThanOrEqualTo(0))); }
@Override public void anySatisfy() { Assert.assertFalse(this.classUnderTest().anySatisfy(Predicates.lessThan(0))); Assert.assertFalse(this.classUnderTest().anySatisfy(Predicates.greaterThanOrEqualTo(0))); }
@Test public void select() { Verify.assertContainsAll(SingletonListTest.newWith(1).select(Predicates.lessThan(3)), 1); Verify.assertEmpty(SingletonListTest.newWith(1).select(Predicates.greaterThan(3))); }