public void run() {
    try {
      if ( job.isStopped() || ( job.getParentJob() != null && job.getParentJob().isStopped() ) ) {
        return;
      }

      // This JobEntryRunner is a replacement for the Job thread.
      // The job thread is never started because we simply want to wait for the result.
      //
      ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.JobStart.id, getJob() );

      job.fireJobStartListeners(); // Fire the start listeners
      result = job.execute( entryNr + 1, result );
    } catch ( KettleException e ) {
      e.printStackTrace();
      log.logError( "An error occurred executing this job entry : ", e );
      result.setResult( false );
      result.setNrErrors( 1 );
    } finally {
      //[PDI-14981] otherwise will get null pointer exception if 'job finished' listeners will be using it
      job.setResult( result );
      try {
        ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.JobFinish.id, getJob() );
        job.getJobMeta().disposeEmbeddedMetastoreProvider();
        log.logDebug( BaseMessages.getString( PKG, "Job.Log.DisposeEmbeddedMetastore" ) );
        job.fireJobFinishListeners();

        //catch more general exception to prevent thread hanging
      } catch ( Exception e ) {
        result.setNrErrors( 1 );
        result.setResult( false );
        log.logError( BaseMessages.getString( PKG, "Job.Log.ErrorExecJob", e.getMessage() ), e );
      }
      job.setFinished( true );
    }
    finished = true;
  }
@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();

  }