Search in sources :

Example 26 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldBeEqualIgnoringGivenFields_create_Test method should_create_error_message_with_single_field_difference.

@Test
public void should_create_error_message_with_single_field_difference() {
    factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("lightSaberColor"), newArrayList((Object) "blue"), newArrayList((Object) "green"), newArrayList("someIgnoredField"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting value <\"green\"> in field <\"lightSaberColor\"> " + "but was <\"blue\"> in <Yoda the Jedi>.%n" + "Comparison was performed on all fields but <[\"someIgnoredField\"]>"));
}
Also used : Jedi(org.assertj.core.test.Jedi) TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 27 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldBeEqualIgnoringGivenFields_create_Test method should_create_error_message_with_all_fields_differences.

@Test
public void should_create_error_message_with_all_fields_differences() {
    factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("name", "lightSaberColor"), newArrayList((Object) "Yoda", "blue"), newArrayList((Object) "Yoda", "green"), newArrayList("someIgnoredField"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(String.format("[Test] %n" + "Expecting values:%n" + "  <[\"Yoda\", \"green\"]>%n" + "in fields:%n" + "  <[\"name\", \"lightSaberColor\"]>%n" + "but were:%n" + "  <[\"Yoda\", \"blue\"]>%n" + "in <Yoda the Jedi>.%n" + "Comparison was performed on all fields but <[\"someIgnoredField\"]>"));
}
Also used : Jedi(org.assertj.core.test.Jedi) TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 28 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldBeEqualIgnoringMinutes_create_Test method should_create_error_message_for_LocalTime.

@Test
public void should_create_error_message_for_LocalTime() {
    factory = shouldBeEqualIgnoringMinutes(LocalTime.of(12, 0), LocalTime.of(12, 1));
    String message = factory.create(new TestDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <12:00>%n" + "to have same hour as:%n" + "  <12:01>%n" + "but had not."));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 29 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldBeEqualIgnoringNanos_create_Test method should_create_error_message_for_LocalTime.

@Test
public void should_create_error_message_for_LocalTime() {
    factory = shouldBeEqualIgnoringNanos(LocalTime.of(12, 0), LocalTime.of(13, 0));
    String message = factory.create(new TestDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <12:00>%n" + "to have same hour, minute and second as:%n" + "  <13:00>%n" + "but had not."));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Example 30 with StandardRepresentation

use of org.assertj.core.presentation.StandardRepresentation in project assertj-core by joel-costigliola.

the class ShouldBeInSameDay_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    ErrorMessageFactory factory = shouldBeInSameDay(parse("2010-01-01"), parse("2010-01-25"));
    String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <2010-01-01T00:00:00.000>%n" + "to be on same year, month and day as:%n" + " <2010-01-25T00:00:00.000>"));
}
Also used : TextDescription(org.assertj.core.description.TextDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Test(org.junit.Test)

Aggregations

StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)241 Test (org.junit.Test)216 TextDescription (org.assertj.core.description.TextDescription)157 TestDescription (org.assertj.core.internal.TestDescription)48 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)22 AssertionInfo (org.assertj.core.api.AssertionInfo)10 Before (org.junit.Before)9 PredicateDescription (org.assertj.core.presentation.PredicateDescription)7 Jedi (org.assertj.core.test.Jedi)6 Path (java.nio.file.Path)5 AssertionFailedError (org.opentest4j.AssertionFailedError)4 Date (java.util.Date)3 BaseTest (org.assertj.core.api.BaseTest)2 Description (org.assertj.core.description.Description)2 BigDecimalsBaseTest (org.assertj.core.internal.BigDecimalsBaseTest)2 BigIntegersBaseTest (org.assertj.core.internal.BigIntegersBaseTest)2 ComparisonFailure (org.junit.ComparisonFailure)2 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1