use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class PropertyOrFieldSupport_getValueOf_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() {
Object extractedValue = propertyOrFieldSupport.getValueOf("name", employeeWithBrokenName("Name"));
assertThat(extractedValue).isEqualTo(new Name("Name"));
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class PropertySupport_propertyValues_Test method setUpOnce.
@Before
public void setUpOnce() {
yoda = new Employee(6000L, new Name("Yoda"), 800);
luke = new Employee(8000L, new Name("Luke", "Skywalker"), 26);
employees = newArrayList(yoda, luke);
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class IterableAssert_extractingResultOf_Test method should_allow_assertions_on_method_invocation_result_extracted_from_given_iterable.
@Test
public void should_allow_assertions_on_method_invocation_result_extracted_from_given_iterable() {
// extract method result
assertThat(jedis).extractingResultOf("age").containsOnly(800, 50);
// extract if method result is primitive
assertThat(jedis).extractingResultOf("darkSide").containsOnly(false, true);
// extract if method result is also a property
assertThat(jedis).extractingResultOf("name").containsOnly(new Name("Yoda"), new Name("Darth Vader"));
// extract toString method result
assertThat(jedis).extractingResultOf("toString").containsOnly("Yoda", "Darth Vader");
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class IterableAssert_extracting_Test method should_allow_assertions_on_field_values_extracted_from_given_iterable.
@Test
public void should_allow_assertions_on_field_values_extracted_from_given_iterable() {
assertThat(employees).extracting("id").as("extract field").containsOnly(1L, 2L);
assertThat(employees).extracting("surname").as("null field").containsNull();
assertThat(employees).extracting("surname.first").as("null nested field").containsNull();
yoda.surname = new Name();
assertThat(employees).extracting("surname.first").as("not null field but null nested field").containsNull();
yoda.surname = new Name("Master");
assertThat(employees).extracting("surname.first").as("nested field").containsOnly("Master", null);
assertThat(employees).extracting("surname", Name.class).as("extract field specifying the extracted type").containsOnly(new Name("Master"), null);
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class IterableAssert_extracting_Test method should_allow_assertions_on_property_values_extracted_from_given_iterable.
@Test
public void should_allow_assertions_on_property_values_extracted_from_given_iterable() {
assertThat(employees).extracting("age").as("extract property backed by a private field").containsOnly(800, 26);
assertThat(employees).extracting("adult").as("extract pure property").containsOnly(true, true);
assertThat(employees).extracting("name.first").as("nested property").containsOnly("Yoda", "Luke");
assertThat(employees).extracting("name").as("extract field that is also a property").containsOnly(new Name("Yoda"), new Name("Luke", "Skywalker"));
assertThat(employees).extracting("name", Name.class).as("extract field that is also a property but specifying the extracted type").containsOnly(new Name("Yoda"), new Name("Luke", "Skywalker"));
}
Aggregations