Search in sources :

Example 11 with Employee

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

the class FieldsOrPropertiesExtractor_extract_Test method should_prefer_properties_over_fields.

@Test
public void should_prefer_properties_over_fields() {
    List<Employee> employees = Arrays.<Employee>asList(new EmployeeWithOverriddenName("Overridden Name"));
    List<Object> extractedValues = extract(employees, byName("name"));
    assertThat(extractedValues).containsOnly(new Name("Overridden Name"));
}
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 12 with Employee

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

the class ObjectAssert_extracting_Test method should_keep_existing_description_if_set_when_extracting_tuples_list.

@Test
public void should_keep_existing_description_if_set_when_extracting_tuples_list() {
    Employee luke = new Employee(2L, new Name("Luke", "Skywalker"), 26);
    thrown.expectAssertionErrorWithMessageContaining("[check luke first name]");
    assertThat(luke).as("check luke first name").extracting("name.first").isEmpty();
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 13 with Employee

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

the class ObjectAssert_extracting_Test method should_use_property_field_names_as_description_when_extracting_tuples_list.

@Test
public void should_use_property_field_names_as_description_when_extracting_tuples_list() {
    Employee luke = new Employee(2L, new Name("Luke", "Skywalker"), 26);
    thrown.expectAssertionErrorWithMessageContaining("[Extracted: name.first, name.last]");
    assertThat(luke).extracting("name.first", "name.last").isEmpty();
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Test(org.junit.Test)

Example 14 with Employee

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

the class ObjectArrayAssert_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 Employee[] { yoda, luke, obiwan, noname };
}
Also used : Employee(org.assertj.core.test.Employee) Name(org.assertj.core.test.Name) Before(org.junit.Before)

Example 15 with Employee

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

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