DonalEvans commented on a change in pull request #7284:
URL: https://github.com/apache/geode/pull/7284#discussion_r788165891



##########
File path: 
geode-for-redis/src/integrationTest/java/org/apache/geode/redis/internal/commands/executor/set/AbstractSUnionStoreIntegrationTest.java
##########
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.redis.internal.commands.executor.set;
+
+import static 
org.apache.geode.redis.RedisCommandArgumentsTestHelper.assertAtLeastNArgs;
+import static 
org.apache.geode.redis.internal.RedisConstants.ERROR_DIFFERENT_SLOTS;
+import static org.apache.geode.redis.internal.RedisConstants.ERROR_WRONG_TYPE;
+import static 
org.apache.geode.test.dunit.rules.RedisClusterStartupRule.BIND_ADDRESS;
+import static 
org.apache.geode.test.dunit.rules.RedisClusterStartupRule.REDIS_CLIENT_TIMEOUT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import redis.clients.jedis.HostAndPort;
+import redis.clients.jedis.JedisCluster;
+import redis.clients.jedis.Protocol;
+
+import org.apache.geode.redis.ConcurrentLoopingThreads;
+import org.apache.geode.redis.RedisIntegrationTest;
+
+public abstract class AbstractSUnionStoreIntegrationTest implements 
RedisIntegrationTest {
+  private JedisCluster jedis;
+  private static final String DESTINATION_KEY = "{tag1}destinationKey";
+  private static final String[] DESTINATION_MEMBERS =
+      {"six", "seven", "eight", "nine", "ten", "one", "two"};
+  private static final String SET_KEY_1 = "{tag1}setKey1";
+  private static final String[] SET_MEMBERS_1 = {"one", "two", "three", 
"four", "five"};
+  private static final String NON_EXISTENT_SET = "{tag1}nonExistentSet";
+  private static final String SET_KEY_2 = "{tag1}setKey2";
+
+  @Before
+  public void setUp() {
+    jedis = new JedisCluster(new HostAndPort(BIND_ADDRESS, getPort()), 
REDIS_CLIENT_TIMEOUT);
+  }
+
+  @After
+  public void tearDown() {
+    flushAll();
+    jedis.close();
+  }
+
+  @Test
+  public void sunionstore_givenTooFewArguments_returnsError() {
+    assertAtLeastNArgs(jedis, Protocol.Command.SUNION, 1);
+  }
+
+  @Test
+  public void 
sunionstore_withNonExistentDest_withExistentSet_returnsUnionSize_storesUnion() {
+    jedis.sadd(SET_KEY_1, SET_MEMBERS_1);
+    assertThat(jedis.sunionstore(DESTINATION_KEY, 
SET_KEY_1)).isEqualTo(SET_MEMBERS_1.length);
+    
assertThat(jedis.smembers(DESTINATION_KEY)).containsExactlyInAnyOrder(SET_MEMBERS_1);
+  }
+
+  @Test
+  public void 
sunionstore_withNonExistentDest_withNonExistentSet_returnsZero_destKeyDoesNotExist()
 {
+    assertThat(jedis.sunionstore(DESTINATION_KEY, 
NON_EXISTENT_SET)).isEqualTo(0);
+    assertThat(jedis.exists(DESTINATION_KEY)).isFalse();
+  }
+
+  @Test
+  public void 
sunionstore_withNonExistentDest_withOneExistentAndOneNonExistentSet_returnsUnionSize_storesUnion()
 {
+    jedis.sadd(SET_KEY_1, SET_MEMBERS_1);
+    assertThat(jedis.sunionstore(DESTINATION_KEY, SET_KEY_1, NON_EXISTENT_SET))
+        .isEqualTo(SET_MEMBERS_1.length);
+    
assertThat(jedis.smembers(DESTINATION_KEY)).containsExactlyInAnyOrder(SET_MEMBERS_1);
+  }
+
+  @Test
+  public void 
sunionstore_withNonExistentDest_withOneNonExistentAndOneExistentSet_returnsUnionSize_storesUnion()
 {

Review comment:
       I think for these tests it's not really relevant to the behaviour we're 
testing, so that detail can be omitted.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to