|
|
|
@ -7,6 +7,7 @@ import java.util.HashSet;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.*;
|
|
|
|
|
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
@ -126,7 +127,7 @@ public class RedissonSetReactiveTest extends BaseReactiveTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkIterator(RSetReactive<Long> set, Set<Long> setCopy) {
|
|
|
|
|
for (Iterator<Long> iterator = toIterator(set.iterator()); iterator.hasNext();) {
|
|
|
|
|
for (Iterator<Long> iterator = toIterator(set.iterator()); iterator.hasNext(); ) {
|
|
|
|
|
Long value = iterator.next();
|
|
|
|
|
if (!setCopy.remove(value)) {
|
|
|
|
|
Assert.fail();
|
|
|
|
@ -265,4 +266,30 @@ public class RedissonSetReactiveTest extends BaseReactiveTest {
|
|
|
|
|
Assert.assertEquals(1, sync(set.size()).intValue());
|
|
|
|
|
Assert.assertEquals(0, sync(otherSet.size()).intValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testIntersection() {
|
|
|
|
|
final String firstSetName = "firstSet";
|
|
|
|
|
RSetReactive<Integer> firstSet = redisson.getSet(firstSetName);
|
|
|
|
|
|
|
|
|
|
sync(firstSet.add(1));
|
|
|
|
|
sync(firstSet.add(2));
|
|
|
|
|
sync(firstSet.add(3));
|
|
|
|
|
|
|
|
|
|
final String secondSetName = "secondSet";
|
|
|
|
|
RSetReactive<Integer> secondSet = redisson.getSet(secondSetName);
|
|
|
|
|
|
|
|
|
|
sync(secondSet.add(3));
|
|
|
|
|
sync(secondSet.add(4));
|
|
|
|
|
sync(secondSet.add(1));
|
|
|
|
|
|
|
|
|
|
final RSetReactive<Object> tmp = redisson.getSet("tmp");
|
|
|
|
|
|
|
|
|
|
final Integer count = sync(tmp.intersection(firstSetName, secondSetName));
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(2, count.intValue());
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(sync(tmp.contains(1)));
|
|
|
|
|
Assert.assertTrue(sync(tmp.contains(3)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|