Search in sources :

Example 36 with BiPredicate

use of java.util.function.BiPredicate in project assertj-core by joel-costigliola.

the class RecursiveComparisonAssert_isEqualTo_withFieldComparators_Test method should_use_custom_equal_over_reference_comparison.

@Test
void should_use_custom_equal_over_reference_comparison() {
    // GIVEN
    Foo actual = new Foo(1);
    Foo expected = new Foo(1);
    BiPredicate<Integer, Integer> greaterThan = (i1, i2) -> Objects.equals(i1, i2 + 1);
    // WHEN
    AssertionError assertionError = expectAssertionError(() -> assertThat(actual).usingRecursiveComparison().withEqualsForFields(greaterThan, "bar").isEqualTo(expected));
    // THEN
    then(assertionError).hasMessageContainingAll("- these fields were compared with the following comparators:", "  - bar -> ");
}
Also used : Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ALWAYS_EQUALS_TIMESTAMP(org.assertj.core.test.AlwaysEqualComparator.ALWAYS_EQUALS_TIMESTAMP) Person(org.assertj.core.internal.objects.data.Person) BiPredicate(java.util.function.BiPredicate) SYMMETRIC_DATE_COMPARATOR(org.assertj.core.internal.objects.SymmetricDateComparator.SYMMETRIC_DATE_COMPARATOR) CaseInsensitiveStringComparator(org.assertj.core.internal.CaseInsensitiveStringComparator) RecursiveComparisonAssert_isEqualTo_BaseTest(org.assertj.core.api.RecursiveComparisonAssert_isEqualTo_BaseTest) AlwaysEqualPerson(org.assertj.core.internal.objects.data.AlwaysEqualPerson) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) MethodSource(org.junit.jupiter.params.provider.MethodSource) NEVER_EQUALS(org.assertj.core.test.NeverEqualComparator.NEVER_EQUALS) Timestamp(java.sql.Timestamp) AlwaysDifferentComparator.alwaysDifferent(org.assertj.core.test.AlwaysDifferentComparator.alwaysDifferent) BDDAssertions.then(org.assertj.core.api.BDDAssertions.then) Arguments(org.junit.jupiter.params.provider.Arguments) Arrays.array(org.assertj.core.util.Arrays.array) AssertionsUtil.expectAssertionError(org.assertj.core.util.AssertionsUtil.expectAssertionError) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Giant(org.assertj.core.internal.objects.data.Giant) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) Patient(org.assertj.core.test.Patient) AtPrecisionComparator(org.assertj.core.internal.AtPrecisionComparator) ALWAYS_EQUALS(org.assertj.core.test.AlwaysEqualComparator.ALWAYS_EQUALS) Comparator(java.util.Comparator) AlwaysEqualComparator.alwaysEqual(org.assertj.core.test.AlwaysEqualComparator.alwaysEqual) AssertionsUtil.expectAssertionError(org.assertj.core.util.AssertionsUtil.expectAssertionError) RecursiveComparisonAssert_isEqualTo_BaseTest(org.assertj.core.api.RecursiveComparisonAssert_isEqualTo_BaseTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BiPredicate (java.util.function.BiPredicate)36 List (java.util.List)17 Collectors (java.util.stream.Collectors)16 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)12 Collections (java.util.Collections)12 Map (java.util.Map)11 Files (java.nio.file.Files)10 Objects (java.util.Objects)8 Set (java.util.Set)8 HashMap (java.util.HashMap)7 Paths (java.nio.file.Paths)6 Arrays (java.util.Arrays)6 HashSet (java.util.HashSet)6 AtomicReference (java.util.concurrent.atomic.AtomicReference)6 HasContainer (org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer)6 Path (java.nio.file.Path)5 java.util (java.util)5 Collection (java.util.Collection)5 Function (java.util.function.Function)5