org.pentaho.di.core.CheckResultInterface Java Examples

The following examples show how to use org.pentaho.di.core.CheckResultInterface. 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: JobEntryMail.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {

  JobEntryValidatorUtils.andValidator().validate( this, "server", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator()
    .validate( this, "replyAddress", remarks, AndValidator.putValidators(
        JobEntryValidatorUtils.notBlankValidator(), JobEntryValidatorUtils.emailValidator() ) );

  JobEntryValidatorUtils.andValidator().validate( this, "destination", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );

  if ( usingAuthentication ) {
    JobEntryValidatorUtils.andValidator().validate( this, "authenticationUser", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
    JobEntryValidatorUtils.andValidator().validate( this, "authenticationPassword", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );
  }

  JobEntryValidatorUtils.andValidator().validate( this, "port", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.integerValidator() ) );

}
 
Example #2
Source File: IntegerValidator.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean validate( CheckResultSourceInterface source, String propertyName,
  List<CheckResultInterface> remarks, ValidatorContext context ) {

  Object result = null;
  String value = null;

  value = ValidatorUtils.getValueAsString( source, propertyName );

  if ( GenericValidator.isBlankOrNull( value ) ) {
    return true;
  }

  result = GenericTypeValidator.formatInt( value );

  if ( result == null ) {
    JobEntryValidatorUtils.addFailureRemark( source, propertyName, VALIDATOR_NAME, remarks,
        JobEntryValidatorUtils.getLevelOnFail( context, VALIDATOR_NAME ) );
    return false;
  }
  return true;

}
 
Example #3
Source File: JobEntryCheckFilesLocked.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  boolean res = JobEntryValidatorUtils.andValidator().validate( this, "arguments", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  if ( res ) {
    ValidatorContext ctx = new ValidatorContext();
    AbstractFileValidator.putVariableSpace( ctx, getVariables() );
    AndValidator.putValidators( ctx, JobEntryValidatorUtils.notNullValidator(),
      JobEntryValidatorUtils.fileExistsValidator() );

    for ( int i = 0; i < arguments.length; i++ ) {
      JobEntryValidatorUtils.andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
    }
  }
}
 
Example #4
Source File: KafkaProducerMeta.java    From pentaho-kafka-producer with Apache License 2.0 6 votes vote down vote up
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
		String input[], String output[], RowMetaInterface info) {

	if (isEmpty(topic)) {
		remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
				Messages.getString("KafkaProducerMeta.Check.InvalidTopic"), stepMeta));
	}
	if (isEmpty(messageField)) {
		remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
				Messages.getString("KafkaProducerMeta.Check.InvalidMessageField"), stepMeta));
	}
	try {
		new ProducerConfig(kafkaProperties);
	} catch (IllegalArgumentException e) {
		remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, e.getMessage(), stepMeta));
	}
}
 
Example #5
Source File: JobEntryDeleteFolders.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  boolean res = JobEntryValidatorUtils.andValidator().validate( this, "arguments", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  if ( !res ) {
    return;
  }

  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notNullValidator(), JobEntryValidatorUtils.fileExistsValidator() );

  for ( int i = 0; i < arguments.length; i++ ) {
    JobEntryValidatorUtils.andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
  }
}
 
Example #6
Source File: LongValidator.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean validate( CheckResultSourceInterface source, String propertyName,
  List<CheckResultInterface> remarks, ValidatorContext context ) {
  Object result = null;
  String value = null;

  value = ValidatorUtils.getValueAsString( source, propertyName );

  if ( GenericValidator.isBlankOrNull( value ) ) {
    return Boolean.TRUE;
  }

  result = GenericTypeValidator.formatLong( value );

  if ( result == null ) {
    JobEntryValidatorUtils.addFailureRemark( source, propertyName, VALIDATOR_NAME, remarks,
        JobEntryValidatorUtils.getLevelOnFail( context, VALIDATOR_NAME ) );
    return false;
  }
  return true;
}
 
Example #7
Source File: JobEntrySSH2PUT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  JobEntryValidatorUtils.andValidator().validate( this, "serverName", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "localDirectory", remarks,
    AndValidator.putValidators(
      JobEntryValidatorUtils.notBlankValidator(),
      JobEntryValidatorUtils.fileExistsValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "userName", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "password", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "serverPort", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.integerValidator() ) );
}
 
