use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_fail_when_some_inherited_field_values_differ.
@Test
public void should_fail_when_some_inherited_field_values_differ() {
AssertionInfo info = someInfo();
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Luke", "Green");
try {
objects.assertIsEqualToComparingOnlyGivenFields(info, actual, other, noFieldComparators(), defaultTypeComparators(), "name", "lightSaberColor");
} catch (AssertionError err) {
List<Object> expected = newArrayList((Object) "Luke");
List<Object> rejected = newArrayList((Object) "Yoda");
verify(failures).failure(info, shouldBeEqualComparingOnlyGivenFields(actual, newArrayList("name"), rejected, expected, newArrayList("name", "lightSaberColor")));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
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_is_not_accessible_and_private_field_use_is_forbidden.
@Test
public void should_fail_when_selected_field_is_not_accessible_and_private_field_use_is_forbidden() {
boolean allowedToUsePrivateFields = FieldSupport.comparison().isAllowedToUsePrivateFields();
Assertions.setAllowComparingPrivateFields(false);
thrown.expectIntrospectionErrorWithMessageContaining("Can't find any field or property with name 'strangeNotReadablePrivateField'.");
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Yoda", "Blue");
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "strangeNotReadablePrivateField");
Assertions.setAllowComparingPrivateFields(allowedToUsePrivateFields);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_pass_when_selected_field_is_private_and_private_field_use_is_allowed.
@Test
public void should_pass_when_selected_field_is_private_and_private_field_use_is_allowed() {
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Yoda", "Blue");
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "strangeNotReadablePrivateField");
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_pass_when_selected_fields_are_equal.
@Test
public void should_pass_when_selected_fields_are_equal() {
Jedi actual = new Jedi("Yoda", "Green");
Jedi other = new Jedi("Yoda", "Green");
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "name", "lightSaberColor");
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_fail_when_one_of_actual_field_to_compare_can_not_be_found_in_the_other_object.
@Test
public void should_fail_when_one_of_actual_field_to_compare_can_not_be_found_in_the_other_object() {
thrown.expectIntrospectionErrorWithMessageContaining("Can't find any field or property with name 'lightSaberColor'");
Jedi actual = new Jedi("Yoda", "Green");
Employee other = new Employee();
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "lightSaberColor");
}
Aggregations