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 @@ -22,6 +22,7 @@
import static org.assertj.core.error.ShouldBeEmpty.shouldBeEmpty;
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldContainNull.shouldContainNull;
import static org.assertj.core.error.ShouldContainOnlyNulls.shouldContainOnlyNulls;
import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs;
Expand Down Expand Up @@ -52,6 +53,7 @@
import org.assertj.core.presentation.PredicateDescription;
import org.eclipse.collections.api.PrimitiveIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.impl.list.fixed.ArrayAdapter;
Expand Down Expand Up @@ -152,6 +154,23 @@ protected void assertContains(ELEMENT[] values) {
throw assertionError(shouldContain(actual, valuesList, notFound)); // TODO: ComparisonStrategy???
}

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

if (actual.isEmpty() && values.length == 0) {
return;
}

ImmutableList<ELEMENT> valuesToSearchFor = Lists.immutable.of(values);
if (actual.containsAnyIterable(valuesToSearchFor)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values)); // TODO: ComparisonStrategy???
}

@Override
protected void assertDoesNotContain(ELEMENT[] values) {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -98,6 +99,23 @@ public BooleanIterableAssert contains(boolean... values) {
});
}

public BooleanIterableAssert containsAnyOf(boolean... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public BooleanIterableAssert doesNotContain(boolean... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -99,6 +100,23 @@ public ByteIterableAssert contains(byte... values) {
});
}

public ByteIterableAssert containsAnyOf(byte... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public ByteIterableAssert doesNotContain(byte... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -98,6 +99,23 @@ public CharIterableAssert contains(char... values) {
});
}

public CharIterableAssert containsAnyOf(char... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public CharIterableAssert doesNotContain(char... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -98,6 +99,23 @@ public DoubleIterableAssert contains(double... values) {
});
}

public DoubleIterableAssert containsAnyOf(double... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public DoubleIterableAssert doesNotContain(double... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -98,6 +99,23 @@ public FloatIterableAssert contains(float... values) {
});
}

public FloatIterableAssert containsAnyOf(float... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public FloatIterableAssert doesNotContain(float... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -87,6 +88,11 @@ private static Optional<UnsatisfiedRequirement> failsRequirements(IntConsumer re
public IntIterableAssert contains(int... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

IntIterable notFound = IntLists.immutable.of(values).reject(actual::contains);
if (notFound.isEmpty()) {
Expand All @@ -97,6 +103,23 @@ public IntIterableAssert contains(int... values) {
});
}

public IntIterableAssert containsAnyOf(int... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public IntIterableAssert doesNotContain(int... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -98,6 +99,23 @@ public LongIterableAssert contains(long... values) {
});
}

public LongIterableAssert containsAnyOf(long... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

public LongIterableAssert doesNotContain(long... values) {
return executeAssertion(() -> {
isNotNull();
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.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;

import java.util.Optional;
Expand Down Expand Up @@ -98,6 +99,23 @@ public ShortIterableAssert contains(short... values) {
});
}

public ShortIterableAssert containsAnyOf(short... values) {
return executeAssertion(() -> {
isNotNull();
requireNonNull(values, "The array of values to look for should not be null");

if (actual.isEmpty() && values.length == 0) {
return;
}

if (actual.containsAny(values)) {
return;
}

throw assertionError(shouldContainAnyOf(actual, values));
});
}

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