Search in sources :

Example 11 with ALWAY_EQUALS_STRING

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

the class ObjectArrayAssert_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(array(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingComparatorForElementFieldsWithType(comparator, String.class).usingElementComparatorIgnoringFields("lightSaberColor").contains(other);
}
Also used : ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) ExtendedByTypesComparator(org.assertj.core.internal.ExtendedByTypesComparator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IgnoringFieldsComparator(org.assertj.core.internal.IgnoringFieldsComparator) Test(org.junit.Test) Arrays.array(org.assertj.core.util.Arrays.array) ObjectArrayAssert(org.assertj.core.api.ObjectArrayAssert) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) ObjectArrayAssertBaseTest(org.assertj.core.api.ObjectArrayAssertBaseTest) Jedi(org.assertj.core.test.Jedi) Comparator(java.util.Comparator) ObjectArrays(org.assertj.core.internal.ObjectArrays) Before(org.junit.Before) Jedi(org.assertj.core.test.Jedi) Test(org.junit.Test) ObjectArrayAssertBaseTest(org.assertj.core.api.ObjectArrayAssertBaseTest)

Example 12 with ALWAY_EQUALS_STRING

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

the class ObjectArrayAssert_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(array(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingComparatorForElementFieldsWithType(comparator, String.class).usingFieldByFieldElementComparator().contains(other);
}
Also used : ObjectArrayElementComparisonStrategy(org.assertj.core.internal.ObjectArrayElementComparisonStrategy) ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Arrays.array(org.assertj.core.util.Arrays.array) ObjectArrayAssert(org.assertj.core.api.ObjectArrayAssert) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Objects(java.util.Objects) ObjectArrayAssertBaseTest(org.assertj.core.api.ObjectArrayAssertBaseTest) 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) ObjectArrayAssertBaseTest(org.assertj.core.api.ObjectArrayAssertBaseTest)

Example 13 with ALWAY_EQUALS_STRING

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

the class IterableAssert_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(singletonList(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingComparatorForElementFieldsWithType(comparator, String.class).usingElementComparatorOnFields("name", "lightSaberColor").contains(other);
}
Also used : Iterables(org.assertj.core.internal.Iterables) OnFieldsComparator(org.assertj.core.internal.OnFieldsComparator) ALWAY_EQUALS_STRING(org.assertj.core.test.AlwaysEqualComparator.ALWAY_EQUALS_STRING) ExtendedByTypesComparator(org.assertj.core.internal.ExtendedByTypesComparator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ConcreteIterableAssert(org.assertj.core.api.ConcreteIterableAssert) Test(org.junit.Test) Collections.singletonList(java.util.Collections.singletonList) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) IterableAssertBaseTest(org.assertj.core.api.IterableAssertBaseTest) Jedi(org.assertj.core.test.Jedi) Comparator(java.util.Comparator) Before(org.junit.Before) Jedi(org.assertj.core.test.Jedi) Test(org.junit.Test) IterableAssertBaseTest(org.assertj.core.api.IterableAssertBaseTest)

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