use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectAssert_isEqualToComparingOnlyGivenFields_Test method comparators_for_fields_should_have_precedence_over_comparators_for_types.
@Test
public void comparators_for_fields_should_have_precedence_over_comparators_for_types() {
Comparator<String> comparator = (o1, o2) -> o1.compareTo(o2);
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "green");
assertThat(actual).usingComparatorForFields(ALWAY_EQUALS_STRING, "name").usingComparatorForType(comparator, String.class).isEqualToComparingOnlyGivenFields(other, "name");
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectArrayAssert_hasOnlyOneElementSatisfying_Test method fails_if_arry_has_only_one_element_and_that_element_does_not_statisfy_the_given_assertion.
@Test
public void fails_if_arry_has_only_one_element_and_that_element_does_not_statisfy_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("L"));
}
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_date_comparator_for_timestamp.
@Test
public void should_be_able_to_use_a_date_comparator_for_timestamp() {
JediMaster yoda1 = new JediMaster("Yoda", new Jedi("luke", "Green"));
yoda1.dateOfBirth = new Timestamp(1000L);
JediMaster yoda2 = new JediMaster("Yoda", new Jedi("LUKE", null));
yoda2.dateOfBirth = new Date(1000L);
// use a date comparator to compare either Date or Timestamp
assertThat(yoda1).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).usingComparatorForType(SYMMETRIC_DATE_COMPARATOR, Date.class).isEqualToComparingFieldByField(yoda2);
assertThat(yoda2).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).usingComparatorForType(SYMMETRIC_DATE_COMPARATOR, Date.class).isEqualToComparingFieldByField(yoda1);
assertThat(yoda1).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).usingComparatorForType(SYMMETRIC_DATE_COMPARATOR, Timestamp.class).isEqualToComparingFieldByField(yoda2);
assertThat(yoda2).usingComparatorForType(new PersonCaseInsensitiveNameComparator(), Person.class).usingComparatorForType(SYMMETRIC_DATE_COMPARATOR, Timestamp.class).isEqualToComparingFieldByField(yoda1);
}
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_fields.
@Test
public void should_be_able_to_use_a_comparator_for_specified_fields() {
Jedi actual = new Jedi("Yoda", "green");
Jedi other = new Jedi("Luke", "green");
assertThat(actual).usingComparatorForFields(ALWAY_EQUALS_STRING, "name").isEqualToComparingFieldByField(other);
}
use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.
the class ObjectAssert_returns_Test method perform_assertion_like_users.
@Test
public void perform_assertion_like_users() {
Jedi yoda = new Jedi("Yoda", "Green");
assertThat(yoda).returns("Yoda", from(Jedi::getName)).returns("Yoda", Jedi::getName);
}
Aggregations