use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class Constant method init.
@Override
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
meta = (ConstantMeta) smi;
data = (ConstantData) sdi;
data.firstRow = true;
if (super.init(smi, sdi)) {
// Create a row (constants) with all the values in it...
// stores the errors...
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
data.constants = buildRow(meta, data, remarks);
if (remarks.isEmpty()) {
return true;
} else {
for (int i = 0; i < remarks.size(); i++) {
CheckResultInterface cr = remarks.get(i);
logError(cr.getText());
}
}
}
return false;
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class RestMetaTest method testStepChecks.
@Test
public void testStepChecks() {
RestMeta meta = new RestMeta();
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
TransMeta transMeta = new TransMeta();
StepMeta step = new StepMeta();
RowMetaInterface prev = new RowMeta();
RowMetaInterface info = new RowMeta();
String[] input = new String[0];
String[] output = new String[0];
VariableSpace variables = new Variables();
Repository repo = null;
IMetaStore metaStore = null;
// In a default configuration, it's expected that some errors will occur.
// For this, we'll grab a baseline count of the number of errors
// as the error count should decrease as we change configuration settings to proper values.
remarks.clear();
meta.check(remarks, transMeta, step, prev, input, output, info, variables, repo, metaStore);
final int errorsDefault = getCheckResultErrorCount(remarks);
assertTrue(errorsDefault > 0);
// Setting the step to read the URL from a field should fix one of the check() errors
meta.setUrlInField(true);
meta.setUrlField("urlField");
prev.addValueMeta(new ValueMetaString("urlField"));
remarks.clear();
meta.check(remarks, transMeta, step, prev, input, output, info, variables, repo, metaStore);
int errorsCurrent = getCheckResultErrorCount(remarks);
assertTrue(errorsDefault > errorsCurrent);
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class UnivariateStatsMetaTest method testCheckGoodPrev.
@Test
public void testCheckGoodPrev() {
UnivariateStatsMeta meta = new UnivariateStatsMeta();
RowMetaInterface mockRowMetaInterface = mock(RowMetaInterface.class);
when(mockRowMetaInterface.size()).thenReturn(500);
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
meta.check(remarks, null, null, mockRowMetaInterface, new String[0], null, null, null, null, null);
assertEquals(2, remarks.size());
assertEquals("Step is connected to previous one, receiving " + 500 + " fields", remarks.get(0).getText());
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class BaseStreamStepMetaTest method testCheckErrorsOnZeroSizeAndDuration.
@Test
public void testCheckErrorsOnZeroSizeAndDuration() {
meta.setBatchDuration("0");
meta.setBatchSize("0");
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
meta.check(remarks, null, null, null, null, null, null, new Variables(), null, null);
assertEquals(1, remarks.size());
assertEquals("The \"Number of records\" and \"Duration\" fields can’t both be set to 0. Please set a value of 1 or higher " + "for one of the fields.", remarks.get(0).getText());
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class BaseStreamStepMetaTest method testCheckErrorsOnVariables.
@Test
public void testCheckErrorsOnVariables() {
List<CheckResultInterface> remarks = new ArrayList<>();
Variables space = new Variables();
space.setVariable("something", "1000");
meta.setBatchSize("${something}");
meta.setBatchDuration("0");
meta.check(remarks, null, null, null, null, null, null, space, null, null);
assertEquals(0, remarks.size());
}
Aggregations