@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() ); }
@Test public void testRunWithException() throws Exception { when( mockJob.isStopped() ).thenReturn( false ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( mockJob.getJobMeta() ).thenReturn( mockJobMeta ); when( parentJob.isStopped() ).thenReturn( false ); doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) ); jobRunner.run(); verify( mockResult, times( 1 ) ).setNrErrors( Mockito.anyInt() ); //[PDI-14981] catch more general exception to prevent thread hanging doThrow( Exception.class ).when( mockJob ).fireJobFinishListeners(); jobRunner.run(); }
getExecutorJob().getJobMeta().disposeEmbeddedMetastoreProvider(); log.logDebug( BaseMessages.getString( PKG, "JobExecutor.Log.DisposeEmbeddedMetastore" ) ); data.executorJob.fireJobFinishListeners(); } catch ( KettleException e ) { result.setNrErrors( 1 );
job.getJobMeta().disposeEmbeddedMetastoreProvider(); log.logDebug( BaseMessages.getString( PKG, "Job.Log.DisposeEmbeddedMetastore" ) ); job.fireJobFinishListeners();
log.logDebug( BaseMessages.getString( PKG, "Job.Log.DisposeEmbeddedMetastore" ) ); fireJobFinishListeners();