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));
}
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);
}
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);
}
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");
}
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);
}
Aggregations