@Test public void testRunSetsResult() throws Exception { when( mockJob.isStopped() ).thenReturn( false ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( parentJob.isStopped() ).thenReturn( false ); when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult ); jobRunner.run(); verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) ); }
@Test public void testRunWithExceptionOnExecuteSetsResult() throws Exception { when( mockJob.isStopped() ).thenReturn( false ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( parentJob.isStopped() ).thenReturn( false ); doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) ); jobRunner.run(); verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) ); }
@Test public void testRunWithExceptionOnExecuteAndFireJobSetsResult() throws KettleException { when( mockJob.isStopped() ).thenReturn( false ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( parentJob.isStopped() ).thenReturn( false ); when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult ); doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) ); doThrow( Exception.class ).when( mockJob ).fireJobFinishListeners(); jobRunner.run(); verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) ); assertTrue( jobRunner.isFinished() ); }
@Test public void testRunWithExceptionOnFireJobSetsResult() throws KettleException { when( mockJob.isStopped() ).thenReturn( false ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( parentJob.isStopped() ).thenReturn( false ); when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult ); doThrow( Exception.class ).when( mockJob ).fireJobFinishListeners(); jobRunner.run(); verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) ); assertTrue( jobRunner.isFinished() ); }
} finally { job.setResult( result ); try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.JobFinish.id, getJob() );