Search in sources :

Example 6 with Person

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

the class Objects_assertDoesNotHaveNotSameClassAs_Test method should_fail_if_actual_has_same_type_as_other.

@Test
public void should_fail_if_actual_has_same_type_as_other() {
    AssertionInfo info = someInfo();
    try {
        objects.assertDoesNotHaveSameClassAs(info, actual, new Person("Luke"));
        failBecauseExpectedAssertionErrorWasNotThrown();
    } catch (AssertionError err) {
        verify(failures).failure(info, shouldNotHaveSameClass(actual, new Person("Luke")));
    }
}
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 7 with Person

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

the class Objects_assertHasSameClassAs_Test method should_fail_if_actual_is_null.

@Test
public void should_fail_if_actual_is_null() {
    thrown.expectAssertionError(actualIsNull());
    objects.assertHasSameClassAs(someInfo(), null, new Person("Luke"));
}
Also used : Person(org.assertj.core.test.Person) ObjectsBaseTest(org.assertj.core.internal.ObjectsBaseTest) Test(org.junit.Test)

Example 8 with Person

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

the class Objects_assertIsEqualToComparingOnlyGivenFields_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.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "name");
}
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 9 with Person

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

the class Objects_assertNotSame_Test method should_fail_if_objects_are_same.

@Test
public void should_fail_if_objects_are_same() {
    AssertionInfo info = someInfo();
    Object actual = new Person("Yoda");
    try {
        objects.assertNotSame(info, actual, actual);
    } catch (AssertionError e) {
        verify(failures).failure(info, shouldNotBeSame(actual));
        return;
    }
    failBecauseExpectedAssertionErrorWasNotThrown();
}
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 10 with Person

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

the class ObjectAssert_hasNoNullFieldsOrProperties_Test method should_fail_if_a_property_is_null.

@Test
public void should_fail_if_a_property_is_null() {
    Person nobody = new Person(null);
    thrown.expectAssertionError("%n" + "Expecting%n" + "  <Person[name='null']>%n" + "not to have any null property or field, but <\"name\"> was null.%n" + "Check was performed on all fields/properties");
    assertThat(nobody).hasNoNullFieldsOrProperties();
}
Also used : Person(org.assertj.core.test.Person) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

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