Search in sources :

Example 26 with Jedi

use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.

the class ObjectArrayAssert_usingElementComparatorOnFields_Test method should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_using_element_comparator_on_fields.

@Test
public void should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_using_element_comparator_on_fields() {
    Jedi actual = new Jedi("Yoda", "green");
    Jedi other = new Jedi("Luke", "blue");
    assertThat(array(actual)).usingComparatorForElementFieldsWithType(ALWAY_EQUALS_STRING, String.class).usingElementComparatorOnFields("name", "lightSaberColor").contains(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) Test(org.junit.Test) ObjectArrayAssertBaseTest(org.assertj.core.api.ObjectArrayAssertBaseTest)

Example 27 with Jedi

use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.

the class ObjectAssert_isEqualToIgnoringNullFields_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", null);
    Jedi other = new Jedi("Luke", null);
    assertThat(actual).usingComparatorForFields(ALWAY_EQUALS_STRING, "name").isEqualToIgnoringNullFields(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 28 with Jedi

use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.

the class ObjectAssert_isEqualToIgnoringNullFields_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", null);
    Jedi other = new Jedi("Luke", null);
    assertThat(actual).usingComparatorForFields(ALWAY_EQUALS_STRING, "name").usingComparatorForType(comparator, String.class).isEqualToIgnoringNullFields(other);
}
Also used : EMPTY_MAP(java.util.Collections.EMPTY_MAP) TypeComparators.defaultTypeComparators(org.assertj.core.internal.TypeComparators.defaultTypeComparators) ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Jedi(org.assertj.core.test.Jedi) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectAssert(org.assertj.core.api.ObjectAssert) Test(org.junit.Test) Comparator(java.util.Comparator) Mockito.verify(org.mockito.Mockito.verify) Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 29 with Jedi

use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.

the class ObjectAssert_isEqualToIgnoringNullFields_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", null);
    Jedi other = new Jedi("Luke", null);
    assertThat(actual).usingComparatorForType(ALWAY_EQUALS_STRING, String.class).isEqualToIgnoringNullFields(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Test(org.junit.Test)

Example 30 with Jedi

use of org.assertj.core.test.Jedi in project assertj-core by joel-costigliola.

the class ObjectAssert_isEqualsToComparingFields_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).isEqualToComparingFieldByField(other);
}
Also used : ALWAY_EQUALS(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS) ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) NEVER_EQUALS(org.assertj.core.test.NeverEqualComparator.NEVER_EQUALS) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Timestamp(java.sql.Timestamp) Test(org.junit.Test) Mockito.verify(org.mockito.Mockito.verify) EMPTY_MAP(java.util.Collections.EMPTY_MAP) SYMMETRIC_DATE_COMPARATOR(org.assertj.core.internal.objects.SymmetricDateComparator.SYMMETRIC_DATE_COMPARATOR) TypeComparators.defaultTypeComparators(org.assertj.core.internal.TypeComparators.defaultTypeComparators) Patient(org.assertj.core.test.Patient) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest) Jedi(org.assertj.core.test.Jedi) ObjectAssert(org.assertj.core.api.ObjectAssert) Person(org.assertj.core.test.Person) Comparator(java.util.Comparator) PersonCaseInsensitiveNameComparator(org.assertj.core.test.PersonCaseInsensitiveNameComparator) Jedi(org.assertj.core.test.Jedi) Test(org.junit.Test) ObjectAssertBaseTest(org.assertj.core.api.ObjectAssertBaseTest)

Aggregations

Jedi (org.assertj.core.test.Jedi)108 Test (org.junit.Test)104 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)30 ObjectAssertBaseTest (org.assertj.core.api.ObjectAssertBaseTest)26 Comparator (java.util.Comparator)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 ALWAY_EQUALS_STRING (org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING)13 Before (org.junit.Before)13 AssertionInfo (org.assertj.core.api.AssertionInfo)10 AtomicReferenceArrayAssertBaseTest (org.assertj.core.api.AtomicReferenceArrayAssertBaseTest)9 IterableAssertBaseTest (org.assertj.core.api.IterableAssertBaseTest)9 ObjectArrayAssertBaseTest (org.assertj.core.api.ObjectArrayAssertBaseTest)9 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)9 Lists.newArrayList (org.assertj.core.util.Lists.newArrayList)7 TextDescription (org.assertj.core.description.TextDescription)6 ExtendedByTypesComparator (org.assertj.core.internal.ExtendedByTypesComparator)6 ObjectArrays (org.assertj.core.internal.ObjectArrays)6 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)6 List (java.util.List)5 TypeComparators.defaultTypeComparators (org.assertj.core.internal.TypeComparators.defaultTypeComparators)5