Search in sources :

Example 1 with Name

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

the class IterableAssert_extractingResultOf_Test method setUpOnce.

@BeforeClass
public static void setUpOnce() {
    yoda = new FluentJedi(new Name("Yoda"), 800, false);
    vader = new FluentJedi(new Name("Darth Vader"), 50, true);
    jedis = newArrayList(yoda, vader);
}
Also used : FluentJedi(org.assertj.core.test.FluentJedi) Name(org.assertj.core.test.Name) BeforeClass(org.junit.BeforeClass)

Example 2 with Name

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

the class IterableAssert_extracting_Test method setUp.

@Before
public void setUp() {
    yoda = new Employee(1L, new Name("Yoda"), 800);
    luke = new Employee(2L, new Name("Luke", "Skywalker"), 26);
    employees = newArrayList(yoda, luke);
    fellowshipOfTheRing.add(TolkienCharacter.of("Frodo", 33, HOBBIT));
    fellowshipOfTheRing.add(TolkienCharacter.of("Sam", 38, HOBBIT));
    fellowshipOfTheRing.add(TolkienCharacter.of("Gandalf", 2020, MAIA));
    fellowshipOfTheRing.add(TolkienCharacter.of("Legolas", 1000, ELF));
    fellowshipOfTheRing.add(TolkienCharacter.of("Pippin", 28, HOBBIT));
    fellowshipOfTheRing.add(TolkienCharacter.of("Gimli", 139, DWARF));
    fellowshipOfTheRing.add(TolkienCharacter.of("Aragorn", 87, MAN));
    fellowshipOfTheRing.add(TolkienCharacter.of("Boromir", 37, MAN));
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Before(org.junit.Before)

Example 3 with Name

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

the class IterableAssert_extracting_Test method should_allow_assertions_on_null_property_values_extracted_from_given_iterable.

@Test
public void should_allow_assertions_on_null_property_values_extracted_from_given_iterable() {
    yoda.name.setFirst(null);
    assertThat(employees).extracting("name.first").as("not null property but null nested property").containsOnly(null, "Luke");
    yoda.setName(null);
    assertThat(employees).extracting("name.first").as("extract nested property when top property is null").containsOnly(null, "Luke");
    assertThat(employees).extracting("name").as("null property").containsOnly(null, new Name("Luke", "Skywalker"));
}
Also used : Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 4 with Name

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

the class ShouldBeEqualByComparingFieldByFieldRecursively_create_Test method should_not_fall_with_npe_if_field_of_one_of_compared_objects_is_null.

public void should_not_fall_with_npe_if_field_of_one_of_compared_objects_is_null() {
    final Name actualName = new Name("Andy");
    final Name nullName = new Name(null);
    Throwable error = ThrowableAssert.catchThrowable(new ThrowableAssert.ThrowingCallable() {

        @Override
        public void call() throws Throwable {
            assertThat(actualName).isEqualToComparingFieldByFieldRecursively(nullName);
        }
    });
    assertThat(error).isNotExactlyInstanceOf(NullPointerException.class);
}
Also used : ThrowableAssert(org.assertj.core.api.ThrowableAssert) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Name(org.assertj.core.test.Name)

Example 5 with Name

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

the class FieldSupport_fieldValues_Test method setUpOnce.

@Before
public void setUpOnce() {
    yoda = new Employee(1L, new Name("Yoda"), 800);
    luke = new Employee(2L, new Name("Luke", "Skywalker"), 26);
    employees = newArrayList(yoda, luke);
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Before(org.junit.Before)

Aggregations

Name (org.assertj.core.test.Name)46 Test (org.junit.Test)30 Employee (org.assertj.core.test.Employee)21 Before (org.junit.Before)11 Extractors.byName (org.assertj.core.extractor.Extractors.byName)10 BeforeClass (org.junit.BeforeClass)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)3 FluentJedi (org.assertj.core.test.FluentJedi)3 Player (org.assertj.core.test.Player)3 CartoonCharacter (org.assertj.core.test.CartoonCharacter)2 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1 ThrowableAssert (org.assertj.core.api.ThrowableAssert)1