Search in sources :

Example 21 with Name

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

the class ObjectArrayAssert_extractingResultOf_Test method should_allow_assertions_on_method_invocation_result_extracted_from_given_iterable.

@Test
public void should_allow_assertions_on_method_invocation_result_extracted_from_given_iterable() {
    // extract method result
    assertThat(jedis).extractingResultOf("age").containsOnly(800, 50);
    // extract if method result is primitive
    assertThat(jedis).extractingResultOf("darkSide").containsOnly(false, true);
    // extract if method result is also a property
    assertThat(jedis).extractingResultOf("name").containsOnly(new Name("Yoda"), new Name("Darth Vader"));
    // extract toString method result
    assertThat(jedis).extractingResultOf("toString").containsOnly("Yoda", "Darth Vader");
}
Also used : Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 22 with Name

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

the class ObjectArrayAssert_extracting_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 = array(yoda, luke);
    fellowshipOfTheRing = new TolkienCharacter[8];
    fellowshipOfTheRing[0] = TolkienCharacter.of("Frodo", 33, HOBBIT);
    fellowshipOfTheRing[1] = TolkienCharacter.of("Sam", 38, HOBBIT);
    fellowshipOfTheRing[2] = TolkienCharacter.of("Gandalf", 2020, MAIA);
    fellowshipOfTheRing[3] = TolkienCharacter.of("Legolas", 1000, ELF);
    fellowshipOfTheRing[4] = TolkienCharacter.of("Pippin", 28, HOBBIT);
    fellowshipOfTheRing[5] = TolkienCharacter.of("Gimli", 139, DWARF);
    fellowshipOfTheRing[6] = TolkienCharacter.of("Aragorn", 87, MAN);
    fellowshipOfTheRing[7] = TolkienCharacter.of("Boromir", 37, MAN);
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Before(org.junit.Before)

Example 23 with Name

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

the class ObjectArrayAssert_extracting_Test method should_allow_assertions_on_field_values_extracted_from_given_iterable.

@Test
public void should_allow_assertions_on_field_values_extracted_from_given_iterable() {
    // basic types
    assertThat(employees).extracting("id").containsOnly(1L, 2L);
    // object
    assertThat(employees).extracting("name").containsOnly(new Name("Yoda"), new Name("Luke", "Skywalker"));
    // nested property
    assertThat(employees).extracting("name.first").containsOnly("Yoda", "Luke");
}
Also used : Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 24 with Name

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

the class AtomicReferenceArrayAssert_filtered_baseTest method setUp.

@Before
public void setUp() {
    yoda = new Employee(1L, new Name("Yoda"), 800);
    obiwan = new Employee(2L, new Name("Obi"), 800);
    luke = new Employee(3L, new Name("Luke", "Skywalker"), 26);
    noname = new Employee(4L, null, 10);
    employees = new AtomicReferenceArray<>(new Employee[] { yoda, luke, obiwan, noname });
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Before(org.junit.Before)

Example 25 with Name

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

the class AtomicReferenceArrayAssert_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 = new AtomicReferenceArray<>(array(yoda, vader));
}
Also used : FluentJedi(org.assertj.core.test.FluentJedi) Name(org.assertj.core.test.Name) BeforeClass(org.junit.BeforeClass)

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