doNothing().when(repoHandler).updateConnector(any(MConnector.class), any(Connection.class));
doNothing().when(repoHandler).updateConnection(any(MConnection.class), any(Connection.class));
doReturn(true).when(repoHandler).existsConnection(anyLong(), any(Connection.class));
doReturn(true).when(repoHandler).existsJob(anyLong(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update job error.");
doThrow(exception).when(repoHandler).updateJob(any(MJob.class), any(Connection.class));
try {
repo.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
verify(repoHandler, times(1)).findConnectionsForConnector(anyLong(), any(Connection.class));
verify(repoHandler, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
verify(repoHandler, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
verify(repoHandler, times(2)).deleteConnectionInputs(anyLong(), any(Connection.class));
verify(repoHandler, times(1)).updateConnector(any(MConnector.class), any(Connection.class));
verify(repoHandler, times(2)).existsConnection(anyLong(), any(Connection.class));
verify(repoHandler, times(2)).updateConnection(any(MConnection.class), any(Connection.class));
verify(repoHandler, times(1)).existsJob(anyLong(), any(Connection.class));
verify(repoHandler, times(1)).updateJob(any(MJob.class), any(Connection.class));
verifyNoMoreInteractions(repoHandler);
return ;
}
fail("Should throw out an exception with message: " + exception.getMessage());
}