doReturn(connectionList).when(repoHandler).findConnectionsForConnector(anyLong(), any(Connection.class));
doReturn(jobList).when(repoHandler).findJobsForConnector(anyLong(), any(Connection.class));
doNothing().when(repoHandler).deleteJobInputs(anyLong(), any(Connection.class));
doNothing().when(repoHandler).deleteConnectionInputs(anyLong(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update connector error.");
doThrow(exception).when(repoHandler).updateConnector(any(MConnector.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));
verifyNoMoreInteractions(repoHandler);
return ;
}
fail("Should throw out an exception with message: " + exception.getMessage());
}