Github user StefanRRichter commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5239#discussion_r162585199
  
    --- Diff: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/util/AbstractStreamOperatorTestHarness.java
 ---
    @@ -132,32 +141,49 @@ public AbstractStreamOperatorTestHarness(
                                1024,
                                new Configuration(),
                                new ExecutionConfig(),
    +                           new TestTaskStateManager(),
                                maxParallelism,
                                parallelism,
                                subtaskIndex));
        }
     
        public AbstractStreamOperatorTestHarness(
                        StreamOperator<OUT> operator,
    -                   final Environment environment) throws Exception {
    +                   Environment env) throws Exception {
                this.operator = operator;
                this.outputList = new ConcurrentLinkedQueue<>();
                this.sideOutputLists = new HashMap<>();
     
    -           Configuration underlyingConfig = 
environment.getTaskConfiguration();
    +           Configuration underlyingConfig = env.getTaskConfiguration();
                this.config = new StreamConfig(underlyingConfig);
                this.config.setCheckpointingEnabled(true);
                this.config.setOperatorID(new OperatorID());
    -           this.executionConfig = environment.getExecutionConfig();
    +           this.executionConfig = env.getExecutionConfig();
                this.closableRegistry = new CloseableRegistry();
                this.checkpointLock = new Object();
     
    -           this.environment = Preconditions.checkNotNull(environment);
    +           Preconditions.checkNotNull(env);
    +
    +           MockUtil mockUtil = new MockUtil();
    +
    +           if (!mockUtil.isMock(env) && !mockUtil.isSpy(env)) {
    +                   env = spy(env);
    +           }
    +
    +           this.environment = env;
    +
    +           this.taskStateManager = new TestTaskStateManager(
    +                   env.getJobID(),
    +                   env.getExecutionId());
    +
    +           
when(this.environment.getTaskStateManager()).thenReturn(this.taskStateManager);
    --- End diff --
    
    👍 I made all tests use the `MockEnvironment`.


---

Reply via email to