jdeppe-pivotal commented on a change in pull request #6738: URL: https://github.com/apache/geode/pull/6738#discussion_r690760595
########## File path: geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/sortedset/AbstractZPopMinIntegrationTest.java ########## @@ -0,0 +1,157 @@ +/* + * 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.executor.sortedset; + +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.ArrayList; +import java.util.Collections; +import java.util.List; + +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 redis.clients.jedis.Tuple; + +import org.apache.geode.redis.RedisIntegrationTest; +import org.apache.geode.redis.internal.RedisConstants; + +public abstract class AbstractZPopMinIntegrationTest implements RedisIntegrationTest { + private JedisCluster jedis; + + @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 shouldError_givenWrongNumberOfArguments() { + assertThatThrownBy( + () -> jedis.sendCommand("key", Protocol.Command.ZPOPMIN, "key", "1", "2")) + .hasMessageContaining(RedisConstants.ERROR_SYNTAX); Review comment: Done. ########## File path: geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/SupportedCommandsJUnitTest.java ########## @@ -91,6 +91,7 @@ "ZINCRBY", "ZCARD", "ZCOUNT", + "ZPOPMIN", Review comment: Done ########## File path: geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractHitsMissesIntegrationTest.java ########## @@ -252,6 +252,11 @@ public void testZIncrBy() { runCommandAndAssertNoStatUpdates("key", (k, m) -> jedis.zincrby(k, 100.0, m)); } + @Test + public void testZPopMin() { Review comment: Done ########## File path: geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/data/RedisSortedSetTest.java ########## @@ -473,6 +473,70 @@ public void memberDummyOrderedSetEntryCompareTo_withEqualMemberNamesAndInclusive assertThat(inclusiveMax.compareTo(realEntry)).isEqualTo(1); } + @Test + public void zpopminRemovesMemberWithLowestScore() { + int originalSize = rangeSortedSet.getSortedSetSize(); + RedisSortedSet sortedSet = spy(rangeSortedSet); + Region<RedisKey, RedisData> region = uncheckedCast(mock(Region.class)); + RedisKey key = new RedisKey(); + int count = 1; + + List<byte[]> result = sortedSet.zpopmin(region, key, count); + assertThat(result).containsExactly("member1".getBytes(), "1".getBytes()); + + ArgumentCaptor<RemsDeltaInfo> argumentCaptor = ArgumentCaptor.forClass(RemsDeltaInfo.class); + verify(sortedSet).storeChanges(eq(region), eq(key), argumentCaptor.capture()); + assertThat(argumentCaptor.getValue().getRemoves()).containsExactly("member1".getBytes()); + assertThat(rangeSortedSet.getSortedSetSize()).isEqualTo(originalSize - count); + } + + @Test + public void zpopminRemovesMembersWithHighestScores_whenCountIsGreaterThanOne() { Review comment: Done. ########## File path: geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/sortedset/AbstractZPopMinIntegrationTest.java ########## @@ -0,0 +1,157 @@ +/* + * 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.executor.sortedset; + +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.ArrayList; +import java.util.Collections; +import java.util.List; + +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 redis.clients.jedis.Tuple; + +import org.apache.geode.redis.RedisIntegrationTest; +import org.apache.geode.redis.internal.RedisConstants; + +public abstract class AbstractZPopMinIntegrationTest implements RedisIntegrationTest { Review comment: Done. -- 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]
