zhuzhurk commented on code in PR #24475: URL: https://github.com/apache/flink/pull/24475#discussion_r1533318682
########## flink-streaming-java/src/test/java/org/apache/flink/streaming/api/transformations/GetTransitivePredecessorsTest.java: ########## @@ -0,0 +1,147 @@ +/* + * 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.api.transformations; + +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.dag.Transformation; +import org.apache.flink.api.java.typeutils.GenericTypeInfo; +import org.apache.flink.streaming.api.operators.AbstractStreamOperator; +import org.apache.flink.streaming.api.operators.OneInputStreamOperator; +import org.apache.flink.streaming.api.operators.TwoInputStreamOperator; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; +import org.apache.flink.util.TestLogger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** Tests for {@code getTransitivePredecessors} method of {@link Transformation}. */ +class GetTransitivePredecessorsTest extends TestLogger { Review Comment: ` extends TestLogger` is no longer needed since JUnit5. The logging will be enabled automatically. ########## flink-streaming-java/src/test/java/org/apache/flink/streaming/api/transformations/GetTransitivePredecessorsTest.java: ########## @@ -0,0 +1,147 @@ +/* + * 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.api.transformations; + +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.dag.Transformation; +import org.apache.flink.api.java.typeutils.GenericTypeInfo; +import org.apache.flink.streaming.api.operators.AbstractStreamOperator; +import org.apache.flink.streaming.api.operators.OneInputStreamOperator; +import org.apache.flink.streaming.api.operators.TwoInputStreamOperator; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; +import org.apache.flink.util.TestLogger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** Tests for {@code getTransitivePredecessors} method of {@link Transformation}. */ +class GetTransitivePredecessorsTest extends TestLogger { + + private Transformation<Integer> commonNode; + private Transformation<Integer> midNode; + + @BeforeEach + void setup() { + commonNode = new TestTransformation<>("commonNode", new MockIntegerTypeInfo(), 1); + midNode = + new OneInputTransformation<>( + commonNode, + "midNode", + new DummyOneInputOperator(), + new MockIntegerTypeInfo(), + 1); + } + + @Test + void testTwoInputTransformation() { + Transformation<Integer> topNode = + new TwoInputTransformation<>( + commonNode, + midNode, + "topNode", + new DummyTwoInputOperator<>(), + midNode.getOutputType(), + 1); + List<Transformation<?>> predecessors = topNode.getTransitivePredecessors(); + assertThat(predecessors.size()).isEqualTo(3); + assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor()) Review Comment: We may change the definition of `commonNode` as `TestTransformation<?>` as that we do not need to conduct type casting each time. ########## flink-streaming-java/src/test/java/org/apache/flink/streaming/api/transformations/GetTransitivePredecessorsTest.java: ########## @@ -0,0 +1,147 @@ +/* + * 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.api.transformations; + +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.dag.Transformation; +import org.apache.flink.api.java.typeutils.GenericTypeInfo; +import org.apache.flink.streaming.api.operators.AbstractStreamOperator; +import org.apache.flink.streaming.api.operators.OneInputStreamOperator; +import org.apache.flink.streaming.api.operators.TwoInputStreamOperator; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; +import org.apache.flink.util.TestLogger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** Tests for {@code getTransitivePredecessors} method of {@link Transformation}. */ +class GetTransitivePredecessorsTest extends TestLogger { + + private Transformation<Integer> commonNode; + private Transformation<Integer> midNode; + + @BeforeEach + void setup() { + commonNode = new TestTransformation<>("commonNode", new MockIntegerTypeInfo(), 1); + midNode = + new OneInputTransformation<>( + commonNode, + "midNode", + new DummyOneInputOperator(), + new MockIntegerTypeInfo(), + 1); + } + + @Test + void testTwoInputTransformation() { + Transformation<Integer> topNode = + new TwoInputTransformation<>( + commonNode, + midNode, + "topNode", + new DummyTwoInputOperator<>(), + midNode.getOutputType(), + 1); + List<Transformation<?>> predecessors = topNode.getTransitivePredecessors(); + assertThat(predecessors.size()).isEqualTo(3); + assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor()) + .isEqualTo(1); + } + + @Test + void testUnionTransformation() { + Transformation<Integer> topNode = + new UnionTransformation<>(Arrays.asList(commonNode, midNode)); + List<Transformation<?>> predecessors = topNode.getTransitivePredecessors(); + assertThat(predecessors.size()).isEqualTo(3); + assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor()) + .isEqualTo(1); + } + + @Test + void testBroadcastStateTransformation() { + Transformation<Integer> topNode = + new AbstractBroadcastStateTransformation<>( + "topNode", commonNode, midNode, null, midNode.getOutputType(), 1); + List<Transformation<?>> predecessors = topNode.getTransitivePredecessors(); + assertThat(predecessors.size()).isEqualTo(3); + assertThat(((TestTransformation<?>) commonNode).getNumGetTransitivePredecessor()) + .isEqualTo(0); + } Review Comment: Maybe one more test case for `AbstractMultipleInputTransformation`? ########## flink-core/src/test/java/org/apache/flink/api/dag/TransformationTest.java: ########## @@ -24,32 +24,30 @@ import org.apache.flink.core.testutils.OneShotLatch; import org.apache.flink.util.TestLogger; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** Tests for {@link Transformation}. */ -public class TransformationTest extends TestLogger { +class TransformationTest extends TestLogger { Review Comment: `extends TestLogger` is no longer needed after migrating to JUnit5. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org