@BeforeMethod(alwaysRun = true)
 public void setUp() {
   jobManager = new JobManager();
   connectorMgrMock = mock(ConnectorManager.class);
   sqoopConnectorMock = mock(SqoopConnector.class);
   ConnectorManager.setInstance(connectorMgrMock);
   repositoryManagerMock = mock(RepositoryManager.class);
   RepositoryManager.setInstance(repositoryManagerMock);
   jdbcRepoMock = mock(JdbcRepository.class);
 }
 @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);
 }
 @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);
 }
 @Test
 public void testUnknownJob() {
   long testJobId = 555l;
   SqoopException exception =
       new SqoopException(DriverError.DRIVER_0004, "Unknown job id: " + testJobId);
   when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
   when(jdbcRepoMock.findJob(testJobId)).thenReturn(null);
   try {
     jobManager.getJob(testJobId);
   } catch (SqoopException ex) {
     assertEquals(ex.getMessage(), exception.getMessage());
     verify(repositoryManagerMock, times(1)).getRepository();
     verify(jdbcRepoMock, times(1)).findJob(testJobId);
   }
 }
  @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);
    }
  }
  @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);
    }
  }