use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectAssert_isEqualsToComparingFields_Test method should_be_able_to_use_a_comparator_for_specified_type.
@Test
public void should_be_able_to_use_a_comparator_for_specified_type() {
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "blue");
assertThat(actual).usingComparatorForType(ALWAY_EQUALS_STRING, String.class).isEqualToComparingFieldByField(other);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectAssert_isEqualsToComparingFields_Test method should_be_able_to_use_a_type_comparator_for_any_of_the_type_subclasses.
@Test
public void should_be_able_to_use_a_type_comparator_for_any_of_the_type_subclasses() {
JediMaster yoda1 = new JediMaster("Yoda", new Jedi("luke", "Green"));
JediMaster yoda2 = new JediMaster("Yoda", new Jedi("LUKE", null));
// Jedi is a subclass of Person
assertThat(yoda1).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).isEqualToComparingFieldByField(yoda2);
assertThat(yoda2).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).isEqualToComparingFieldByField(yoda1);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_hasOnlyOneElementSatisfying_Test method fails_if_arry_has_more_than_one_element.
@Test
public void fails_if_arry_has_more_than_one_element() {
thrown.expectAssertionErrorWithMessageContaining("Expected size:<1> but was:<2>");
Jedi[] jedis = { new Jedi("Yoda", "red"), new Jedi("Luke", "green") };
assertThat(jedis).hasOnlyOneElementSatisfying(yoda -> assertThat(yoda.getName()).startsWith("Y"));
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_hasOnlyOneElementSatisfying_Test method fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_one_of_the_given_assertion.
@Test
public void fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_one_of_the_given_assertion() {
thrown.expectAssertionError("%nExpecting:%n <\"Yoda\">%nto start with:%n <\"L\">%n");
Jedi[] jedis = { new Jedi("Yoda", "red") };
assertThat(jedis).hasOnlyOneElementSatisfying(yoda -> {
assertThat(yoda.getName()).startsWith("Y");
assertThat(yoda.getName()).startsWith("L");
});
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_hasOnlyOneElementSatisfying_Test method fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_the_soft_assertion.
@Test
public void fails_if_iterable_has_only_one_element_and_that_element_does_not_statisfy_the_soft_assertion() {
Jedi[] jedis = { new Jedi("Yoda", "red") };
Throwable assertionError = catchThrowable(() -> {
assertThat(jedis).hasOnlyOneElementSatisfying(yoda -> {
SoftAssertions softly = new SoftAssertions();
softly.assertThat(yoda.getName()).startsWith("L");
softly.assertThat(yoda.getName()).startsWith("M");
softly.assertAll();
});
});
assertThat(assertionError).hasMessageContaining(format("Expecting:%n <\"Yoda\">%nto start with:%n <\"L\">")).hasMessageContaining(format("Expecting:%n <\"Yoda\">%nto start with:%n <\"M\">"));
}
Aggregations