Java Code Examples for org.pentaho.di.core.CheckResultInterface

The following examples show how to use org.pentaho.di.core.CheckResultInterface. These examples are extracted from open source projects. 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 Project: pentaho-kafka-producer   Source File: KafkaProducerMeta.java    License: 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 2
Source Project: pentaho-kettle   Source File: IntegerValidator.java    License: 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 Project: pentaho-kettle   Source File: LongValidator.java    License: 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 4
Source Project: pentaho-kettle   Source File: JobEntrySSH2PUT.java    License: 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 5
Source Project: pentaho-kettle   Source File: JmsProducer.java    License: 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 6
Source Project: pentaho-kettle   Source File: JobEntryAddResultFilenames.java    License: 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 7
Source Project: pentaho-kettle   Source File: JobEntryUnZip.java    License: 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 8
Source Project: pentaho-kettle   Source File: MQTTProducer.java    License: 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 9
Source Project: pentaho-kettle   Source File: JobEntryZipFile.java    License: 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 10
Source Project: pentaho-kettle   Source File: JobEntryGetPOP.java    License: 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 11
Source Project: pentaho-kettle   Source File: JobEntryMoveFiles.java    License: 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 12
Source Project: pentaho-kettle   Source File: RowGeneratorMeta.java    License: 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 13
Source Project: pentaho-kettle   Source File: JobEntryXMLWellFormed.java    License: 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 14
Source Project: pentaho-kafka-consumer   Source File: KafkaConsumerMeta.java    License: 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 15
Source Project: pentaho-kettle   Source File: JobEntryMail.java    License: 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 16
Source Project: pentaho-kettle   Source File: JobEntryShell.java    License: 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 17
Source Project: pentaho-kettle   Source File: JobEntryTruncateTables.java    License: 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 18
Source Project: pentaho-kettle   Source File: JobEntryTrans.java    License: 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 19
Source Project: pentaho-kettle   Source File: JobEntryCheckFilesLocked.java    License: 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 20
Source Project: pentaho-kettle   Source File: JobEntryDeleteFolders.java    License: 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 21
Source Project: pentaho-kettle   Source File: JobEntryPGPEncryptFiles.java    License: 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
@Override
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 (prev == null || prev.size() == 0) {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "Not receiving any fields from previous steps.", stepMeta));
    } else {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, String.format("Step is connected to previous one, receiving %1$d fields", prev.size()), stepMeta));
    }

    if (input.length > 0) {
        remarks.add( new CheckResult(CheckResultInterface.TYPE_RESULT_ERROR, "Step is receiving info from other steps!", stepMeta) );
    } else {
        remarks.add(new CheckResult(CheckResultInterface.TYPE_RESULT_OK, "No input received from other steps.", stepMeta));
    }
}
 
Example 23
Source Project: pentaho-kettle   Source File: MergeJoinMeta.java    License: Apache License 2.0 5 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 ) {
  /*
   * @todo Need to check for the following: 1) Join type must be one of INNER / LEFT OUTER / RIGHT OUTER / FULL OUTER
   * 2) Number of input streams must be two (for now at least) 3) The field names of input streams must be unique
   */
  CheckResult cr =
    new CheckResult( CheckResultInterface.TYPE_RESULT_WARNING, BaseMessages.getString(
      PKG, "MergeJoinMeta.CheckResult.StepNotVerified" ), stepMeta );
  remarks.add( cr );
}
 
Example 24
Source Project: pentaho-kettle   Source File: MQTTProducerMetaTest.java    License: 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 25
Source Project: pentaho-kettle   Source File: OptimizationLevelIT.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Performs the JUnit assertEquals for the passed optimization level. The return value of testOptimizationLevel is
 * asserted with containsErrorMessage.
 *
 * @param optimizationLevel
 *          the optimization level to test
 * @param containsErrorMessage
 *          True if the check contains the error message, false if not.
 */
private void test( String optimizationLevel, boolean containsErrorMessage ) {
  try {
    List<CheckResultInterface> remarks = testOptimizationLevel( optimizationLevel );
    assertEquals( containsErrorMessage( remarks ), containsErrorMessage );
  } catch ( KettleException ke ) {
    ke.printStackTrace();
    fail( ke.getMessage() );
  }
}
 
