Search in sources :

Example 21 with Employee

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

the class ByNameMultipleExtractorTest method should_extract_multiple_values_from_maps_by_keys.

@Test
public void should_extract_multiple_values_from_maps_by_keys() {
    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(key1, key2, "bad key").containsExactly(tuple(yoda, luke, null), tuple(yoda, han, 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)

Example 22 with Employee

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

the class ByNameSingleExtractorTest method should_extract_property_field_combinations.

@Test
public void should_extract_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 extracted = byName("me.field.me.field.me.field.surname.name").extract(darth);
    assertThat(extracted).isEqualTo("Young Padawan");
}
Also used : Employee(org.assertj.core.test.Employee) Extractors.byName(org.assertj.core.extractor.Extractors.byName) Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 23 with Employee

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

the class ByNameSingleExtractorTest method should_throw_exception_if_property_cannot_be_extracted_due_to_runtime_exception_during_property_access.

@Test
public void should_throw_exception_if_property_cannot_be_extracted_due_to_runtime_exception_during_property_access() {
    thrown.expectIntrospectionError();
    Employee employee = new BrokenEmployee();
    adultExtractor().extract(employee);
}
Also used : Employee(org.assertj.core.test.Employee) Test(org.junit.Test)

Example 24 with Employee

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

the class FieldsOrPropertiesExtractor_extract_Test method setUp.

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

Example 25 with Employee

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

the class FieldsOrPropertiesExtractor_extract_tuples_Test method setUp.

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

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