Search in sources :

Example 1 with Employee

use of org.assertj.core.test.Employee 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 2 with Employee

use of org.assertj.core.test.Employee 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)

Example 3 with Employee

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

the class FieldSupport_fieldValues_Test method should_return_null_elements_for_null_field_value.

@Test
public void should_return_null_elements_for_null_field_value() {
    List<Employee> list = newArrayList(null, null);
    Iterable<Long> ages = fieldSupport.fieldValues("id", Long.class, list);
    assertThat(ages).containsExactly(null, null);
    luke.setName(null);
    list = newArrayList(yoda, luke, null, null);
    Iterable<Name> names = fieldSupport.fieldValues("name", Name.class, list);
    assertThat(names).containsExactly(new Name("Yoda"), null, null, null);
    Iterable<String> firstNames = fieldSupport.fieldValues("name.first", String.class, list);
    assertThat(firstNames).containsExactly("Yoda", null, null, null);
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 4 with Employee

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

the class PropertyOrFieldSupport_getValueOf_Test method should_extract_nested_property_field_combinations.

@Test
public void should_extract_nested_property_field_combinations() {
    Employee darth = new Employee(1L, new Name("Darth", "Vader"), 100);
    Employee luke = new Employee(2L, new Name("Luke", "Skywalker"), 26);
    darth.field = luke;
    luke.field = darth;
    luke.surname = new Name("Young", "Padawan");
    Object value = propertyOrFieldSupport.getValueOf("me.field.me.field.me.field.surname.name", darth);
    assertThat(value).isEqualTo("Young Padawan");
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 5 with Employee

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

the class PropertyOrFieldSupport_getValueOf_Test method should_extract_single_value_from_maps_by_key.

@Test
public void should_extract_single_value_from_maps_by_key() {
    String key1 = "key1";
    String key2 = "key2";
    Map<String, Employee> map1 = new HashMap<>();
    map1.put(key1, yoda);
    Employee luke = new Employee(2L, new Name("Luke"), 22);
    map1.put(key2, luke);
    Map<String, Employee> map2 = new HashMap<>();
    map2.put(key1, yoda);
    Employee han = new Employee(3L, new Name("Han"), 31);
    map2.put(key2, han);
    List<Map<String, Employee>> maps = asList(map1, map2);
    assertThat(maps).extracting(key2).containsExactly(luke, han);
    assertThat(maps).extracting(key2, Employee.class).containsExactly(luke, han);
    assertThat(maps).extracting(key1).containsExactly(yoda, yoda);
    assertThat(maps).extracting("bad key").containsExactly(null, null);
}
Also used : Employee(org.assertj.core.test.Employee) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Name(org.assertj.core.test.Name) Test(org.junit.Test)

Aggregations

Employee (org.assertj.core.test.Employee)27 Name (org.assertj.core.test.Name)21 Test (org.junit.Test)17 Before (org.junit.Before)9 Extractors.byName (org.assertj.core.extractor.Extractors.byName)6 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)3 Jedi (org.assertj.core.test.Jedi)3 Tuple (org.assertj.core.groups.Tuple)2 BeforeClass (org.junit.BeforeClass)1