Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static org.assertj.core.error.ShouldHaveSizeLessThan.shouldHaveSizeLessThan;
import static org.assertj.core.error.ShouldHaveSizeLessThanOrEqualTo.shouldHaveSizeLessThanOrEqualTo;
import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
import static org.assertj.core.util.Preconditions.checkArgument;
import static org.assertj.eclipse.collections.util.RichIterableUtil.sizeOf;

Expand Down Expand Up @@ -148,6 +149,21 @@ protected void assertContains(ELEMENT[] values) {
throw assertionError(shouldContain(actual, valuesList, notFound)); // TODO: ComparisonStrategy???
}

@Override
protected void assertDoesNotContain(ELEMENT[] values) {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

ArrayAdapter<ELEMENT> valuesList = ArrayAdapter.adapt(values);
MutableList<ELEMENT> found = valuesList.select(actual::contains);

if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, valuesList, found)); // TODO: ComparisonStrategy???
}

@Override
@CheckReturnValue
public <T> SELF filteredOn(Function<? super ELEMENT, T> function, T expectedValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.collections.api.block.procedure.primitive.BooleanProcedure;
import org.eclipse.collections.api.factory.primitive.BooleanLists;
import org.eclipse.collections.api.list.primitive.BooleanList;
import org.eclipse.collections.api.list.primitive.ImmutableBooleanList;

public class BooleanIterableAssert extends AbstractPrimitiveIterableAssert<BooleanIterableAssert, BooleanIterable> {
public BooleanIterableAssert(BooleanIterable actual) {
Expand Down Expand Up @@ -95,4 +97,17 @@ public BooleanIterableAssert contains(boolean... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public BooleanIterableAssert doesNotContain(boolean... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableBooleanList found = BooleanLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.collections.api.block.procedure.primitive.ByteProcedure;
import org.eclipse.collections.api.factory.primitive.ByteLists;
import org.eclipse.collections.api.list.primitive.ByteList;
import org.eclipse.collections.api.list.primitive.ImmutableByteList;

public class ByteIterableAssert extends AbstractPrimitiveIterableAssert<ByteIterableAssert, ByteIterable> {

Expand Down Expand Up @@ -96,4 +98,17 @@ public ByteIterableAssert contains(byte... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public ByteIterableAssert doesNotContain(byte... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableByteList found = ByteLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.collections.api.block.procedure.primitive.CharProcedure;
import org.eclipse.collections.api.factory.primitive.CharLists;
import org.eclipse.collections.api.list.primitive.CharList;
import org.eclipse.collections.api.list.primitive.ImmutableCharList;

public class CharIterableAssert extends AbstractPrimitiveIterableAssert<CharIterableAssert, CharIterable> {
public CharIterableAssert(CharIterable actual) {
Expand Down Expand Up @@ -95,4 +97,17 @@ public CharIterableAssert contains(char... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public CharIterableAssert doesNotContain(char... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableCharList found = CharLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
import java.util.function.DoubleConsumer;
Expand All @@ -30,6 +31,7 @@
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.factory.primitive.DoubleLists;
import org.eclipse.collections.api.list.primitive.DoubleList;
import org.eclipse.collections.api.list.primitive.ImmutableDoubleList;

public class DoubleIterableAssert extends AbstractPrimitiveIterableAssert<DoubleIterableAssert, DoubleIterable> {
public DoubleIterableAssert(DoubleIterable actual) {
Expand Down Expand Up @@ -95,4 +97,17 @@ public DoubleIterableAssert contains(double... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public DoubleIterableAssert doesNotContain(double... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableDoubleList found = DoubleLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.collections.api.block.procedure.primitive.FloatProcedure;
import org.eclipse.collections.api.factory.primitive.FloatLists;
import org.eclipse.collections.api.list.primitive.FloatList;
import org.eclipse.collections.api.list.primitive.ImmutableFloatList;

public class FloatIterableAssert extends AbstractPrimitiveIterableAssert<FloatIterableAssert, FloatIterable> {
public FloatIterableAssert(FloatIterable actual) {
Expand Down Expand Up @@ -95,4 +97,17 @@ public FloatIterableAssert contains(float... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public FloatIterableAssert doesNotContain(float... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableFloatList found = FloatLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
import java.util.function.IntConsumer;
Expand All @@ -29,6 +30,7 @@
import org.eclipse.collections.api.IntIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.factory.primitive.IntLists;
import org.eclipse.collections.api.list.primitive.ImmutableIntList;
import org.eclipse.collections.api.list.primitive.IntList;

public class IntIterableAssert extends AbstractPrimitiveIterableAssert<IntIterableAssert, IntIterable> {
Expand Down Expand Up @@ -87,12 +89,24 @@ public IntIterableAssert contains(int... values) {
isNotNull();

IntIterable notFound = IntLists.immutable.of(values).reject(actual::contains);

if (notFound.isEmpty()) {
return;
}

throw assertionError(shouldContain(actual, values, notFound));
});
}

public IntIterableAssert doesNotContain(int... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableIntList found = IntLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
import java.util.function.LongConsumer;
Expand All @@ -29,6 +30,7 @@
import org.eclipse.collections.api.LongIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.factory.primitive.LongLists;
import org.eclipse.collections.api.list.primitive.ImmutableLongList;
import org.eclipse.collections.api.list.primitive.LongList;

public class LongIterableAssert extends AbstractPrimitiveIterableAssert<LongIterableAssert, LongIterable> {
Expand Down Expand Up @@ -95,4 +97,17 @@ public LongIterableAssert contains(long... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public LongIterableAssert doesNotContain(long... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableLongList found = LongLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;

Expand All @@ -29,6 +30,7 @@
import org.eclipse.collections.api.block.predicate.primitive.ShortPredicate;
import org.eclipse.collections.api.block.procedure.primitive.ShortProcedure;
import org.eclipse.collections.api.factory.primitive.ShortLists;
import org.eclipse.collections.api.list.primitive.ImmutableShortList;
import org.eclipse.collections.api.list.primitive.ShortList;

public class ShortIterableAssert extends AbstractPrimitiveIterableAssert<ShortIterableAssert, ShortIterable> {
Expand Down Expand Up @@ -95,4 +97,17 @@ public ShortIterableAssert contains(short... values) {
throw assertionError(shouldContain(actual, values, notFound));
});
}

public ShortIterableAssert doesNotContain(short... values) {
return executeAssertion(() -> {
isNotNull();

ImmutableShortList found = ShortLists.immutable.of(values).select(actual::contains);
if (found.isEmpty()) {
return;
}

throw assertionError(shouldNotContain(actual, values, found));
});
}
}
Loading
Loading