use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldBeEqualByComparingFieldByFieldRecursively_create_Test method should_precise_missing_fields_when_actual_does_not_declare_all_expected_fields.
@Test
public void should_precise_missing_fields_when_actual_does_not_declare_all_expected_fields() {
// GIVEN
Person person = new Person("John", "Doe");
PersonDAO personDAO = new PersonDAO("John", "Doe", 1L, 23);
// THEN
List<Difference> differences = determineDifferences(person, personDAO, null, null);
// WHEN
// @format:off
String message = shouldBeEqualByComparingFieldByFieldRecursive(person, personDAO, differences, REPRESENTATION).create(new TextDescription("Test"), REPRESENTATION);
// @format:on
// THEN
String personHash = toHexString(person.hashCode());
String personDAOHash = toHexString(personDAO.hashCode());
assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + " <org.assertj.core.error.Person@%s>%n" + "to be equal to:%n" + " <org.assertj.core.error.PersonDAO@%s>%n" + "when recursively comparing field by field, but found the following difference(s):%n" + "%n" + "Path to difference: <>%n" + "- actual : <org.assertj.core.error.Person@%s>%n" + "- expected: <org.assertj.core.error.PersonDAO@%s>%n" + "- reason : org.assertj.core.error.Person can't be compared to org.assertj.core.error.PersonDAO as PersonDAO does not declare all Person fields, it lacks these:[firstName, lastName]", personHash, personDAOHash, personHash, personDAOHash));
}
use of org.assertj.core.description.TextDescription 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\"]>"));
}
use of org.assertj.core.description.TextDescription 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\"]>"));
}
use of org.assertj.core.description.TextDescription 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>"));
}
use of org.assertj.core.description.TextDescription in project assertj-core by joel-costigliola.
the class ShouldBeInSameMonth_create_Test method should_create_error_message.
@Test
public void should_create_error_message() {
ErrorMessageFactory factory = shouldBeInSameMonth(parse("2010-01-01"), parse("2010-02-01"));
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 and month as:%n" + " <2010-02-01T00:00:00.000>"));
}
Aggregations