use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class Iterables_assertAnyMatch_Test method should_fail_with_custom_description_if_predicate_is_met_by_no_element.
@Test
public void should_fail_with_custom_description_if_predicate_is_met_by_no_element() {
List<String> actual = newArrayList("Luke", "Leia", "Yoda");
Predicate<String> startsWithM = s -> s.startsWith("M");
try {
iterables.assertAnyMatch(info, actual, startsWithM, new PredicateDescription("custom"));
} catch (AssertionError e) {
verify(failures).failure(info, anyElementShouldMatch(actual, new PredicateDescription("custom")));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class ShouldNotMatch_create_Test method should_create_error_message_with_predicate_description.
@Test
public void should_create_error_message_with_predicate_description() {
ErrorMessageFactory factory = shouldNotMatch("Yoda", (String color) -> color.equals("green"), new PredicateDescription("green light saber"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n <\"Yoda\">%nnot to match 'green light saber' predicate."));
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class ShouldMatch_create_Test method should_create_error_message_with_predicate_description.
@Test
public void should_create_error_message_with_predicate_description() {
ErrorMessageFactory factory = shouldMatch("Yoda", (String color) -> color.equals("green"), new PredicateDescription("green light saber"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n <\"Yoda\">%nto match 'green light saber' predicate."));
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class ShouldAccept_create_Test method should_create_error_message_with_predicate_description.
@Test
public void should_create_error_message_with_predicate_description() {
ErrorMessageFactory factory = shouldAccept((String color) -> color.equals("green"), "Yoda", new PredicateDescription("green light saber"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n <'green light saber' predicate>%nto accept <\"Yoda\"> but it did not."));
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class ShouldNotAccept_create_Test method should_create_error_message_with_predicate_description.
@Test
public void should_create_error_message_with_predicate_description() {
ErrorMessageFactory factory = shouldNotAccept((String color) -> color.equals("red"), "Yoda", new PredicateDescription("red light saber"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n <'red light saber' predicate>%nnot to accept <\"Yoda\"> but it did."));
}
Aggregations