Search in sources :

Example 76 with TextDescription

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]>."));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) Test(org.junit.Test)

Example 77 with TextDescription

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>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Date(java.util.Date) Test(org.junit.Test)

Example 78 with TextDescription

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\""));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 79 with TextDescription

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."));
}
Also used : PredicateDescription(org.assertj.core.presentation.PredicateDescription) TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 80 with TextDescription

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."));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Aggregations

TextDescription (org.assertj.core.description.TextDescription)210 Test (org.junit.Test)210 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)157 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)24 PredicateDescription (org.assertj.core.presentation.PredicateDescription)8 Jedi (org.assertj.core.test.Jedi)6 Path (java.nio.file.Path)4 Integer.toHexString (java.lang.Integer.toHexString)3 Date (java.util.Date)3 Description (org.assertj.core.description.Description)3 Difference (org.assertj.core.internal.DeepDifference.Difference)3 BaseTest (org.assertj.core.api.BaseTest)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 LongPredicate (java.util.function.LongPredicate)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 LongStream (java.util.stream.LongStream)1