use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class Iterables_assertNoneMatch_Test method should_fail_with_custom_description_if_predicate_is_not_met.
@Test
public void should_fail_with_custom_description_if_predicate_is_not_met() {
List<String> actual = newArrayList("Luke", "Leia", "Yoda");
Predicate<? super String> predicate = s -> s.startsWith("L");
try {
iterables.assertNoneMatch(info, actual, predicate, new PredicateDescription("custom"));
} catch (AssertionError e) {
verify(failures).failure(info, noElementsShouldMatch(actual, "Luke", new PredicateDescription("custom")));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class AnyElementsShouldMatch_create_Test method should_create_error_message.
@Test
public void should_create_error_message() {
// GIVEN
ErrorMessageFactory factory = anyElementShouldMatch(newArrayList("Luke", "Yoda"), new PredicateDescription("Yoda violates some restrictions"));
// WHEN
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
// THEN
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting any elements of:%n" + " <[\"Luke\", \"Yoda\"]>%n" + "to match 'Yoda violates some restrictions' predicate but none did."));
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class ElementsShouldMatch_create_Test method should_create_error_message_with_custom_description.
@Test
public void should_create_error_message_with_custom_description() {
ErrorMessageFactory factory = elementsShouldMatch(newArrayList("Luke", "Yoda"), "Yoda", new PredicateDescription("custom"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting all elements of:%n" + " <[\"Luke\", \"Yoda\"]>%n" + "to match 'custom' predicate but this element did not:%n" + " <\"Yoda\">"));
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class NoElementsShouldMatch_create_Test method should_create_error_message_with_custom_description.
@Test
public void should_create_error_message_with_custom_description() {
ErrorMessageFactory factory = noElementsShouldMatch(newArrayList("Luke", "Yoda"), "Yoda", new PredicateDescription("custom"));
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting no elements of:%n" + " <[\"Luke\", \"Yoda\"]>%n" + "to match 'custom' predicate but this element did:%n" + " <\"Yoda\">"));
}
use of org.assertj.core.presentation.PredicateDescription in project assertj-core by joel-costigliola.
the class Iterables_assertAllMatch_Test method should_fail_with_custom_description_if_predicate_is_not_met.
@Test
public void should_fail_with_custom_description_if_predicate_is_not_met() {
List<String> actual = newArrayList("Luke", "Leia", "Yoda");
Predicate<? super String> predicate = s -> s.startsWith("L");
try {
iterables.assertAllMatch(info, actual, predicate, new PredicateDescription("custom"));
} catch (AssertionError e) {
verify(failures).failure(info, elementsShouldMatch(actual, "Yoda", new PredicateDescription("custom")));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
Aggregations