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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit</artifactId>
<version>1.4.2</version>
<version>1.5.0</version>
<scope>test</scope>
</dependency>
<!-- Remove SLF4J warnings added by archunit -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.assertj.core.error.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldBeAnArray.shouldBeAnArray;
import static org.assertj.core.error.ShouldBeEmpty.shouldBeEmpty;
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
Expand Down Expand Up @@ -155,6 +156,32 @@ private void assertAnyMatch(Predicate<? super ELEMENT> predicate, PredicateDescr
}
}

@Override
public SELF anySatisfy(Consumer<? super ELEMENT> requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

@Override
public SELF anySatisfy(ThrowingConsumer<? super ELEMENT> requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(Consumer<? super ELEMENT> requirements) {
isNotNull();
requireNonNull(requirements, "The Consumer<T> expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
for (ELEMENT element : actual) {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
if (result.isEmpty()) {
return; // element satisfied the requirements
}
unsatisfiedRequirements.add(result.get());
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

@Override
protected void assertContains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,7 +32,9 @@
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.predicate.primitive.BooleanPredicate;
import org.eclipse.collections.api.block.procedure.primitive.BooleanProcedure;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.BooleanLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.BooleanList;
import org.eclipse.collections.api.list.primitive.ImmutableBooleanList;

Expand Down Expand Up @@ -102,6 +105,26 @@ private void assertAnyMatch(BooleanPredicate predicate, PredicateDescription pre
}
}

public BooleanIterableAssert anySatisfy(BooleanProcedure requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(BooleanProcedure requirements) {
isNotNull();
requireNonNull(requirements, "The BooleanProcedure expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public BooleanIterableAssert contains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,7 +32,9 @@
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.predicate.primitive.BytePredicate;
import org.eclipse.collections.api.block.procedure.primitive.ByteProcedure;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.ByteLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.ByteList;
import org.eclipse.collections.api.list.primitive.ImmutableByteList;

Expand Down Expand Up @@ -103,6 +106,26 @@ private void assertAnyMatch(BytePredicate predicate, PredicateDescription predic
}
}

public ByteIterableAssert anySatisfy(ByteProcedure requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(ByteProcedure requirements) {
isNotNull();
requireNonNull(requirements, "The ByteProcedure expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public ByteIterableAssert contains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,7 +32,9 @@
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.predicate.primitive.CharPredicate;
import org.eclipse.collections.api.block.procedure.primitive.CharProcedure;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.CharLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.CharList;
import org.eclipse.collections.api.list.primitive.ImmutableCharList;

Expand Down Expand Up @@ -102,6 +105,26 @@ private void assertAnyMatch(CharPredicate predicate, PredicateDescription predic
}
}

public CharIterableAssert anySatisfy(CharProcedure requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(CharProcedure requirements) {
isNotNull();
requireNonNull(requirements, "The CharProcedure expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public CharIterableAssert contains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,7 +32,9 @@
import org.assertj.core.presentation.PredicateDescription;
import org.eclipse.collections.api.DoubleIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.DoubleLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.DoubleList;
import org.eclipse.collections.api.list.primitive.ImmutableDoubleList;

Expand Down Expand Up @@ -102,6 +105,26 @@ private void assertAnyMatch(DoublePredicate predicate, PredicateDescription pred
}
}

public DoubleIterableAssert anySatisfy(DoubleConsumer requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(DoubleConsumer requirements) {
isNotNull();
requireNonNull(requirements, "The DoubleConsumer expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public DoubleIterableAssert contains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,7 +32,9 @@
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.predicate.primitive.FloatPredicate;
import org.eclipse.collections.api.block.procedure.primitive.FloatProcedure;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.FloatLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.FloatList;
import org.eclipse.collections.api.list.primitive.ImmutableFloatList;

Expand Down Expand Up @@ -102,6 +105,26 @@ private void assertAnyMatch(FloatPredicate predicate, PredicateDescription predi
}
}

public FloatIterableAssert anySatisfy(FloatProcedure requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(FloatProcedure requirements) {
isNotNull();
requireNonNull(requirements, "The FloatProcedure expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public FloatIterableAssert contains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,8 +32,9 @@
import org.assertj.core.presentation.PredicateDescription;
import org.eclipse.collections.api.IntIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.predicate.primitive.BooleanPredicate;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.IntLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.ImmutableIntList;
import org.eclipse.collections.api.list.primitive.IntList;

Expand Down Expand Up @@ -103,6 +105,26 @@ private void assertAnyMatch(IntPredicate predicate, PredicateDescription predica
}
}

public IntIterableAssert anySatisfy(IntConsumer requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(IntConsumer requirements) {
isNotNull();
requireNonNull(requirements, "The IntConsumer expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public IntIterableAssert contains(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.AnyElementShouldMatch.anyElementShouldMatch;
import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
import static org.assertj.core.error.ShouldContain.shouldContain;
import static org.assertj.core.error.ShouldContainAnyOf.shouldContainAnyOf;
import static org.assertj.core.error.ShouldNotContain.shouldNotContain;
Expand All @@ -31,7 +32,10 @@
import org.assertj.core.presentation.PredicateDescription;
import org.eclipse.collections.api.LongIterable;
import org.eclipse.collections.api.RichIterable;
import org.eclipse.collections.api.block.procedure.primitive.BooleanProcedure;
import org.eclipse.collections.api.factory.Lists;
import org.eclipse.collections.api.factory.primitive.LongLists;
import org.eclipse.collections.api.list.MutableList;
import org.eclipse.collections.api.list.primitive.ImmutableLongList;
import org.eclipse.collections.api.list.primitive.LongList;

Expand Down Expand Up @@ -102,6 +106,26 @@ private void assertAnyMatch(LongPredicate predicate, PredicateDescription predic
}
}

public LongIterableAssert anySatisfy(LongConsumer requirements) {
return executeAssertion(() -> assertAnySatisfy(requirements));
}

private void assertAnySatisfy(LongConsumer requirements) {
isNotNull();
requireNonNull(requirements, "The LongConsumer expressing the assertions requirements must not be null");

MutableList<UnsatisfiedRequirement> unsatisfiedRequirements = Lists.mutable.empty();
if (actual.anySatisfy(element -> {
Optional<UnsatisfiedRequirement> result = failsRequirements(requirements, element);
result.ifPresent(unsatisfiedRequirements::add);
return result.isEmpty();
})) {
return;
}

throw assertionError(elementsShouldSatisfyAny(actual, unsatisfiedRequirements, info));
}

public LongIterableAssert contains(long... values) {
return executeAssertion(() -> {
isNotNull();
Expand Down
Loading
Loading