Skip to content

Commit bebdda7

Browse files
committed
Add intersectSize test for SINTERCARD operation in DefaultReactiveSetOperationsIntegrationTests
Signed-off-by: Kiminni <imk0980@gmail.com>
1 parent 5b32dee commit bebdda7

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/test/java/org/springframework/data/redis/core/DefaultReactiveSetOperationsIntegrationTests.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*
4141
* @author Mark Paluch
4242
* @author Christoph Strobl
43+
* @author Mingi Lee
4344
*/
4445
@ParameterizedClass
4546
@MethodSource("testParams")
@@ -230,6 +231,39 @@ void intersectAndStore() {
230231
setOperations.isMember(destKey, shared).as(StepVerifier::create).expectNext(true).verifyComplete();
231232
}
232233

234+
@Test
235+
@EnabledOnCommand("SINTERCARD")
236+
void intersectSize() {
237+
238+
K key = keyFactory.instance();
239+
K otherKey = keyFactory.instance();
240+
K thirdKey = keyFactory.instance();
241+
242+
V onlyInKey = valueFactory.instance();
243+
V shared1 = valueFactory.instance();
244+
V shared2 = valueFactory.instance();
245+
V onlyInOtherKey = valueFactory.instance();
246+
247+
setOperations.add(key, onlyInKey, shared1, shared2).as(StepVerifier::create).expectNext(3L).verifyComplete();
248+
setOperations.add(otherKey, onlyInOtherKey, shared1, shared2).as(StepVerifier::create).expectNext(3L)
249+
.verifyComplete();
250+
setOperations.add(thirdKey, shared1).as(StepVerifier::create).expectNext(1L).verifyComplete();
251+
252+
// Test intersectSize(key, otherKey)
253+
setOperations.intersectSize(key, otherKey).as(StepVerifier::create).expectNext(2L).verifyComplete();
254+
255+
// Test intersectSize(key, Collection)
256+
setOperations.intersectSize(key, Arrays.asList(otherKey)).as(StepVerifier::create).expectNext(2L).verifyComplete();
257+
258+
// Test intersectSize(Collection) with multiple keys
259+
setOperations.intersectSize(Arrays.asList(key, otherKey, thirdKey)).as(StepVerifier::create).expectNext(1L)
260+
.verifyComplete();
261+
262+
// Test with empty intersection
263+
K emptyKey = keyFactory.instance();
264+
setOperations.intersectSize(key, emptyKey).as(StepVerifier::create).expectNext(0L).verifyComplete();
265+
}
266+
233267
@Test // DATAREDIS-602, DATAREDIS-873
234268
void difference() {
235269

0 commit comments

Comments
 (0)