Example #8
Source File: JmsProducer.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean init( StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface ) {
  boolean isInitalized = super.init( stepMetaInterface, stepDataInterface );
  meta = ( (JmsProducerMeta) ( (BaseSerializingMeta) stepMetaInterface ).withVariables( this ) );

  List<CheckResultInterface> remarks = new ArrayList<>();
  meta.check(
    remarks, getTransMeta(), meta.getParentStepMeta(),
    null, null, null, null, //these parameters are not used inside the method
    variables, getRepository(), getMetaStore() );
  @SuppressWarnings( "squid:S3864" ) //usage of peek is appropriate here
  boolean errorsPresent =
    remarks.stream().filter( result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR )
      .peek( result -> logError( result.getText() ) )
      .count() > 0;
  if ( errorsPresent ) {
    return false;
  }

  return isInitalized;
}
 
Example #9
Source File: JobEntryTrans.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
                   Repository repository, IMetaStore metaStore ) {
  if ( setLogfile ) {
    JobEntryValidatorUtils.andValidator().validate( this, "logfile", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  }
  if ( !Utils.isEmpty( filename ) ) {
    JobEntryValidatorUtils.andValidator().validate( this, "filename", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  } else {
    JobEntryValidatorUtils.andValidator().validate( this, "transname", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
    JobEntryValidatorUtils.andValidator().validate( this, "directory", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );
  }
}
 
Example #10
Source File: JobEntryAddResultFilenames.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  boolean res = JobEntryValidatorUtils.andValidator().validate( this, "arguments", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  if ( res == false ) {
    return;
  }

  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notNullValidator(), JobEntryValidatorUtils.fileExistsValidator() );

  for ( int i = 0; i < arguments.length; i++ ) {
    JobEntryValidatorUtils.andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
  }
}
 
Example #11
Source File: JobEntryTruncateTables.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  boolean res = JobEntryValidatorUtils.andValidator().validate( this, "arguments", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  if ( res == false ) {
    return;
  }

  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notNullValidator(),
      JobEntryValidatorUtils.fileExistsValidator() );

  for ( int i = 0; i < arguments.length; i++ ) {
    JobEntryValidatorUtils.andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
  }
}
 
Example #12
Source File: MQTTProducer.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean init( StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface ) {
  boolean isInitalized = super.init( stepMetaInterface, stepDataInterface );
  BaseSerializingMeta serializingMeta = (BaseSerializingMeta) stepMetaInterface;
  meta = (MQTTProducerMeta) serializingMeta.withVariables( this ); // handle variable substitution up-front

  List<CheckResultInterface> remarks = new ArrayList<>();
  meta.check(
    remarks, getTransMeta(), meta.getParentStepMeta(),
    null, null, null, null, //these parameters are not used inside the method
    variables, getRepository(), getMetaStore() );
  @SuppressWarnings( "squid:S3864" ) //peek used appropriately here
  boolean errorsPresent =
    remarks.stream().filter( result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR )
      .peek( result -> logError( result.getText() ) )
      .count() > 0;
  return !errorsPresent && isInitalized;
}
 
Example #13
Source File: JobEntryZipFile.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  ValidatorContext ctx1 = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx1, getVariables() );
  AndValidator.putValidators( ctx1, JobEntryValidatorUtils.notBlankValidator(), JobEntryValidatorUtils.fileDoesNotExistValidator() );
  if ( 3 == ifZipFileExists ) {
    // execute method fails if the file already exists; we should too
    FileDoesNotExistValidator.putFailIfExists( ctx1, true );
  }
  JobEntryValidatorUtils.andValidator().validate( this, "zipFilename", remarks, ctx1 );

  if ( 2 == afterZip ) {
    // setting says to move
    JobEntryValidatorUtils.andValidator().validate( this, "moveToDirectory", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  }

  JobEntryValidatorUtils.andValidator().validate( this, "sourceDirectory", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );

}
 
Example #14
Source File: JobEntryShell.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notBlankValidator(),
      JobEntryValidatorUtils.fileExistsValidator() );

  JobEntryValidatorUtils.andValidator().validate( this, "workDirectory", remarks, ctx );
  JobEntryValidatorUtils.andValidator().validate( this, "filename", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );

  if ( setLogfile ) {
    JobEntryValidatorUtils.andValidator().validate( this, "logfile", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  }
}
 
