use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class OptimizationLevelIT method testOptimizationLevel.
/**
* Creates the transformation needed to test the java script step with an optimization level set.
*
* @param optimizationLevel
* @return
* @throws KettleException
*/
private List<CheckResultInterface> testOptimizationLevel(String optimizationLevel) throws KettleException {
KettleEnvironment.init();
// Create a new transformation...
TransMeta transMeta = new TransMeta();
transMeta.setName("Test optimization level exception handling");
PluginRegistry registry = PluginRegistry.getInstance();
// create an injector step.../
String injectorStepname = "injector step";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(StepPluginType.class, im);
StepMeta injectorStep = new StepMeta(injectorPid, injectorStepname, im);
transMeta.addStep(injectorStep);
// Create a javascript step
String javaScriptStepname = "javascript step";
// Create the meta and populate
ScriptValuesMetaMod scriptValuesMetaMod = new ScriptValuesMetaMod();
ScriptValuesScript[] js = new ScriptValuesScript[] { new ScriptValuesScript(ScriptValuesScript.TRANSFORM_SCRIPT, "script", "var str = string;\n" + "var bool = LuhnCheck(str);") };
scriptValuesMetaMod.setJSScripts(js);
scriptValuesMetaMod.setFieldname(new String[] { "bool" });
scriptValuesMetaMod.setRename(new String[] { "" });
scriptValuesMetaMod.setType(new int[] { ValueMetaInterface.TYPE_BOOLEAN });
scriptValuesMetaMod.setLength(new int[] { -1 });
scriptValuesMetaMod.setPrecision(new int[] { -1 });
scriptValuesMetaMod.setReplace(new boolean[] { false });
scriptValuesMetaMod.setCompatible(false);
scriptValuesMetaMod.setOptimizationLevel(optimizationLevel);
// Create the step meta
String javaScriptStepPid = registry.getPluginId(StepPluginType.class, scriptValuesMetaMod);
StepMeta javaScriptStep = new StepMeta(javaScriptStepPid, javaScriptStepname, scriptValuesMetaMod);
// Create a dummy step
String dummyStepname = "dummy step";
DummyTransMeta dm = new DummyTransMeta();
String dummyPid = registry.getPluginId(StepPluginType.class, dm);
StepMeta dummyStep = new StepMeta(dummyPid, dummyStepname, dm);
transMeta.addStep(dummyStep);
// hop the steps that were created
TransHopMeta hi2 = new TransHopMeta(javaScriptStep, dummyStep);
transMeta.addTransHop(hi2);
// We use an existing test that creates data: we'll use that data here
JavaScriptSpecialIT javaScriptSpecialTest = new JavaScriptSpecialIT();
List<RowMetaAndData> inputList = javaScriptSpecialTest.createData1();
// RowMetaInterface rowMetaInterface = null;
// This is the collection of error messages that may be generated
// and other things that the check method will need
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
String[] input = new String[] { injectorStepname };
String[] output = new String[] {};
// We get the row meta and data....
Iterator<RowMetaAndData> it = inputList.iterator();
if (it.hasNext()) {
RowMetaAndData rowMetaAndData = it.next();
// .... and then call the scriptValuesMetaMod's check method
scriptValuesMetaMod.check(remarks, transMeta, javaScriptStep, rowMetaAndData.getRowMeta(), input, output, null, transMeta, null, null);
} else {
fail("No data in the inputList");
}
// we then return the remarks made by scriptValuesMetaMod.check(....);
return remarks;
}
use of org.pentaho.di.core.CheckResultInterface in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceStepValidationTest method unsupportedFieldsAddToRemarks.
@Test
public void unsupportedFieldsAddToRemarks() throws MetaverseException {
setupServiceStepNameMatches();
checkStepWithMockedOriginSteps();
ArgumentCaptor<CheckResultInterface> argumentCaptor = ArgumentCaptor.forClass(CheckResultInterface.class);
verify(remarks, times(1)).add(argumentCaptor.capture());
for (String field : FIELD_NAMES) {
assertThat("Expected unsupported field to be in validation messages", argumentCaptor.getValue().getText(), containsString(field));
}
}
Aggregations