Search in sources :

Example 1 with TestClassWithRandomId

use of org.assertj.core.test.TestClassWithRandomId in project assertj-core by joel-costigliola.

the class Objects_assertIsEqualToIgnoringNullFields_Test method should_pass_when_private_fields_differ_but_are_not_compared.

@Test
public void should_pass_when_private_fields_differ_but_are_not_compared() {
    boolean allowedToUsePrivateFields = FieldSupport.comparison().isAllowedToUsePrivateFields();
    Assertions.setAllowComparingPrivateFields(false);
    TestClassWithRandomId actual = new TestClassWithRandomId("1", 1);
    TestClassWithRandomId other = new TestClassWithRandomId(null, 1);
    // s field is ignored because null in other, and id also because it is private without public getter
    objects.assertIsEqualToIgnoringNullFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators());
    // reset
    Assertions.setAllowComparingPrivateFields(allowedToUsePrivateFields);
}
Also used : TestClassWithRandomId(org.assertj.core.test.TestClassWithRandomId) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 2 with TestClassWithRandomId

use of org.assertj.core.test.TestClassWithRandomId in project assertj-core by joel-costigliola.

the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_pass_when_private_fields_differ_but_are_not_compared_or_are_ignored.

@Test
public void should_pass_when_private_fields_differ_but_are_not_compared_or_are_ignored() {
    boolean allowedToUsePrivateFields = FieldSupport.comparison().isAllowedToUsePrivateFields();
    Assertions.setAllowComparingPrivateFields(false);
    TestClassWithRandomId actual = new TestClassWithRandomId("1", 1);
    TestClassWithRandomId other = new TestClassWithRandomId("1", 2);
    // 
    objects.assertIsEqualToIgnoringGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "n");
    // reset
    Assertions.setAllowComparingPrivateFields(allowedToUsePrivateFields);
}
Also used : TestClassWithRandomId(org.assertj.core.test.TestClassWithRandomId) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Aggregations

ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)2 TestClassWithRandomId (org.assertj.core.test.TestClassWithRandomId)2 Test (org.junit.Test)2