use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class SoftAssertionsTest method object_soft_assertions_should_report_errors_on_final_methods_and_methods_that_switch_the_object_under_test.
// the test would fail if any method was not proxyable as the assertion error would not be softly caught
@SuppressWarnings("unchecked")
@Test
public void object_soft_assertions_should_report_errors_on_final_methods_and_methods_that_switch_the_object_under_test() {
// GIVEN
Name name = name("John", "Doe");
Object alphabet = "abcdefghijklmnopqrstuvwxyz";
Object vowels = asList("a", "e", "i", "o", "u");
// WHEN
softly.assertThat(name).extracting("first", "last").contains("John").contains("gandalf");
softly.assertThat(name).extracting(Name::getFirst, Name::getLast).contains("John").contains("frodo");
softly.assertThat(alphabet).asString().startsWith("abc").startsWith("123");
softly.assertThat(vowels).asList().startsWith("a", "e").startsWith("1", "2");
// THEN
List<Throwable> errorsCollected = softly.errorsCollected();
assertThat(errorsCollected).hasSize(4);
assertThat(errorsCollected.get(0)).hasMessageContaining("gandalf");
assertThat(errorsCollected.get(1)).hasMessageContaining("frodo");
assertThat(errorsCollected.get(2)).hasMessageContaining("123");
assertThat(errorsCollected.get(3)).hasMessageContaining("\"1\", \"2\"");
}
use of org.assertj.core.test.Name 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();
}
use of org.assertj.core.test.Name 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();
}
use of org.assertj.core.test.Name 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 };
}
use of org.assertj.core.test.Name in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_extractingResultOf_Test method setUpOnce.
@BeforeClass
public static void setUpOnce() {
yoda = new FluentJedi(new Name("Yoda"), 800, false);
vader = new FluentJedi(new Name("Darth Vader"), 50, true);
jedis = array(yoda, vader);
}
Aggregations