Search in sources :

Example 11 with Person

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

the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_pass_when_fields_are_equal_even_if_objects_types_differ.

@Test
public void should_pass_when_fields_are_equal_even_if_objects_types_differ() {
    CartoonCharacter actual = new CartoonCharacter("Homer Simpson");
    Person other = new Person("Homer Simpson");
    objects.assertIsEqualToIgnoringGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "children");
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 12 with Person

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

the class Objects_assertIsEqualToIgnoringGivenFields_Test method should_pass_when_not_ignored_fields_are_equal_even_if_one_ignored_field_is_not_defined.

@Test
public void should_pass_when_not_ignored_fields_are_equal_even_if_one_ignored_field_is_not_defined() {
    Person actual = new Person("Yoda");
    Jedi other = new Jedi("Yoda", "Green");
    objects.assertIsEqualToIgnoringGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "lightSaberColor");
}
Also used : Jedi(org.assertj.core.test.Jedi) Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 13 with Person

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

the class Objects_assertIsEqualToIgnoringNullFields_Test method should_pass_when_fields_are_equal_even_if_objects_types_differ.

@Test
public void should_pass_when_fields_are_equal_even_if_objects_types_differ() {
    Person actual = new Person("Homer Simpson");
    CartoonCharacter other = new CartoonCharacter("Homer Simpson");
    objects.assertIsEqualToIgnoringNullFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators());
}
Also used : CartoonCharacter(org.assertj.core.test.CartoonCharacter) Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 14 with Person

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

the class Objects_assertSame_Test method should_fail_if_objects_are_not_same.

@Test
public void should_fail_if_objects_are_not_same() {
    AssertionInfo info = someInfo();
    Object a = new Person("Yoda");
    Object e = new Person("Yoda");
    try {
        objects.assertSame(info, a, e);
        failBecauseExpectedAssertionErrorWasNotThrown();
    } catch (AssertionError err) {
    }
    verify(failures).failure(info, shouldBeSame(a, e));
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 15 with Person

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

the class Comparables_assertNotEqualByComparison_Test method should_pass_if_objects_are_not_equal_whatever_custom_comparison_strategy_is.

@Test
public void should_pass_if_objects_are_not_equal_whatever_custom_comparison_strategy_is() {
    Person actual = spy(new Person("YODA"));
    Person other = new Person("Yoda");
    comparablesWithCustomComparisonStrategy.assertNotEqualByComparison(someInfo(), actual, other);
    verify(actual).compareTo(other);
}
Also used : Person(org.assertj.core.test.Person) Test(org.junit.Test) ComparablesBaseTest(org.assertj.core.internal.ComparablesBaseTest)

Aggregations

Person (org.assertj.core.test.Person)16 Test (org.junit.Test)14 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)8 AssertionInfo (org.assertj.core.api.AssertionInfo)4 ComparablesBaseTest (org.assertj.core.internal.ComparablesBaseTest)4 CartoonCharacter (org.assertj.core.test.CartoonCharacter)3 ObjectAssertBaseTest (org.assertj.core.api.ObjectAssertBaseTest)2 Jedi (org.assertj.core.test.Jedi)2 SuperHero (org.assertj.core.util.introspection.beans.SuperHero)2 Before (org.junit.Before)2 PersonCaseInsensitiveNameComparator (org.assertj.core.test.PersonCaseInsensitiveNameComparator)1