package disjointsets; import org.assertj.core.api.AbstractListAssert; import org.assertj.core.api.AbstractObjectAssert; import org.assertj.core.api.ObjectAssert; import java.util.Arrays; import java.util.function.Function; public class DisjointSetsAssert extends AbstractObjectAssert, DisjointSets> { public DisjointSetsAssert(DisjointSets disjointSets) { super(disjointSets, DisjointSetsAssert.class); } @SafeVarargs public final AbstractListAssert, Object, ObjectAssert> findingSets(T... items) { @SuppressWarnings("unchecked") Function, Integer>[] ids = Arrays.stream(items) .map(i -> (Function, Integer>) actual -> actual.findSet(i)) .toArray(value -> (Function, Integer>[]) new Function[value]); return extracting(ids).as("set ids of %s", Arrays.toString(items)); } }