liuliuOD commented on code in PR #24015:
URL: https://github.com/apache/kafka/pull/24015#discussion_r4420791462
##########
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableImplTest.java:
##########
@@ -656,4 +661,20 @@ public void
shouldThrowNullPointerOnTransformValuesWithKeyWhenStoreNamesNull(fin
setDslStoreFormat(withHeaders);
assertThrows(NullPointerException.class, () ->
table.transformValues(mock(), (String[]) null));
}
+
+ @Test
+ public void shouldUseForeignKeyJoinResponsePartitionWhenValid() {
+ final KTableImpl.DefaultForeignResponseSinkPartitioner<String, String>
partitioner = new KTableImpl.DefaultForeignResponseSinkPartitioner<>();
+ assertEquals(Optional.of(Set.of(0)), partitioner.partitions("topic",
"key", new SubscriptionResponseWrapper<>(null, "value", 0), new
RecordHeaders(), 3));
+ assertEquals(Optional.of(Set.of(2)), partitioner.partitions("topic",
"key", new SubscriptionResponseWrapper<>(null, "value", 2), new
RecordHeaders(), 3));
+ assertEquals(Optional.empty(), partitioner.partitions("topic", "key",
new SubscriptionResponseWrapper<>(null, "value", null), new RecordHeaders(),
3));
+ }
+
+ @Test
+ public void
shouldUseDefaultPartitionerForInvalidForeignKeyJoinResponsePartition() {
+ final KTableImpl.DefaultForeignResponseSinkPartitioner<String, String>
partitioner = new KTableImpl.DefaultForeignResponseSinkPartitioner<>();
+ assertEquals(Optional.empty(), partitioner.partitions("topic", "key",
new SubscriptionResponseWrapper<>(null, "value", -1), new RecordHeaders(), 3));
+ assertEquals(Optional.empty(), partitioner.partitions("topic", "key",
new SubscriptionResponseWrapper<>(null, "value", 3), new RecordHeaders(), 3));
+ assertEquals(Optional.empty(), partitioner.partitions("topic", "key",
new SubscriptionResponseWrapper<>(null, "value", Integer.MAX_VALUE), new
RecordHeaders(), 3));
+ }
Review Comment:
Optional: could we make both tests parameterized? That would report each
partition value as a separate case.
--
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]