mdedetrich commented on code in PR #12728: URL: https://github.com/apache/kafka/pull/12728#discussion_r1389049719
########## connect/runtime/src/test/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerderTest.java: ########## @@ -838,39 +733,32 @@ public void testPutConnectorConfig() throws Exception { Map<String, String> newConnConfig = new HashMap<>(connConfig); newConnConfig.put("foo", "bar"); - Callback<Map<String, String>> connectorConfigCb = PowerMock.createMock(Callback.class); - // Callback<Herder.Created<ConnectorInfo>> putConnectorConfigCb = PowerMock.createMock(Callback.class); + Callback<Map<String, String>> connectorConfigCb = mock(Callback.class); // Create - connector = PowerMock.createMock(BogusSourceConnector.class); + connector = mock(BogusSourceConnector.class); expectAdd(SourceSink.SOURCE); - Connector connectorMock = PowerMock.createMock(SourceConnector.class); + Connector connectorMock = mock(SourceConnector.class); expectConfigValidation(connectorMock, true, connConfig); // Should get first config - connectorConfigCb.onCompletion(null, connConfig); - EasyMock.expectLastCall(); + doNothing().when(connectorConfigCb).onCompletion(null, connConfig); // Update config, which requires stopping and restarting - worker.stopAndAwaitConnector(CONNECTOR_NAME); - EasyMock.expectLastCall(); - Capture<Map<String, String>> capturedConfig = EasyMock.newCapture(); - Capture<Callback<TargetState>> onStart = EasyMock.newCapture(); - worker.startConnector(eq(CONNECTOR_NAME), EasyMock.capture(capturedConfig), EasyMock.anyObject(), - eq(herder), eq(TargetState.STARTED), EasyMock.capture(onStart)); - EasyMock.expectLastCall().andAnswer(() -> { + doNothing().when(worker).stopAndAwaitConnector(CONNECTOR_NAME); + final ArgumentCaptor<Map<String, String>> capturedConfig = ArgumentCaptor.forClass(Map.class); + final ArgumentCaptor<Callback<TargetState>> onStart = ArgumentCaptor.forClass(Callback.class); + doAnswer(invocation -> { onStart.getValue().onCompletion(null, TargetState.STARTED); return true; - }); + }).when(worker).startConnector(eq(CONNECTOR_NAME), capturedConfig.capture(), any(), + eq(herder), eq(TargetState.STARTED), onStart.capture()); // Generate same task config, which should result in no additional action to restart tasks - EasyMock.expect(worker.connectorTaskConfigs(CONNECTOR_NAME, new SourceConnectorConfig(plugins, newConnConfig, true))) - .andReturn(singletonList(taskConfig(SourceSink.SOURCE))); + when(worker.connectorTaskConfigs(CONNECTOR_NAME, new SourceConnectorConfig(plugins, newConnConfig, true))) + .thenReturn(singletonList(taskConfig(SourceSink.SOURCE))); expectConfigValidation(connectorMock, false, newConnConfig); - connectorConfigCb.onCompletion(null, newConnConfig); - EasyMock.expectLastCall(); - EasyMock.expect(worker.getPlugins()).andReturn(plugins).anyTimes(); - - PowerMock.replayAll(); + doNothing().when(connectorConfigCb).onCompletion(null, newConnConfig); Review Comment: Done and pushed. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org