Search in sources :

Example 1 with Person

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

the class MethodSupport_methodResultFor_Test method setUp.

@Before
public void setUp() {
    bruceWayne = new Person("Bruce Wayne");
    joker = new Person("Joker");
    batman = new SuperHero("Batman", bruceWayne, joker);
}
Also used : SuperHero(org.assertj.core.util.introspection.beans.SuperHero) Person(org.assertj.core.test.Person) Before(org.junit.Before)

Example 2 with Person

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

the class PropertySupport_publicGetterExistsFor_Test method setUp.

@Before
public void setUp() {
    bruceWayne = new Person("Bruce Wayne");
    joker = new Person("Joker");
    batman = new SuperHero("Batman", bruceWayne, joker);
}
Also used : SuperHero(org.assertj.core.util.introspection.beans.SuperHero) Person(org.assertj.core.test.Person) Before(org.junit.Before)

Example 3 with Person

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

the class ObjectAssert_isEqualsToComparingFields_Test method should_be_able_to_use_a_type_comparator_for_any_of_the_type_subclasses.

@Test
public void should_be_able_to_use_a_type_comparator_for_any_of_the_type_subclasses() {
    JediMaster yoda1 = new JediMaster("Yoda", new Jedi("luke", "Green"));
    JediMaster yoda2 = new JediMaster("Yoda", new Jedi("LUKE", null));
    // Jedi is a subclass of Person
    assertThat(yoda1).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).isEqualToComparingFieldByField(yoda2);
    assertThat(yoda2).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).isEqualToComparingFieldByField(yoda1);
}
Also used : Jedi(org.assertj.core.test.Jedi) PersonCaseInsensitiveNameComparator(org.assertj.core.test.PersonCaseInsensitiveNameComparator) Person(org.assertj.core.test.Person) Test(org.junit.Test) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest)

Example 4 with Person

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

the class Comparables_assertNotEqualByComparison_Test method should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is.

// ------------------------------------------------------------------------------------------------------------------
// tests using a custom comparison strategy
// ------------------------------------------------------------------------------------------------------------------
@Test
public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() {
    thrown.expectAssertionError(actualIsNull());
    comparablesWithCustomComparisonStrategy.assertNotEqualByComparison(someInfo(), null, new Person("Yoda"));
}
Also used : Person(org.assertj.core.test.Person) Test(org.junit.Test) ComparablesBaseTest(org.assertj.core.internal.ComparablesBaseTest)

Example 5 with Person

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

the class Comparables_assertNotEqualByComparison_Test method should_fail_if_objects_are_equal_whatever_custom_comparison_strategy_is.

@Test
public void should_fail_if_objects_are_equal_whatever_custom_comparison_strategy_is() {
    AssertionInfo info = someInfo();
    try {
        comparablesWithCustomComparisonStrategy.assertNotEqualByComparison(info, new Person("Yoda"), new Person("Yoda"));
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldNotBeEqual(new Person("Yoda"), new Person("Yoda")));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) 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