Search in sources :

Example 6 with ALWAY_EQUALS_STRING

use of org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING 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)

Example 7 with ALWAY_EQUALS_STRING

use of org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING 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);
}
Also used : AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) ExtendedByTypesComparator(org.assertj.core.internal.ExtendedByTypesComparator) AtomicReferenceArrayAssert(org.assertj.core.api.AtomicReferenceArrayAssert) Jedi(org.assertj.core.test.Jedi) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IgnoringFieldsComparator(org.assertj.core.internal.IgnoringFieldsComparator) Test(org.junit.Test) Comparator(java.util.Comparator) ObjectArrays(org.assertj.core.internal.ObjectArrays) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Before(org.junit.Before) Jedi(org.assertj.core.test.Jedi) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) Test(org.junit.Test)

Example 8 with ALWAY_EQUALS_STRING

use of org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING 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");
}
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 9 with ALWAY_EQUALS_STRING

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

the class AtomicReferenceArrayAssert_usingElementComparatorOnFields_Test method comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_using_element_comparator_on_fields.

@Test
public void comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_using_element_comparator_on_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).usingElementComparatorOnFields("name", "lightSaberColor").contains(other);
}
Also used : OnFieldsComparator(org.assertj.core.internal.OnFieldsComparator) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) ExtendedByTypesComparator(org.assertj.core.internal.ExtendedByTypesComparator) AtomicReferenceArrayAssert(org.assertj.core.api.AtomicReferenceArrayAssert) Jedi(org.assertj.core.test.Jedi) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Comparator(java.util.Comparator) ObjectArrays(org.assertj.core.internal.ObjectArrays) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Before(org.junit.Before) Jedi(org.assertj.core.test.Jedi) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) Test(org.junit.Test)

Example 10 with ALWAY_EQUALS_STRING

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

the class AtomicReferenceArrayAssert_usingFieldByFieldElementComparator_Test method comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_when_using_field_by_field_element_comparator.

@Test
public void comparators_for_element_field_names_should_have_precedence_over_comparators_for_element_field_types_when_using_field_by_field_element_comparator() {
    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).usingFieldByFieldElementComparator().contains(other);
}
Also used : ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) AtomicReferenceArrayAssert(org.assertj.core.api.AtomicReferenceArrayAssert) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Arrays.array(org.assertj.core.util.Arrays.array) String.format(java.lang.String.format) AtomicReferenceArrayElementComparisonStrategy(org.assertj.core.internal.AtomicReferenceArrayElementComparisonStrategy) AtomicReferenceArray(java.util.concurrent.atomic.AtomicReferenceArray) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Objects(java.util.Objects) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) Jedi(org.assertj.core.test.Jedi) Comparator(java.util.Comparator) ObjectArrays(org.assertj.core.internal.ObjectArrays) Lists.newArrayList(org.assertj.core.util.Lists.newArrayList) Before(org.junit.Before) Jedi(org.assertj.core.test.Jedi) Test(org.junit.Test) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest)

Aggregations

Comparator (java.util.Comparator)13 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 ALWAY_EQUALS_STRING (org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING)13 Jedi (org.assertj.core.test.Jedi)13 Test (org.junit.Test)13 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)9 Before (org.junit.Before)9 ExtendedByTypesComparator (org.assertj.core.internal.ExtendedByTypesComparator)6 ObjectArrays (org.assertj.core.internal.ObjectArrays)6 EMPTY_MAP (java.util.Collections.EMPTY_MAP)4 ObjectAssert (org.assertj.core.api.ObjectAssert)4 ObjectAssertBaseTest (org.assertj.core.api.ObjectAssertBaseTest)4 TypeComparators.defaultTypeComparators (org.assertj.core.internal.TypeComparators.defaultTypeComparators)4 Arrays.array (org.assertj.core.util.Arrays.array)4 Mockito.verify (org.mockito.Mockito.verify)4 Collections.singletonList (java.util.Collections.singletonList)3 Objects (java.util.Objects)3 AtomicReferenceArrayAssert (org.assertj.core.api.AtomicReferenceArrayAssert)3 AtomicReferenceArrayAssertBaseTest (org.assertj.core.api.AtomicReferenceArrayAssertBaseTest)3 ConcreteIterableAssert (org.assertj.core.api.ConcreteIterableAssert)3