use of org.apache.kafka.connect.runtime.distributed.RebalanceNeededException in project kafka by apache.
the class ConnectorsResourceTest method testRestartConnectorAndTasksRebalanceNeeded.
@Test
public void testRestartConnectorAndTasksRebalanceNeeded() {
RestartRequest restartRequest = new RestartRequest(CONNECTOR_NAME, true, false);
final Capture<Callback<ConnectorStateInfo>> cb = Capture.newInstance();
herder.restartConnectorAndTasks(EasyMock.eq(restartRequest), EasyMock.capture(cb));
expectAndCallbackException(cb, new RebalanceNeededException("Request cannot be completed because a rebalance is expected"));
PowerMock.replayAll();
ConnectRestException ex = assertThrows(ConnectRestException.class, () -> connectorsResource.restartConnector(CONNECTOR_NAME, NULL_HEADERS, restartRequest.includeTasks(), restartRequest.onlyFailed(), FORWARD));
assertEquals(Response.Status.CONFLICT.getStatusCode(), ex.statusCode());
PowerMock.verifyAll();
}
Aggregations