Search in sources :

Example 61 with Jedi

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_specified_fields_of_elements_when_using_element_comparator_ignoring_fields.

@Test
public void should_be_able_to_use_a_comparator_for_specified_fields_of_elements_when_using_element_comparator_ignoring_fields() {
    Jedi actual = new Jedi("Yoda", "green");
    Jedi other = new Jedi("Luke", "green");
    assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingElementComparatorIgnoringFields("lightSaberColor").contains(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) Test(org.junit.Test)

Example 62 with Jedi

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

the class AtomicReferenceArrayAssert_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(atomicArrayOf(actual)).usingComparatorForElementFieldsWithType(ALWAY_EQUALS_STRING, String.class).usingElementComparatorOnFields("name", "lightSaberColor").contains(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) Test(org.junit.Test)

Example 63 with Jedi

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

the class AtomicReferenceArrayAssert_usingElementComparatorOnFields_Test method should_be_able_to_use_a_comparator_for_specified_fields_of_elements_when_using_element_comparator_on_fields.

@Test
public void should_be_able_to_use_a_comparator_for_specified_fields_of_elements_when_using_element_comparator_on_fields() {
    Jedi actual = new Jedi("Yoda", "green");
    Jedi other = new Jedi("Luke", "green");
    assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithNames(ALWAY_EQUALS_STRING, "name").usingElementComparatorOnFields("name", "lightSaberColor").contains(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest) Test(org.junit.Test)

Example 64 with Jedi

use of org.assertj.core.test.Jedi 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 65 with Jedi

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

the class AtomicReferenceArrayAssert_usingFieldByFieldElementComparator_Test method should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_when_using_field_by_field_element_comparator.

@Test
public void should_be_able_to_use_a_comparator_for_element_fields_with_specified_type_when_using_field_by_field_element_comparator() {
    Jedi actual = new Jedi("Yoda", "green");
    Jedi other = new Jedi("Luke", "blue");
    assertThat(atomicArrayOf(actual)).usingComparatorForElementFieldsWithType(ALWAY_EQUALS_STRING, String.class).usingFieldByFieldElementComparator().contains(other);
}
Also used : Jedi(org.assertj.core.test.Jedi) Test(org.junit.Test) AtomicReferenceArrayAssertBaseTest(org.assertj.core.api.AtomicReferenceArrayAssertBaseTest)

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