예제 #1
0
 @Test
 public void testGetJob() {
   MJob testJob = job(123l, 456l);
   testJob.setEnabled(true);
   MJob mJobSpy = org.mockito.Mockito.spy(testJob);
   when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
   when(jdbcRepoMock.findJob(123l)).thenReturn(mJobSpy);
   assertEquals(jobManager.getJob(123l), mJobSpy);
   verify(repositoryManagerMock, times(1)).getRepository();
   verify(jdbcRepoMock, times(1)).findJob(123l);
 }
예제 #2
0
  @Test
  public void testDisabledJob() {
    MJob testJob = job(123l, 456l);
    testJob.setEnabled(false);
    testJob.setPersistenceId(1111);
    SqoopException exception =
        new SqoopException(DriverError.DRIVER_0009, "Job id: " + testJob.getPersistenceId());

    MJob mJobSpy = org.mockito.Mockito.spy(testJob);
    when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
    when(jdbcRepoMock.findJob(123l)).thenReturn(mJobSpy);
    try {
      jobManager.getJob(123l);
    } catch (SqoopException ex) {
      assertEquals(ex.getMessage(), exception.getMessage());
      verify(repositoryManagerMock, times(1)).getRepository();
      verify(jdbcRepoMock, times(1)).findJob(123l);
    }
  }