use of java.util.function.LongPredicate in project assertj-core by joel-costigliola.
the class LongPredicateAssert_accepts_Test method should_fail_when_predicate_does_not_accept_values.
@Test
public void should_fail_when_predicate_does_not_accept_values() {
LongPredicate predicate = val -> val <= 2;
long[] matchValues = new long[] { 1L, 2L, 3L };
thrown.expectAssertionError(elementsShouldMatch(matchValues, 3L, PredicateDescription.GIVEN).create());
assertThat(predicate).accepts(matchValues);
}
use of java.util.function.LongPredicate in project assertj-core by joel-costigliola.
the class LongPredicateAssert_rejects_Test method should_fail_when_predicate_accepts_value.
@Test
public void should_fail_when_predicate_accepts_value() {
LongPredicate predicate = val -> val <= 2;
Predicate<Long> wrapPredicate = predicate::test;
long expectedValue = 2;
thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
assertThat(predicate).rejects(expectedValue);
}
use of java.util.function.LongPredicate in project assertj-core by joel-costigliola.
the class LongPredicateAssert_rejects_Test method should_fail_when_predicate_accepts_some_value.
@Test
public void should_fail_when_predicate_accepts_some_value() {
LongPredicate predicate = num -> num <= 2;
long[] matchValues = new long[] { 1L, 2L, 3L };
List<Long> matchValuesList = LongStream.of(matchValues).boxed().collect(Collectors.toList());
thrown.expectAssertionError(noElementsShouldMatch(matchValuesList, 1L, PredicateDescription.GIVEN).create());
assertThat(predicate).rejects(matchValues);
}
use of java.util.function.LongPredicate in project assertj-core by joel-costigliola.
the class LongPredicateAssert_rejects_Test method should_fail_when_predicate_accepts_value_with_description.
@Test
public void should_fail_when_predicate_accepts_value_with_description() {
LongPredicate predicate = val -> val <= 2;
Predicate<Long> wrapPredicate = predicate::test;
long expectedValue = 2;
thrown.expectAssertionError("[test] " + shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
assertThat(predicate).as(new TextDescription("test")).rejects(expectedValue);
}
use of java.util.function.LongPredicate in project assertj-core by joel-costigliola.
the class LongPredicateAssert_rejects_Test method should_pass_when_predicate_accepts_no_value.
@Test
public void should_pass_when_predicate_accepts_no_value() {
LongPredicate predicate = num -> num <= 2;
assertThat(predicate).rejects(3L, 4L, 5L);
}
Aggregations