mjsax commented on code in PR #22725:
URL: https://github.com/apache/kafka/pull/22725#discussion_r3618618083
##########
streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriverBuilder.java:
##########
@@ -75,14 +83,43 @@ public TopologyTestDriverBuilder
withInitialWallClockTime(final Instant initialW
}
/**
- * Build the driver: construct it and apply all declared topic partition
counts.
+ * Declare the number of partitions for an input, output, or internal
repartition topic.
+ *
+ * @param topicName the topic to declare
+ * @param partitions the number of partitions (must be at least 1)
+ * @return this builder
+ * @throws IllegalArgumentException if {@code partitions} is less than 1,
or the topic was already
+ * declared with a different count
+ */
+ public TopologyTestDriverBuilder declareTopic(final String topicName,
final int partitions) {
+ Objects.requireNonNull(topicName, "topicName cannot be null");
+ if (partitions < 1) {
+ throw new IllegalArgumentException(
+ "Partition count must be at least 1 (topic='" + topicName +
"', partitions=" + partitions + ").");
+ }
+ final Integer existing = declaredTopics.putIfAbsent(topicName,
partitions);
+ if (existing != null && existing != partitions) {
+ throw new IllegalArgumentException(
Review Comment:
SGTM. (Yes, it's mainly about consistency.)
--
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]