コード例 #1
0
 @Test
 public void testGetLink() {
   MLink testLink = new MLink(123l, null);
   testLink.setEnabled(true);
   MLink mConnectionSpy = org.mockito.Mockito.spy(testLink);
   when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
   when(jdbcRepoMock.findLink(123l)).thenReturn(mConnectionSpy);
   assertEquals(jobManager.getLink(123l), mConnectionSpy);
   verify(repositoryManagerMock, times(1)).getRepository();
   verify(jdbcRepoMock, times(1)).findLink(123l);
 }
コード例 #2
0
  @Test
  public void testDisabledLink() {
    MLink testConnection = new MLink(123l, null);
    testConnection.setPersistenceId(1234);
    testConnection.setEnabled(false);
    SqoopException exception =
        new SqoopException(
            DriverError.DRIVER_0010, "Connection id: " + testConnection.getPersistenceId());

    MLink mConnectionSpy = org.mockito.Mockito.spy(testConnection);
    when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
    when(jdbcRepoMock.findLink(123l)).thenReturn(mConnectionSpy);
    try {
      jobManager.getLink(123l);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repositoryManagerMock, times(1)).getRepository();
      verify(jdbcRepoMock, times(1)).findLink(123l);
    }
  }