use of org.assertj.core.test.Employee in project assertj-core by joel-costigliola.
the class ByNameMultipleExtractorTest method should_extract_tuples_from_fields_or_properties.
@Test
public void should_extract_tuples_from_fields_or_properties() {
Extractor<Employee, Tuple> extractor = new ByNameMultipleExtractor<>("id", "age");
Tuple extractedValue = extractor.extract(yoda);
assertThat(extractedValue).isEqualTo(tuple(1L, 800));
}
use of org.assertj.core.test.Employee in project assertj-core by joel-costigliola.
the class ByNameMultipleExtractorTest method should_extract_tuples_with_consistent_iteration_order.
@Test
public void should_extract_tuples_with_consistent_iteration_order() {
Extractor<Employee, Tuple> extractor = new ByNameMultipleExtractor<>("id", "name.first", "age");
Tuple extractedValues = extractor.extract(yoda);
assertThat(extractedValues).isEqualTo(tuple(1L, "Yoda", 800));
}
use of org.assertj.core.test.Employee in project assertj-core by joel-costigliola.
the class ByNameSingleExtractorTest 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);
}
use of org.assertj.core.test.Employee in project assertj-core by joel-costigliola.
the class ToStringExtractorTest method should_extract_toString.
@Test
public void should_extract_toString() {
Employee someEmployee = new Employee(1, new Name("John Doe"), 28);
String result = toStringExtractor.extract(someEmployee);
assertThat(result).isEqualTo("Employee[id=1, name=Name[first='John Doe', last='null'], age=28]");
}
use of org.assertj.core.test.Employee in project assertj-core by joel-costigliola.
the class FieldsOrPropertiesExtractor_extract_Test method should_fallback_to_field_if_exception_has_been_thrown_on_property_access.
@Test
public void should_fallback_to_field_if_exception_has_been_thrown_on_property_access() {
List<Employee> employees = Arrays.<Employee>asList(new EmployeeWithBrokenName("Name"));
List<Object> extractedValues = extract(employees, byName("name"));
assertThat(extractedValues).containsOnly(new Name("Name"));
}
Aggregations