Example 26
Source Project: pentaho-kettle   Source File: JobEntryCreateFile.java    License: Apache License 2.0 5 votes vote down vote up
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.notNullValidator(), JobEntryValidatorUtils.fileDoesNotExistValidator() );
  JobEntryValidatorUtils.andValidator().validate( this, "filename", remarks, ctx );
}
 
Example 27
Source Project: pentaho-kettle   Source File: FileExistsValidator.java    License: Apache License 2.0 5 votes vote down vote up
protected boolean getFailIfDoesNotExist( CheckResultSourceInterface source, String propertyName,
  List<CheckResultInterface> remarks, ValidatorContext context ) {
  Object obj = context.get( KEY_FAIL_IF_DOES_NOT_EXIST );
  if ( obj instanceof Boolean ) {
    return (Boolean) obj;
  } else {
    // default is false
    return false;
  }
}
 
Example 28
Source Project: pentaho-kettle   Source File: MQTTConsumerMetaTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckFailAll() {
  List<CheckResultInterface> remarks = new ArrayList<>();
  meta.setKeepAliveInterval( "asdf" );
  meta.setMaxInflight( "asdf" );
  meta.setConnectionTimeout( "asdf" );
  meta.setCleanSession( "asdf" );
  meta.setAutomaticReconnect( "adsf" );
  meta.setMqttVersion( "9" );
  meta.check( remarks, null, null, null, null, null, null, new Variables(), null, null );

  assertEquals( 6, remarks.size() );
  assertEquals( BaseMessages
      .getString( PKG, "MQTTMeta.CheckResult.NotANumber",
        BaseMessages.getString( PKG, "MQTTDialog.Options." + KEEP_ALIVE_INTERVAL ) ),
    remarks.get( 0 ).getText() );
  assertEquals( BaseMessages
      .getString( PKG, "MQTTMeta.CheckResult.NotANumber",
        BaseMessages.getString( PKG, "MQTTDialog.Options." + MAX_INFLIGHT ) ),
    remarks.get( 1 ).getText() );
  assertEquals( BaseMessages
      .getString( PKG, "MQTTMeta.CheckResult.NotANumber",
        BaseMessages.getString( PKG, "MQTTDialog.Options." + CONNECTION_TIMEOUT ) ),
    remarks.get( 2 ).getText() );
  assertEquals( BaseMessages
      .getString( PKG, "MQTTMeta.CheckResult.NotABoolean",
        BaseMessages.getString( PKG, "MQTTDialog.Options." + CLEAN_SESSION ) ),
    remarks.get( 3 ).getText() );
  assertEquals( BaseMessages
      .getString( PKG, "MQTTMeta.CheckResult.NotCorrectVersion",
        BaseMessages.getString( PKG, "MQTTDialog.Options." + MQTT_VERSION ) ),
    remarks.get( 4 ).getText() );
  assertEquals(
    BaseMessages
      .getString( PKG, "MQTTMeta.CheckResult.NotABoolean",
        BaseMessages.getString( PKG, "MQTTDialog.Options." + AUTOMATIC_RECONNECT ) ),
    remarks.get( 5 ).getText() );
}
 
Example 29
Source Project: pentaho-kettle   Source File: JobEntryXSLT.java    License: 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 ) {
  ValidatorContext ctx = new ValidatorContext();
  putVariableSpace( ctx, getVariables() );
  putValidators( ctx, notBlankValidator(), fileExistsValidator() );
  andValidator().validate( this, "xmlFilename", remarks, ctx );
  andValidator().validate( this, "xslFilename", remarks, ctx );

  andValidator().validate( this, "outputFilename", remarks, putValidators( notBlankValidator() ) );
}
 
Example 30
Source Project: pentaho-kettle   Source File: AbstractFileValidator.java    License: Apache License 2.0 5 votes vote down vote up
protected VariableSpace getVariableSpace( CheckResultSourceInterface source, String propertyName,
  List<CheckResultInterface> remarks, ValidatorContext context ) {
  Object obj = context.get( KEY_VARIABLE_SPACE );
  if ( obj instanceof VariableSpace ) {
    return (VariableSpace) obj;
  } else {
    JobEntryValidatorUtils.addGeneralRemark(
      source, propertyName, getName(), remarks, "messages.failed.missingKey",
      CheckResultInterface.TYPE_RESULT_ERROR );
    return null;
  }
}