Search in sources :

Example 1 with JobHasDescriptionImportRule

use of org.pentaho.di.imp.rules.JobHasDescriptionImportRule in project pentaho-kettle by pentaho.

the class RepositoryExporterTest method getImportRules.

private ImportRules getImportRules() {
    ImportRules imp = new ImportRules();
    List<ImportRuleInterface> impRules = new ArrayList<ImportRuleInterface>(1);
    JobHasDescriptionImportRule rule = new JobHasDescriptionImportRule();
    rule.setEnabled(true);
    rule.setMinLength(19000);
    impRules.add(rule);
    TransformationHasDescriptionImportRule trRule = new TransformationHasDescriptionImportRule() {

        public String toString() {
            return "stub to avoid call to Plugin registry";
        }
    };
    trRule.setEnabled(true);
    trRule.setMinLength(19001);
    impRules.add(trRule);
    imp.setRules(impRules);
    return imp;
}
Also used : ImportRules(org.pentaho.di.imp.ImportRules) JobHasDescriptionImportRule(org.pentaho.di.imp.rules.JobHasDescriptionImportRule) ImportRuleInterface(org.pentaho.di.imp.rule.ImportRuleInterface) ArrayList(java.util.ArrayList) TransformationHasDescriptionImportRule(org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)

Example 2 with JobHasDescriptionImportRule

use of org.pentaho.di.imp.rules.JobHasDescriptionImportRule in project pentaho-kettle by pentaho.

the class JobHasDescriptionImportRuleComposite method getCompositeData.

public void getCompositeData(ImportRuleInterface importRule) {
    JobHasDescriptionImportRule rule = (JobHasDescriptionImportRule) importRule;
    rule.setMinLength(Const.toInt(text.getText(), 0));
}
Also used : JobHasDescriptionImportRule(org.pentaho.di.imp.rules.JobHasDescriptionImportRule)

Example 3 with JobHasDescriptionImportRule

use of org.pentaho.di.imp.rules.JobHasDescriptionImportRule in project pentaho-kettle by pentaho.

the class JobHasDescriptionImportRuleComposite method setCompositeData.

public void setCompositeData(ImportRuleInterface importRule) {
    JobHasDescriptionImportRule rule = (JobHasDescriptionImportRule) importRule;
    text.setText(Integer.toString(rule.getMinLength()));
}
Also used : JobHasDescriptionImportRule(org.pentaho.di.imp.rules.JobHasDescriptionImportRule)

Example 4 with JobHasDescriptionImportRule

use of org.pentaho.di.imp.rules.JobHasDescriptionImportRule in project pentaho-kettle by pentaho.

the class JobHasDescriptionImportRuleIT method testRule.

public void testRule() throws Exception {
    JobMeta jobMeta = new JobMeta();
    jobMeta.setDescription("This job is used for testing an import rule");
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasDescription");
    assertNotNull("The 'job has description' rule could not be found in the plugin registry!", plugin);
    JobHasDescriptionImportRule rule = (JobHasDescriptionImportRule) registry.loadClass(plugin);
    assertNotNull("The 'job has description rule' class could not be loaded by the plugin registry!", plugin);
    rule.setMinLength(20);
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    rule.setMinLength(2000);
    rule.setEnabled(true);
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has description rule'", !feedback.isEmpty());
    assertTrue("An error ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.ERROR);
    rule.setEnabled(false);
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't expect any feedback from the 'job has description rule' while disabled", feedback.isEmpty());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobHasDescriptionImportRule(org.pentaho.di.imp.rules.JobHasDescriptionImportRule) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface)

Aggregations

JobHasDescriptionImportRule (org.pentaho.di.imp.rules.JobHasDescriptionImportRule)4 ArrayList (java.util.ArrayList)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 ImportRules (org.pentaho.di.imp.ImportRules)1 ImportRuleInterface (org.pentaho.di.imp.rule.ImportRuleInterface)1 TransformationHasDescriptionImportRule (org.pentaho.di.imp.rules.TransformationHasDescriptionImportRule)1 JobMeta (org.pentaho.di.job.JobMeta)1