Java Code Examples for org.pentaho.di.core.Result#getResult()

The following examples show how to use org.pentaho.di.core.Result#getResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlackBoxIT.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Test
public void runTransOrJob() throws Exception {

  // Params are:
  // File transFile
  // List<File> expectedFiles

  LogChannelInterface log = new LogChannel( "BlackBoxTest [" + transFile.toString() + "]" );

  if ( !transFile.exists() ) {
    log.logError( "Transformation does not exist: " + getPath( transFile ) );
    addFailure( "Transformation does not exist: " + getPath( transFile ) );
    fail( "Transformation does not exist: " + getPath( transFile ) );
  }
  if ( expectedFiles.isEmpty() ) {
    addFailure( "No expected output files found: " + getPath( transFile ) );
    fail( "No expected output files found: " + getPath( transFile ) );
  }

  Result result = runTrans( transFile.getAbsolutePath(), log );

  // verify all the expected output files...
  //
  for ( int i = 0; i < expectedFiles.size(); i++ ) {

    File expected = expectedFiles.get( i );

    if ( expected.getAbsoluteFile().toString().contains( ".expected" ) ) {

      // create a path to the expected output
      String actualFile = expected.getAbsolutePath();
      actualFile = actualFile.replaceFirst( ".expected_" + i + ".", ".actual_" + i + "." ); // multiple files case
      actualFile = actualFile.replaceFirst( ".expected.", ".actual." ); // single file case
      File actual = new File( actualFile );
      if ( result.getResult() ) {
        fileCompare( expected, actual );
      }
    }
  }

  // We didn't get a result, so the only expected file should be a ".fail.txt" file
  //
  if ( !result.getResult() ) {
    String logStr = KettleLogStore.getAppender().getBuffer( result.getLogChannelId(), true ).toString();

    if ( expectedFiles.size() == 0 ) {
      // We haven't got a ".fail.txt" file, so this is a real failure
      fail( "Error running " + getPath( transFile ) + ":" + logStr );
    }
  }
}
 
Example 2
Source File: JobGridDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void addTrackerToTree( JobTracker jobTracker, TreeItem parentItem ) {
  try {
    if ( jobTracker != null ) {
      TreeItem treeItem = new TreeItem( parentItem, SWT.NONE );
      if ( nrRow % 2 != 0 ) {
        treeItem.setBackground( GUIResource.getInstance().getColorBlueCustomGrid() );
      }
      nrRow++;
      if ( jobTracker.nrJobTrackers() > 0 ) {
        // This is a sub-job: display the name at the top of the list...
        treeItem.setText( 0, BaseMessages.getString( PKG, "JobLog.Tree.JobPrefix" ) + jobTracker.getJobName() );

        // then populate the sub-job entries ...
        for ( int i = 0; i < jobTracker.nrJobTrackers(); i++ ) {
          addTrackerToTree( jobTracker.getJobTracker( i ), treeItem );
        }
      } else {
        JobEntryResult result = jobTracker.getJobEntryResult();
        if ( result != null ) {
          String jobEntryName = result.getJobEntryName();
          if ( !Utils.isEmpty( jobEntryName ) ) {
            treeItem.setText( 0, jobEntryName );
            treeItem.setText( 4, Const.NVL( result.getJobEntryFilename(), "" ) );
          } else {
            treeItem.setText( 0, BaseMessages.getString( PKG, "JobLog.Tree.JobPrefix2" )
              + jobTracker.getJobName() );
          }
          String comment = result.getComment();
          if ( comment != null ) {
            treeItem.setText( 1, comment );
          }
          Result res = result.getResult();
          if ( res != null ) {
            treeItem.setText( 2, res.getResult()
              ? BaseMessages.getString( PKG, "JobLog.Tree.Success" ) : BaseMessages.getString(
                PKG, "JobLog.Tree.Failure" ) );
            treeItem.setText( 5, Long.toString( res.getEntryNr() ) );
            if ( res.getResult() ) {
              treeItem.setForeground( GUIResource.getInstance().getColorSuccessGreen() );
            } else {
              treeItem.setForeground( GUIResource.getInstance().getColorRed() );
            }
          }
          String reason = result.getReason();
          if ( reason != null ) {
            treeItem.setText( 3, reason );
          }
          Date logDate = result.getLogDate();
          if ( logDate != null ) {
            treeItem.setText( 6, new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" ).format( logDate ) );
          }
        }
      }
      treeItem.setExpanded( true );
    }
  } catch ( Exception e ) {
    log.logError( Const.getStackTracker( e ) );
  }
}