use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldHaveSuppressedException_create_Test method should_create_error_message.
@Test
public void should_create_error_message() {
Throwable actual = new Throwable();
actual.addSuppressed(new IllegalArgumentException("invalid arg"));
actual.addSuppressed(new NullPointerException("null arg"));
ErrorMessageFactory factory = shouldHaveSuppressedException(actual, new IllegalArgumentException("foo"));
String message = factory.create(new TextDescription("Test"), CONFIGURATION_PROVIDER.representation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <java.lang.Throwable>%n" + "to have a suppressed exception with the following type and message:%n" + " <\"java.lang.IllegalArgumentException\"> / <\"foo\">%n" + "but could not find any in actual's suppressed exceptions:%n" + " <[java.lang.IllegalArgumentException: invalid arg,%n" + " java.lang.NullPointerException: null arg]>."));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldHaveTime_create_Test method should_create_error_message.
@Test
public void should_create_error_message() {
Date date = DateUtil.parseDatetime("2011-01-01T05:01:00");
String message = shouldHaveTime(date, 123).create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting%n" + " <2011-01-01T05:01:00.000>%n" + "to have time:%n" + " <123L>%n" + "but was:%n" + " <" + date.getTime() + "L>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldMatchPattern_create_Test method should_create_error_message_escaping_percent.
@Test
public void should_create_error_message_escaping_percent() {
factory = shouldMatch("%%E", "fffff");
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(String.format("[Test] %nExpecting:%n \"%%%%E\"%nto match pattern:%n \"fffff\""));
}
use of org.assertj.core.description.TextDescription 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.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldNotAccept_create_Test method should_create_error_message_with_default_predicate_description.
@Test
public void should_create_error_message_with_default_predicate_description() {
ErrorMessageFactory factory = shouldNotAccept(color -> color.equals("red"), "Yoda", PredicateDescription.GIVEN);
String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
assertThat(message).isEqualTo(format("[Test] %nExpecting:%n <given predicate>%nnot to accept <\"Yoda\"> but it did."));
}
Aggregations