[
https://issues.apache.org/jira/browse/GEODE-8864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17295376#comment-17295376
]
ASF GitHub Bot commented on GEODE-8864:
---------------------------------------
jhutchison commented on a change in pull request #5954:
URL: https://github.com/apache/geode/pull/5954#discussion_r587599646
##########
File path:
geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/hash/HScanIntegrationTest.java
##########
@@ -37,22 +44,58 @@ public int getPort() {
return server.getPort();
}
+
+ // Note: these tests will not pass native redis, so included here in
concrete test class
+ @Test
+ public void givenCursorGreaterThanIntMaxValue_returnsCursorError() {
+ int largestCursorValue = Integer.MAX_VALUE;
+
+ BigInteger tooBigCursor =
+ new
BigInteger(String.valueOf(largestCursorValue)).add(BigInteger.valueOf(1));
+
+ assertThatThrownBy(() -> jedis.hscan("a", tooBigCursor.toString()))
+ .hasMessageContaining(ERROR_CURSOR);
+ }
+
+ @Test
+ public void givenCursorLessThanIntMinValue_returnsCursorError() {
+ int smallestCursorValue = Integer.MIN_VALUE;
+
+ BigInteger tooSmallCursor =
+ new
BigInteger(String.valueOf(smallestCursorValue)).subtract(BigInteger.valueOf(1));
+
+ assertThatThrownBy(() -> jedis.hscan("a", tooSmallCursor.toString()))
+ .hasMessageContaining(ERROR_CURSOR);
+ }
+
+
@Test
- public void
givenDifferentCursorThanSpecifiedByPreviousHscan_returnsAllEntries() {
+ public void givenCount_shouldReturnsExpectedNumberOfEntries() {
Map<String, String> entryMap = new HashMap<>();
- for (int i = 0; i < 10; i++) {
- entryMap.put(String.valueOf(i), String.valueOf(i));
- }
- jedis.hmset("a", entryMap);
+ entryMap.put("1", "yellow");
+ entryMap.put("2", "green");
+ entryMap.put("3", "orange");
+ jedis.hmset("colors", entryMap);
+
+ int COUNT_PARAM = 2;
ScanParams scanParams = new ScanParams();
- scanParams.count(5);
- ScanResult<Map.Entry<String, String>> result = jedis.hscan("a", "0",
scanParams);
- assertThat(result.isCompleteIteration()).isFalse();
+ scanParams.count(COUNT_PARAM);
+ ScanResult<Map.Entry<String, String>> result;
+
+ List<Map.Entry<String, String>> allEntries = new ArrayList<>();
+ String cursor = "0";
- result = jedis.hscan("a", "100");
+ result = jedis.hscan("colors", cursor, scanParams);
+ allEntries.addAll(result.getResult());
- assertThat(result.getResult()).hasSize(10);
- assertThat(new
HashSet<>(result.getResult())).isEqualTo(entryMap.entrySet());
+ List<Map.Entry<String, String>> allDistinctEntries =
+ allEntries
+ .stream()
+ .distinct()
+ .collect(Collectors.toList());
+
+ assertThat(allDistinctEntries.size()).isEqualTo(COUNT_PARAM);
Review comment:
Yeah, I'm hesitant to read too much into the exactness of what the count
parameter does. as per docs (as I'm sure you've read) " Basically with COUNT
the user specified the amount of work that should be done at every call in
order to retrieve elements from the collection. This is just a hint for the
implementation, however generally speaking this is what you could expect most
of the times from the implementation." which, I think, is what makes it a
little confusing to know how to test. I'll remove the removal of the
duplicates, though
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
> finish implementation of Redis HScan Command
> --------------------------------------------
>
> Key: GEODE-8864
> URL: https://issues.apache.org/jira/browse/GEODE-8864
> Project: Geode
> Issue Type: New Feature
> Components: redis
> Reporter: John Hutchison
> Priority: Major
> Labels: blocks-1.14.0, pull-request-available
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)