use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_fail_when_selected_field_does_not_exist.
@Test
public void should_fail_when_selected_field_does_not_exist() {
thrown.expect(IntrospectionError.class, "%nCan't find any field or property with name 'age'.%n" + "Error when introspecting properties was :%n" + "- No getter for property 'age' in org.assertj.core.test.Jedi %n" + "Error when introspecting fields was :%n" + "- Unable to obtain the value of the field <'age'> from <Yoda the Jedi>");
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Yoda", "Blue");
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "age");
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_fail_when_some_selected_field_values_differ.
@Test
public void should_fail_when_some_selected_field_values_differ() {
AssertionInfo info = someInfo();
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Yoda", "Blue");
try {
objects.assertIsEqualToComparingOnlyGivenFields(info, actual, other, noFieldComparators(), defaultTypeComparators(), "name", "lightSaberColor");
} catch (AssertionError err) {
List<Object> expected = newArrayList((Object) "Blue");
List<Object> rejected = newArrayList((Object) "Green");
verify(failures).failure(info, shouldBeEqualComparingOnlyGivenFields(actual, newArrayList("lightSaberColor"), rejected, expected, newArrayList("name", "lightSaberColor")));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_pass_when_field_values_are_null.
@Test
public void should_pass_when_field_values_are_null() {
Jedi actual = new Jedi("Yoda", null);
Jedi other = new Jedi("Yoda", null);
objects.assertIsEqualToIgnoringGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "name");
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_pass_when_not_ignored_inherited_fields_are_equal.
@Test
public void should_pass_when_not_ignored_inherited_fields_are_equal() {
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Luke", "Green");
objects.assertIsEqualToIgnoringGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "name");
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_be_able_to_use_a_comparator_for_specified_fields.
@Test
public void should_be_able_to_use_a_comparator_for_specified_fields() {
Comparator<String> alwaysEqual = (s1, s2) -> 0;
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Luke", "Green");
assertThat(actual).usingComparatorForFields(alwaysEqual, "name").isEqualToComparingFieldByField(other);
}
Aggregations