use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_hasOnlyOneElementSatisfying_Test method succeeds_if_array_has_only_one_element_and_that_element_statisfies_the_given_assertion.
@Test
public void succeeds_if_array_has_only_one_element_and_that_element_statisfies_the_given_assertion() {
Jedi[] jedis = { new Jedi("Yoda", "red") };
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 AtomicReferenceArrayAssert_usingElementComparatorIgnoringFields_Test method should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_using_element_comparator_ignoring_fields.
@Test
public void should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_using_element_comparator_ignoring_fields() {
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "blue");
assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithType(ALWAY_EQUALS_STRING, String.class).usingElementComparatorIgnoringFields("name").contains(other);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class AtomicReferenceArrayAssert_usingElementComparatorIgnoringFields_Test method comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_using_element_comparator_ignoring_fields.
@Test
public void comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_using_element_comparator_ignoring_fields() {
Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "green");
assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingComparatorForElementFieldsWithType(comparator, String.class).usingElementComparatorIgnoringFields("lightSaberColor").contains(other);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertHasSameHashCodeAs_Test method should_pass_if_actual_has_the_same_hash_code_as_other.
@Test
public void should_pass_if_actual_has_the_same_hash_code_as_other() {
// Jedi class hashCode is computed with the Jedi's name only
Jedi redYoda = new Jedi("Yoda", "Red");
objects.assertHasSameHashCodeAs(someInfo(), greenYoda, redYoda);
objects.assertHasSameHashCodeAs(someInfo(), redYoda, greenYoda);
objects.assertHasSameHashCodeAs(someInfo(), greenYoda, new Jedi("Yoda", "green"));
objects.assertHasSameHashCodeAs(someInfo(), greenYoda, greenYoda);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class Objects_assertIsEqualToComparingOnlyGivenFields_Test method should_pass_when_field_value_is_null.
@Test
public void should_pass_when_field_value_is_null() {
Jedi actual = new Jedi("Yoda", null);
Jedi other = new Jedi("Yoda", null);
objects.assertIsEqualToComparingOnlyGivenFields(someInfo(), actual, other, noFieldComparators(), defaultTypeComparators(), "name", "lightSaberColor");
}
Aggregations