mjsax commented on code in PR #14570:
URL: https://github.com/apache/kafka/pull/14570#discussion_r1399617212


##########
streams/src/test/java/org/apache/kafka/streams/integration/IQv2StoreIntegrationTest.java:
##########
@@ -1584,7 +1646,43 @@ public <V> void shouldHandleKeyQuery(
         );
 
         final V result1 = queryResult.getResult();
-        final Integer integer = valueExtactor.apply(result1);
+        final Integer integer = (Integer) result1;
+        assertThat(integer, is(expectedValue));
+        assertThat(queryResult.getExecutionInfo(), is(empty()));
+        assertThat(queryResult.getPosition(), is(POSITION_0));
+    }
+
+    public <V> void shouldHandleTimestampedKeyQuery(
+            final Integer key,
+            final Integer expectedValue) {

Review Comment:
   I think we should pass in `ValueAndTimestamp` as expected result and also 
verify that we get the correct timestamp back. (Also rename `expectedValue` to 
`expectedValueAndTimestamp`.)



##########
streams/src/test/java/org/apache/kafka/streams/integration/IQv2StoreIntegrationTest.java:
##########
@@ -1584,7 +1646,43 @@ public <V> void shouldHandleKeyQuery(
         );
 
         final V result1 = queryResult.getResult();
-        final Integer integer = valueExtactor.apply(result1);
+        final Integer integer = (Integer) result1;
+        assertThat(integer, is(expectedValue));
+        assertThat(queryResult.getExecutionInfo(), is(empty()));
+        assertThat(queryResult.getPosition(), is(POSITION_0));
+    }
+
+    public <V> void shouldHandleTimestampedKeyQuery(
+            final Integer key,
+            final Integer expectedValue) {
+
+        final TimestampedKeyQuery<Integer, V> query = 
TimestampedKeyQuery.withKey(key);
+        final StateQueryRequest<ValueAndTimestamp<V>> request =
+                inStore(STORE_NAME)
+                        .withQuery(query)
+                        .withPartitions(mkSet(0, 1))
+                        .withPositionBound(PositionBound.at(INPUT_POSITION));
+
+        final StateQueryResult<ValueAndTimestamp<V>> result =
+                IntegrationTestUtils.iqv2WaitForResult(kafkaStreams, request);
+        final QueryResult<ValueAndTimestamp<V>> queryResult = 
result.getOnlyPartitionResult();
+        if (queryResult == null) {
+            throw new AssertionError("cannot use this query type to query 
result");
+        }
+        final boolean failure = queryResult.isFailure();
+        if (failure) {
+            throw new AssertionError(queryResult.toString());
+        }
+        assertThat(queryResult.isSuccess(), is(true));
+
+        assertThrows(IllegalArgumentException.class, 
queryResult::getFailureReason);
+        assertThrows(
+                IllegalArgumentException.class,
+                queryResult::getFailureMessage
+        );
+
+        final ValueAndTimestamp<V> result1 = queryResult.getResult();

Review Comment:
   `result1` is a very bad name. Rename to `valueAndTimestamp`.



##########
streams/src/test/java/org/apache/kafka/streams/integration/IQv2StoreIntegrationTest.java:
##########
@@ -1584,7 +1646,43 @@ public <V> void shouldHandleKeyQuery(
         );
 
         final V result1 = queryResult.getResult();
-        final Integer integer = valueExtactor.apply(result1);
+        final Integer integer = (Integer) result1;
+        assertThat(integer, is(expectedValue));
+        assertThat(queryResult.getExecutionInfo(), is(empty()));
+        assertThat(queryResult.getPosition(), is(POSITION_0));
+    }
+
+    public <V> void shouldHandleTimestampedKeyQuery(
+            final Integer key,
+            final Integer expectedValue) {
+
+        final TimestampedKeyQuery<Integer, V> query = 
TimestampedKeyQuery.withKey(key);
+        final StateQueryRequest<ValueAndTimestamp<V>> request =
+                inStore(STORE_NAME)
+                        .withQuery(query)
+                        .withPartitions(mkSet(0, 1))
+                        .withPositionBound(PositionBound.at(INPUT_POSITION));
+
+        final StateQueryResult<ValueAndTimestamp<V>> result =
+                IntegrationTestUtils.iqv2WaitForResult(kafkaStreams, request);
+        final QueryResult<ValueAndTimestamp<V>> queryResult = 
result.getOnlyPartitionResult();
+        if (queryResult == null) {
+            throw new AssertionError("cannot use this query type to query 
result");
+        }
+        final boolean failure = queryResult.isFailure();
+        if (failure) {
+            throw new AssertionError(queryResult.toString());
+        }
+        assertThat(queryResult.isSuccess(), is(true));
+
+        assertThrows(IllegalArgumentException.class, 
queryResult::getFailureReason);
+        assertThrows(
+                IllegalArgumentException.class,
+                queryResult::getFailureMessage
+        );
+
+        final ValueAndTimestamp<V> result1 = queryResult.getResult();
+        final Integer integer = (Integer) result1.value();
         assertThat(integer, is(expectedValue));

Review Comment:
   Cf my comments above: I think this can just `  assertThat(valueAndTimestamp, 
is(expectedValueAndTimestamp));`



##########
streams/src/test/java/org/apache/kafka/streams/integration/IQv2StoreIntegrationTest.java:
##########
@@ -1632,10 +1729,65 @@ public <V> void shouldHandleRangeQuery(
                     IllegalArgumentException.class,
                     queryResult.get(partition)::getFailureMessage
                 );
-
                 try (final KeyValueIterator<Integer, V> iterator = 
queryResult.get(partition).getResult()) {
                     while (iterator.hasNext()) {
-                        
actualValues.add(valueExtactor.apply(iterator.next().value));
+                        actualValues.add((Integer) iterator.next().value);
+                    }
+                }
+                assertThat(queryResult.get(partition).getExecutionInfo(), 
is(empty()));
+            }
+            assertThat("Result:" + result, actualValues, is(expectedValues));
+            assertThat("Result:" + result, result.getPosition(), 
is(INPUT_POSITION));
+        }
+    }
+
+    public <V> void shouldHandleTimestampedRangeQuery(
+        final Optional<Integer> lower,
+        final Optional<Integer> upper,
+        final boolean isKeyAscending,
+        final List<Integer> expectedValues) {

Review Comment:
   Similar to above. We should expect a list of `ValueAndTimestamp` to also 
verify the ts we get back.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to