snuyanzin commented on code in PR #19928:
URL: https://github.com/apache/flink/pull/19928#discussion_r965880237
##########
flink-connectors/flink-connector-gcp-pubsub/src/test/java/org/apache/flink/streaming/connectors/gcp/pubsub/PubSubSourceTest.java:
##########
@@ -66,13 +65,17 @@ public class PubSubSourceTest {
private PubSubSource<String> pubSubSource;
- @Before
- public void setup() throws Exception {
-
when(pubSubSubscriberFactory.getSubscriber(eq(credentials))).thenReturn(pubsubSubscriber);
-
when(streamingRuntimeContext.isCheckpointingEnabled()).thenReturn(true);
- when(streamingRuntimeContext.getMetricGroup()).thenReturn(metricGroup);
- when(metricGroup.addGroup(any(String.class))).thenReturn(metricGroup);
-
when(acknowledgeOnCheckpointFactory.create(any())).thenReturn(acknowledgeOnCheckpoint);
+ @BeforeEach
+ void setup() throws Exception {
+ lenient()
+ .when(pubSubSubscriberFactory.getSubscriber(eq(credentials)))
+ .thenReturn(pubsubSubscriber);
+
lenient().when(streamingRuntimeContext.isCheckpointingEnabled()).thenReturn(true);
+
lenient().when(streamingRuntimeContext.getMetricGroup()).thenReturn(metricGroup);
+
lenient().when(metricGroup.addGroup(any(String.class))).thenReturn(metricGroup);
+ lenient()
+ .when(acknowledgeOnCheckpointFactory.create(any()))
+ .thenReturn(acknowledgeOnCheckpoint);
Review Comment:
It looks like these stubbing methods are not always required for all the
tests
e.g. `when(pubSubSubscriberFactory.getSubscriber(eq(credentials)))
.thenReturn(pubsubSubscriber)` is required only for
`testOpenWithCheckpointing`
for others it fails with `Unnecessary stubbings detected.`
Similar for others. It is strange to me why it didn't fail like that with
JUnit4.
Probably another approach it to move these stubbing to concrete methods
where to leave only required
--
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]