Example #15
Source File: JobEntryGetPOP.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  JobEntryValidatorUtils.andValidator().validate( this, "serverName", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "userName", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "password", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notBlankValidator(),
      JobEntryValidatorUtils.fileExistsValidator() );
  JobEntryValidatorUtils.andValidator().validate( this, "outputDirectory", remarks, ctx );

  JobEntryValidatorUtils.andValidator().validate( this, "SSLPort", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.integerValidator() ) );
}
 
Example #16
Source File: JobEntryMoveFiles.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  boolean res = JobEntryValidatorUtils.andValidator().validate( this, "arguments", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  if ( res == false ) {
    return;
  }

  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notNullValidator(), JobEntryValidatorUtils.fileExistsValidator() );

  for ( int i = 0; i < source_filefolder.length; i++ ) {
    JobEntryValidatorUtils.andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
  }
}
 
Example #17
Source File: JobEntryUnZip.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  ValidatorContext ctx1 = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx1, getVariables() );
  AndValidator.putValidators( ctx1, JobEntryValidatorUtils.notBlankValidator(),
      JobEntryValidatorUtils.fileDoesNotExistValidator() );

  JobEntryValidatorUtils.andValidator().validate( this, "zipFilename", remarks, ctx1 );

  if ( 2 == afterunzip ) {
    // setting says to move
    JobEntryValidatorUtils.andValidator().validate( this, "moveToDirectory", remarks,
        AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  }

  JobEntryValidatorUtils.andValidator().validate( this, "sourceDirectory", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );

}
 
Example #18
Source File: RowGeneratorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void getFields( RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep,
  VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
  try {
    List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
    RowMetaAndData rowMetaAndData = RowGenerator.buildRow( this, remarks, origin );
    if ( !remarks.isEmpty() ) {
      StringBuilder stringRemarks = new StringBuilder();
      for ( CheckResultInterface remark : remarks ) {
        stringRemarks.append( remark.toString() ).append( Const.CR );
      }
      throw new KettleStepException( stringRemarks.toString() );
    }

    for ( ValueMetaInterface valueMeta : rowMetaAndData.getRowMeta().getValueMetaList() ) {
      valueMeta.setOrigin( origin );
    }

    row.mergeRowMeta( rowMetaAndData.getRowMeta() );
  } catch ( Exception e ) {
    throw new KettleStepException( e );
  }
}
 
Example #19
Source File: JobEntryXMLWellFormed.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space, Repository repository,
    IMetaStore metaStore ) {
  boolean res = andValidator().validate( this, "arguments", remarks, putValidators( notNullValidator() ) );

  if ( res == false ) {
    return;
  }

  ValidatorContext ctx = new ValidatorContext();
  putVariableSpace( ctx, getVariables() );
  putValidators( ctx, notNullValidator(), fileExistsValidator() );

  for ( int i = 0; i < source_filefolder.length; i++ ) {
    andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
  }
}
 
Example #20
Source File: KafkaConsumerMeta.java    From pentaho-kafka-consumer with Apache License 2.0 6 votes vote down vote up
public void check(List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
                  String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
                  IMetaStore metaStore) {

    if (topic == null) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("KafkaConsumerMeta.Check.InvalidTopic"), stepMeta));
    }
    if (field == null) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("KafkaConsumerMeta.Check.InvalidField"), stepMeta));
    }
    if (keyField == null) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR,
                Messages.getString("KafkaConsumerMeta.Check.InvalidKeyField"), stepMeta));
    }
    try {
        new ConsumerConfig(kafkaProperties);
    } catch (IllegalArgumentException e) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, e.getMessage(), stepMeta));
    }
}
 
Example #21
Source File: JobEntryPGPEncryptFiles.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  boolean res = JobEntryValidatorUtils.andValidator().validate( this, "arguments", remarks,
      AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );

  if ( res == false ) {
    return;
  }

  ValidatorContext ctx = new ValidatorContext();
  AbstractFileValidator.putVariableSpace( ctx, getVariables() );
  AndValidator.putValidators( ctx, JobEntryValidatorUtils.notNullValidator(),
      JobEntryValidatorUtils.fileExistsValidator() );

  for ( int i = 0; i < source_filefolder.length; i++ ) {
    JobEntryValidatorUtils.andValidator().validate( this, "arguments[" + i + "]", remarks, ctx );
  }
}
 
