use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_usingFieldByFieldElementComparator_Test method should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_when_using_field_by_field_element_comparator.
@Test
public void should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_when_using_field_by_field_element_comparator() {
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "blue");
assertThat(array(actual)).usingComparatorForElementFieldsWithType(ALWAY_EQUALS_STRING, String.class).usingFieldByFieldElementComparator().contains(other);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_usingFieldByFieldElementComparator_Test method comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_when_using_field_by_field_element_comparator.
@Test
public void comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_when_using_field_by_field_element_comparator() {
Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "green");
assertThat(array(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingComparatorForElementFieldsWithType(comparator, String.class).usingFieldByFieldElementComparator().contains(other);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ExtendedByTypesComparator_compareTo_Test method should_return_equal_if_objects_are_equal_by_default_comparator.
@Test
public void should_return_equal_if_objects_are_equal_by_default_comparator() {
assertThat(EXTENDED_STANDARD_COMPARATOR.compare(new Jedi("Yoda", "Green"), new Jedi("Yoda", "Green"))).isZero();
assertThat(EXTENDED_FIELD_BY_FIELD_COMPARATOR.compare(new Jedi("Yoda", "Green"), new Jedi("Yoda", "Green"))).isZero();
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ShouldBeEqualByComparingFieldByFieldRecursively_create_Test method should_throw_assertion_error_rather_than_null_pointer_when_one_nested_member_is_null.
@Test
public void should_throw_assertion_error_rather_than_null_pointer_when_one_nested_member_is_null() {
// GIVEN
Jedi yoda = new Jedi("Yoda", "Green");
Jedi noname = new Jedi(null, "Green");
// WHEN
Throwable throwable1 = catchThrowable(() -> assertThat(yoda).isEqualToComparingFieldByFieldRecursively(noname));
Throwable throwable2 = catchThrowable(() -> assertThat(noname).isEqualToComparingFieldByFieldRecursively(yoda));
// THEN
assertThat(throwable1).isInstanceOf(AssertionError.class).isNotInstanceOf(NullPointerException.class);
assertThat(throwable2).isInstanceOf(AssertionError.class).isNotInstanceOf(NullPointerException.class);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ShouldBeEqualComparingOnlyGivenFields_create_Test method should_create_error_message_with_all_fields_differences.
@Test
public void should_create_error_message_with_all_fields_differences() {
factory = shouldBeEqualComparingOnlyGivenFields(new Jedi("Luke", "blue"), newArrayList("name", "lightSaberColor"), newArrayList((Object) "Luke", "blue"), newArrayList((Object) "Yoda", "green"), newArrayList("name", "lightSaberColor"));
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" + " <[\"Luke\", \"blue\"]>%n" + "in <Luke the Jedi>.%n" + "Comparison was performed on fields:%n" + " <[\"name\", \"lightSaberColor\"]>"));
}
Aggregations