pnowojski commented on a change in pull request #7570: [FLINK-11422] Prefer 
testing class to mock StreamTask in AbstractStre…
URL: https://github.com/apache/flink/pull/7570#discussion_r251916174
 
 

 ##########
 File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/util/MockStreamTaskBuilder.java
 ##########
 @@ -0,0 +1,146 @@
+/*
+ * 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.flink.streaming.util;
+
+import org.apache.flink.api.common.ExecutionConfig;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.accumulators.Accumulator;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.fs.CloseableRegistry;
+import org.apache.flink.runtime.execution.Environment;
+import org.apache.flink.runtime.state.CheckpointStorage;
+import org.apache.flink.runtime.state.StateBackend;
+import org.apache.flink.runtime.state.memory.MemoryStateBackend;
+import org.apache.flink.streaming.api.graph.StreamConfig;
+import org.apache.flink.streaming.api.operators.MockStreamStatusMaintainer;
+import org.apache.flink.streaming.api.operators.StreamTaskStateInitializer;
+import org.apache.flink.streaming.api.operators.StreamTaskStateInitializerImpl;
+import org.apache.flink.streaming.runtime.streamstatus.StreamStatusMaintainer;
+import org.apache.flink.streaming.runtime.tasks.ProcessingTimeService;
+import org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.function.BiConsumer;
+
+/**
+ * A builder of {@link MockStreamTask}.
+ */
+public class MockStreamTaskBuilder {
+       private final Environment environment;
+       private String name;
+       private Object checkpointLock;
+       private StreamConfig config;
+       private ExecutionConfig executionConfig;
+       private CloseableRegistry closableRegistry;
+       private StreamStatusMaintainer streamStatusMaintainer;
+       private CheckpointStorage checkpointStorage;
+       private ProcessingTimeService processingTimeService;
+       private StreamTaskStateInitializer streamTaskStateInitializer;
+       private BiConsumer<String, Throwable> handleAsyncException;
+       private Map<String, Accumulator<?, ?>> accumulatorMap;
+
+       public MockStreamTaskBuilder(Environment environment) throws Exception {
+               // obligatory parameters
+               this.environment = environment;
+
+               // default values
 
 Review comment:
   nit: you could inline the default values with the fields definitions like
   ```
   private String name = "Mock Task"
   ```
   it would simplify/shorten the code by ~15 lines.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to