@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 testWaitUntilFinished() throws Exception { when( mockJob.isStopped() ).thenReturn( true ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( parentJob.isStopped() ).thenReturn( false ); when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult ); jobRunner.waitUntilFinished(); } }
@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 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(); }
@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 testRun() throws Exception { // Call all the NO-OP paths when( mockJob.isStopped() ).thenReturn( true ); jobRunner.run(); when( mockJob.isStopped() ).thenReturn( false ); when( mockJob.getParentJob() ).thenReturn( null ); when( mockJob.getJobMeta() ).thenReturn( mockJobMeta ); jobRunner.run(); when( parentJob.isStopped() ).thenReturn( true ); when( mockJob.getParentJob() ).thenReturn( parentJob ); jobRunner.run(); when( parentJob.isStopped() ).thenReturn( false ); when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult ); jobRunner.run(); }
@Test public void testIsFinished() throws Exception { assertFalse( jobRunner.isFinished() ); 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(); assertTrue( jobRunner.isFinished() ); }
while ( parentJobTraverse != null ) { parentJobTraverse.setVariable( varname, value ); parentJobTraverse = parentJobTraverse.getParentJob(); while ( rootJob != null ) { rootJob.setVariable( varname, value ); rootJob = rootJob.getParentJob(); Job gpJob = parentJob.getParentJob(); if ( gpJob != null ) { gpJob.setVariable( varname, value );
public void run() { try { if ( job.isStopped() || ( job.getParentJob() != null && job.getParentJob().isStopped() ) ) { return;
verifyRecursiveExecution( parentJob.getParentJob(), jobMeta );
while ( parentJob != null ) { parentJob.setVariable( varname, value ); parentJob = parentJob.getParentJob(); parentJob.setVariable( varname, value ); parentJob = parentJob.getParentJob(); VariableSpace gpJob = trans.getParentJob().getParentJob(); if ( gpJob != null ) { gpJob.setVariable( varname, value );
Job j = getParentJob();
while ( rootJob.getParentJob() != null ) { rootJob = rootJob.getParentJob();