sebastienviale commented on code in PR #22673: URL: https://github.com/apache/kafka/pull/22673#discussion_r3499684835
########## streams/test-utils/src/main/java/org/apache/kafka/streams/TopologyTestDriverBuilder.java: ########## @@ -0,0 +1,91 @@ +/* + * 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.kafka.streams; + +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Properties; + +/** + * Fluent builder for a {@link TopologyTestDriver}. + * + * <p>This is the entry point for constructing a {@link TopologyTestDriver}. + * Configure the builder, optionally declare topic partition counts, and call {@link #build()}. + * The {@link TopologyTestDriver} constructors remain functional but are deprecated in favor of + * this builder.</p> + * + * <pre>{@code + * TopologyTestDriver driver = new TopologyTestDriverBuilder(topology) + * .withConfig(props) + * .withInitialWallClockTime(Instant.ofEpochMilli(0)) + * .build(); + * }</pre> + */ +public class TopologyTestDriverBuilder { + + private final Topology topology; + private final Map<String, Integer> declaredTopics = new LinkedHashMap<>(); + private Properties config = new Properties(); + private Optional<Instant> initialWallClockTime = Optional.empty(); + + /** + * Start building a driver for the given topology. + * + * @param topology the topology to be tested + */ + public TopologyTestDriverBuilder(final Topology topology) { + this.topology = Objects.requireNonNull(topology, "topology cannot be null"); + } + + /** + * Set the configuration passed to the driver. Optional; defaults to empty {@link Properties}. + * + * @param config the configuration for the topology + * @return this builder + */ + public TopologyTestDriverBuilder withConfig(final Properties config) { + this.config = config; + return this; + } Review Comment: done, I added a unit test too -- 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]