Example #22
Source File: MergeRowsMetaCheckTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckInputRowsEmptyAndNonEmpty() throws KettleStepException {
  when( transMeta.getPrevStepFields( REFERENCE_STEP_NAME ) ).thenReturn( generateRowMetaEmpty() );
  when( transMeta.getPrevStepFields( COMPARISON_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() );

  meta.check( remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0],
    (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null );

  assertNotNull( remarks );
  assertTrue( remarks.size() >= 2 );
  assertEquals( remarks.get( 1 ).getType(), CheckResultInterface.TYPE_RESULT_ERROR );
}
 
Example #23
Source File: AbortMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepinfo,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  // See if we have input streams leading to this step!
  if ( input.length == 0 ) {
    CheckResult cr =
      new CheckResult( CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString(
        PKG, "AbortMeta.CheckResult.NoInputReceivedError" ), stepinfo );
    remarks.add( cr );
  }
}
 
Example #24
Source File: JobEntryFTPDelete.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
  Repository repository, IMetaStore metaStore ) {
  JobEntryValidatorUtils.andValidator().validate( this, "serverName", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate(
    this, "targetDirectory", remarks, AndValidator.putValidators(
        JobEntryValidatorUtils.notBlankValidator(), JobEntryValidatorUtils.fileExistsValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "userName", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "password", remarks, AndValidator.putValidators( JobEntryValidatorUtils.notNullValidator() ) );
}
 
Example #25
Source File: MergeRowsMetaCheckTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckInputRowsBothNonEmpty() throws KettleStepException {
  when( transMeta.getPrevStepFields( REFERENCE_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() );
  when( transMeta.getPrevStepFields( COMPARISON_STEP_NAME ) ).thenReturn( generateRowMeta10Strings() );

  meta.check( remarks, transMeta, stepMeta, (RowMeta) null, new String[0], new String[0],
    (RowMeta) null, new Variables(), (Repository) null, (IMetaStore) null );

  assertNotNull( remarks );
  assertTrue( remarks.size() >= 2 );
  assertEquals( remarks.get( 1 ).getType(), CheckResultInterface.TYPE_RESULT_OK );
}
 
Example #26
Source File: XMLOutputMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheck() throws Exception {
  XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
  xmlOutputMeta.setDefault();
  TransMeta transMeta = mock( TransMeta.class );
  StepMeta stepInfo = mock( StepMeta.class );
  RowMetaInterface prev = mock( RowMetaInterface.class );
  Repository repos = mock( Repository.class );
  IMetaStore metastore = mock( IMetaStore.class );
  RowMetaInterface info = mock( RowMetaInterface.class );
  ArrayList<CheckResultInterface> remarks = new ArrayList<>();
  xmlOutputMeta.check( remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info,
      new Variables(), repos, metastore );
  assertEquals( 2, remarks.size() );
  assertEquals( "Step is receiving info from other steps.", remarks.get( 0 ).getText() );
  assertEquals( "File specifications are not checked.", remarks.get( 1 ).getText() );

  XMLField xmlField = new XMLField();
  xmlField.setFieldName( "aField" );
  xmlField.setType( 1 );
  xmlField.setLength( 10 );
  xmlField.setPrecision( 3 );
  xmlOutputMeta.setOutputFields( new XMLField[] { xmlField } );
  when( prev.size() ).thenReturn( 1 );
  remarks.clear();
  xmlOutputMeta.check( remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info,
      new Variables(), repos, metastore );
  assertEquals( 4, remarks.size() );
  assertEquals( "Step is connected to previous one, receiving 1 fields", remarks.get( 0 ).getText() );
  assertEquals( "All output fields are found in the input stream.", remarks.get( 1 ).getText() );
  assertEquals( "Step is receiving info from other steps.", remarks.get( 2 ).getText() );
  assertEquals( "File specifications are not checked.", remarks.get( 3 ).getText() );

}
 
Example #27
Source File: MQTTProducerMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckOptionsFail() {
  List<CheckResultInterface> remarks = new ArrayList<>();
  MQTTProducerMeta meta = new MQTTProducerMeta();
  meta.mqttServer = "theserver:1883";
  meta.clientId = "client100";
  meta.topic = "newtopic";
  meta.qos = "2";
  meta.messageField = "Messages";
  meta.username = "testuser";
  meta.keepAliveInterval = "asdf";
  meta.maxInflight = "asdf";
  meta.connectionTimeout = "asdf";
  meta.cleanSession = "asdf";
  meta.automaticReconnect = "adsf";
  meta.mqttVersion = "asdf";
  meta.check( remarks, null, null, null, null, null, null, new Variables(), null, null );

  assertEquals( 6, remarks.size() );
  assertTrue( remarks.get( 0 ).getText()
    .contains( BaseMessages.getString( PKG, "MQTTDialog.Options." + KEEP_ALIVE_INTERVAL ) ) );
  assertTrue(
    remarks.get( 1 ).getText().contains( BaseMessages.getString( PKG, "MQTTDialog.Options." + MAX_INFLIGHT ) ) );
  assertTrue( remarks.get( 2 ).getText()
    .contains( BaseMessages.getString( PKG, "MQTTDialog.Options." + CONNECTION_TIMEOUT ) ) );
  assertTrue(
    remarks.get( 3 ).getText().contains( BaseMessages.getString( PKG, "MQTTDialog.Options." + CLEAN_SESSION ) ) );
  assertTrue(
    remarks.get( 4 ).getText().contains( BaseMessages.getString( PKG, "MQTTDialog.Options." + MQTT_VERSION ) ) );
  assertTrue( remarks.get( 5 ).getText()
    .contains( BaseMessages.getString( PKG, "MQTTDialog.Options." + AUTOMATIC_RECONNECT ) ) );
}
 
Example #28
Source File: JobMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Check all job entries within the job. Each Job Entry has the opportunity to check their own settings.
 *
 * @param remarks       List of CheckResult remarks inserted into by each JobEntry
 * @param only_selected true if you only want to check the selected jobs
 * @param monitor       Progress monitor (not presently in use)
 */
public void checkJobEntries( List<CheckResultInterface> remarks, boolean only_selected,
    ProgressMonitorListener monitor, VariableSpace space, Repository repository, IMetaStore metaStore ) {
  remarks.clear(); // Empty remarks
  if ( monitor != null ) {
    monitor.beginTask( BaseMessages.getString( PKG, "JobMeta.Monitor.VerifyingThisJobEntryTask.Title" ),
        jobcopies.size() + 2 );
  }
  boolean stop_checking = false;
  for ( int i = 0; i < jobcopies.size() && !stop_checking; i++ ) {
    JobEntryCopy copy = jobcopies.get( i ); // get the job entry copy
    if ( ( !only_selected ) || ( only_selected && copy.isSelected() ) ) {
      JobEntryInterface entry = copy.getEntry();
      if ( entry != null ) {
        if ( monitor != null ) {
          monitor
              .subTask( BaseMessages.getString( PKG, "JobMeta.Monitor.VerifyingJobEntry.Title", entry.getName() ) );
        }
        entry.check( remarks, this, space, repository, metaStore );
        compatibleEntryCheck( entry, remarks );
        if ( monitor != null ) {
          monitor.worked( 1 ); // progress bar...
          if ( monitor.isCanceled() ) {
            stop_checking = true;
          }
        }
      }
    }
    if ( monitor != null ) {
      monitor.worked( 1 );
    }
  }
  if ( monitor != null ) {
    monitor.done();
  }
}
 
Example #29
Source File: UnivariateStatsMetaTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckNullPrev() {
  UnivariateStatsMeta meta = new UnivariateStatsMeta();
  List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
  meta.check( remarks, null, null, null, new String[0], null, null, null, null, null );
  assertEquals( 2, remarks.size() );
  assertEquals( "Not receiving any fields from previous steps!", remarks.get( 0 ).getText() );
}
 
Example #30
Source File: JobEntryHTTP.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, JobMeta jobMeta, VariableSpace space,
                   Repository repository, IMetaStore metaStore ) {
  JobEntryValidatorUtils.andValidator().validate( this, "targetFilename", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "targetFilenameExtention", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "uploadFilename", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.notBlankValidator() ) );
  JobEntryValidatorUtils.andValidator().validate( this, "proxyPort", remarks,
    AndValidator.putValidators( JobEntryValidatorUtils.integerValidator() ) );
}