Search in sources :

Example 1 with Iterables

use of org.assertj.core.internal.Iterables in project assertj-core by joel-costigliola.

the class IterablesBaseTest method setUp.

@Before
public void setUp() {
    actual = newArrayList("Luke", "Yoda", "Leia");
    failures = spy(new Failures());
    iterables = new Iterables();
    iterables.failures = failures;
    comparisonStrategy = new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance);
    iterablesWithCaseInsensitiveComparisonStrategy = new Iterables(comparisonStrategy);
    iterablesWithCaseInsensitiveComparisonStrategy.failures = failures;
    info = someInfo();
}
Also used : ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Failures(org.assertj.core.internal.Failures) Iterables(org.assertj.core.internal.Iterables) Before(org.junit.Before)

Example 2 with Iterables

use of org.assertj.core.internal.Iterables in project assertj-core by joel-costigliola.

the class IterableAssert_usingComparatorForType_Test method verify_internal_effects.

@Override
protected void verify_internal_effects() {
    Iterables iterables = getIterables(assertions);
    assertThat(iterables).isNotSameAs(iterablesBefore);
    assertThat(iterables.getComparisonStrategy()).isInstanceOf(ComparatorBasedComparisonStrategy.class);
    ComparatorBasedComparisonStrategy strategy = (ComparatorBasedComparisonStrategy) iterables.getComparisonStrategy();
    assertThat(strategy.getComparator()).isInstanceOf(ExtendedByTypesComparator.class);
}
Also used : ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Iterables(org.assertj.core.internal.Iterables)

Example 3 with Iterables

use of org.assertj.core.internal.Iterables in project assertj-core by joel-costigliola.

the class IterableAssert_usingElementComparatorIgnoringFields_Test method verify_internal_effects.

@Override
protected void verify_internal_effects() {
    Iterables iterables = getIterables(assertions);
    assertThat(iterables).isNotSameAs(iterablesBefore);
    assertThat(iterables.getComparisonStrategy()).isInstanceOf(ComparatorBasedComparisonStrategy.class);
    ComparatorBasedComparisonStrategy strategy = (ComparatorBasedComparisonStrategy) iterables.getComparisonStrategy();
    assertThat(strategy.getComparator()).isInstanceOf(ExtendedByTypesComparator.class);
    assertThat(((IgnoringFieldsComparator) ((ExtendedByTypesComparator) strategy.getComparator()).getComparator()).getFields()).containsOnly("field");
}
Also used : IgnoringFieldsComparator(org.assertj.core.internal.IgnoringFieldsComparator) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Iterables(org.assertj.core.internal.Iterables)

Example 4 with Iterables

use of org.assertj.core.internal.Iterables in project assertj-core by joel-costigliola.

the class AbstractIterableAssert method usingElementComparator.

/**
 * {@inheritDoc}
 */
@Override
@CheckReturnValue
public SELF usingElementComparator(Comparator<? super ELEMENT> elementComparator) {
    this.iterables = new Iterables(new ComparatorBasedComparisonStrategy(elementComparator));
    // to have the same semantics on base assertions like isEqualTo, we need to use an iterable comparator comparing
    // elements with elementComparator parameter
    objects = new Objects(new IterableElementComparisonStrategy<>(elementComparator));
    return myself;
}
Also used : IterableElementComparisonStrategy(org.assertj.core.internal.IterableElementComparisonStrategy) Objects(org.assertj.core.internal.Objects) ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) Iterables(org.assertj.core.internal.Iterables) CheckReturnValue(org.assertj.core.util.CheckReturnValue)

Example 5 with Iterables

use of org.assertj.core.internal.Iterables in project assertj-core by joel-costigliola.

the class IterableAssert_usingElementComparatorOnFields_Test method verify_internal_effects.

@Override
protected void verify_internal_effects() {
    Iterables iterables = getIterables(assertions);
    assertThat(iterables).isNotSameAs(iterablesBefore);
    assertThat(iterables.getComparisonStrategy()).isInstanceOf(ComparatorBasedComparisonStrategy.class);
    ComparatorBasedComparisonStrategy strategy = (ComparatorBasedComparisonStrategy) iterables.getComparisonStrategy();
    assertThat(strategy.getComparator()).isInstanceOf(ExtendedByTypesComparator.class);
    assertThat(((OnFieldsComparator) ((ExtendedByTypesComparator) strategy.getComparator()).getComparator()).getFields()).containsOnly("field");
}
Also used : ComparatorBasedComparisonStrategy(org.assertj.core.internal.ComparatorBasedComparisonStrategy) OnFieldsComparator(org.assertj.core.internal.OnFieldsComparator) Iterables(org.assertj.core.internal.Iterables)

Aggregations

Iterables (org.assertj.core.internal.Iterables)8 ComparatorBasedComparisonStrategy (org.assertj.core.internal.ComparatorBasedComparisonStrategy)6 Lists (org.assertj.core.internal.Lists)3 ExtendedByTypesComparator (org.assertj.core.internal.ExtendedByTypesComparator)2 IgnoringFieldsComparator (org.assertj.core.internal.IgnoringFieldsComparator)2 OnFieldsComparator (org.assertj.core.internal.OnFieldsComparator)2 Failures (org.assertj.core.internal.Failures)1 IterableElementComparisonStrategy (org.assertj.core.internal.IterableElementComparisonStrategy)1 Objects (org.assertj.core.internal.Objects)1 CheckReturnValue (org.assertj.core.util.CheckReturnValue)1 Before (org.junit.Before)1