Search in sources :

Example 1 with JobHasANoteImportRule

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

the class JobHasANoteImportRuleIT method testRule.

public void testRule() throws Exception {
    // Create a job to test.
    // 
    JobMeta jobMeta = new JobMeta();
    NotePadMeta note = new NotePadMeta("A note documenting the transformation", 50, 50, 200, 50);
    jobMeta.addNote(note);
    // Load the plugin to test from the registry.
    // 
    PluginRegistry registry = PluginRegistry.getInstance();
    PluginInterface plugin = registry.findPluginWithId(ImportRulePluginType.class, "JobHasANote");
    assertNotNull("The 'job has a note' rule could not be found in the plugin registry!", plugin);
    JobHasANoteImportRule rule = (JobHasANoteImportRule) registry.loadClass(plugin);
    assertNotNull("The 'job has a note' rule class could not be loaded by the plugin registry!", plugin);
    rule.setEnabled(true);
    List<ImportValidationFeedback> feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has a note'", !feedback.isEmpty());
    assertTrue("An approval ruling was expected", feedback.get(0).getResultType() == ImportValidationResultType.APPROVAL);
    jobMeta.removeNote(0);
    feedback = rule.verifyRule(jobMeta);
    assertTrue("We didn't get any feedback from the 'job has a note' 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 no note' rule while disabled", feedback.isEmpty());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) NotePadMeta(org.pentaho.di.core.NotePadMeta) JobHasANoteImportRule(org.pentaho.di.imp.rules.JobHasANoteImportRule)

Aggregations

NotePadMeta (org.pentaho.di.core.NotePadMeta)1 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)1 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)1 JobHasANoteImportRule (org.pentaho.di.imp.rules.JobHasANoteImportRule)1 JobMeta (org.pentaho.di.job.JobMeta)1