use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class ZipFileMetaTest method testCheck.
@Test
public void testCheck() {
ZipFileMeta zipFileMeta = new ZipFileMeta();
zipFileMeta.setDefault();
TransMeta transMeta = mock(TransMeta.class);
StepMeta stepInfo = mock(StepMeta.class);
RowMetaInterface prev = mock(RowMetaInterface.class);
Repository repos = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
RowMetaInterface info = mock(RowMetaInterface.class);
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Source Filename field is missing!", remarks.get(0).getText());
assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
remarks = new ArrayList<>();
zipFileMeta = new ZipFileMeta();
zipFileMeta.setDynamicSourceFileNameField("sourceFileField");
zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[0], new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Target Filename field was specified", remarks.get(0).getText());
assertEquals("No input received from other steps!", remarks.get(1).getText());
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class BaseStreamStepMetaTest method testCheckErrorsOnNaN.
@Test
public void testCheckErrorsOnNaN() throws Exception {
List<CheckResultInterface> remarks = new ArrayList<>();
meta.setBatchDuration("blah");
meta.setBatchSize("blah");
meta.check(remarks, null, null, null, null, null, null, new Variables(), null, null);
assertEquals(2, remarks.size());
assertEquals(CheckResultInterface.TYPE_RESULT_ERROR, remarks.get(0).getType());
assertEquals("The \"Duration\" field is using a non-numeric value. Please set a numeric value.", remarks.get(0).getText());
assertEquals(CheckResultInterface.TYPE_RESULT_ERROR, remarks.get(1).getType());
assertEquals("The \"Number of records\" field is using a non-numeric value. Please set a numeric value.", remarks.get(1).getText());
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class BaseStreamStepMetaTest method testCheckErrorsOnVariablesSubstituteError.
@Test
public void testCheckErrorsOnVariablesSubstituteError() {
List<CheckResultInterface> remarks = new ArrayList<>();
Variables space = new Variables();
space.setVariable("something", "0");
meta.setBatchSize("${something}");
meta.setBatchDuration("${something}");
meta.check(remarks, null, null, null, null, null, null, space, 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());
testRoundTrip(meta);
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class PDI_6976_Test method testVerifyNoPreviousStep.
@Test
public void testVerifyNoPreviousStep() {
LoadFileInputMeta spy = spy(new LoadFileInputMeta());
FileInputList fileInputList = mock(FileInputList.class);
List<FileObject> files = when(mock(List.class).size()).thenReturn(1).getMock();
doReturn(files).when(fileInputList).getFiles();
doReturn(fileInputList).when(spy).getFiles(any(VariableSpace.class));
@SuppressWarnings("unchecked") List<CheckResultInterface> validationResults = mock(List.class);
// Check we do not get validation errors
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (((CheckResultInterface) invocation.getArguments()[0]).getType() != CheckResultInterface.TYPE_RESULT_OK) {
TestCase.fail("We've got validation error");
}
return null;
}
}).when(validationResults).add(any(CheckResultInterface.class));
spy.check(validationResults, mock(TransMeta.class), mock(StepMeta.class), mock(RowMetaInterface.class), new String[] {}, new String[] { "File content", "File size" }, mock(RowMetaInterface.class), mock(VariableSpace.class), mock(Repository.class), mock(IMetaStore.class));
}
use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.
the class SalesforceUpsertMetaTest method testCheck.
@Test
public void testCheck() {
SalesforceUpsertMeta meta = new SalesforceUpsertMeta();
meta.setDefault();
List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
meta.check(remarks, null, null, null, null, null, null, null, null, null);
boolean hasError = false;
for (CheckResultInterface cr : remarks) {
if (cr.getType() == CheckResult.TYPE_RESULT_ERROR) {
hasError = true;
}
}
assertFalse(remarks.isEmpty());
assertTrue(hasError);
remarks.clear();
meta.setDefault();
meta.setUsername("user");
meta.setUpdateLookup(new String[] { "SalesforceField" });
meta.setUpdateStream(new String[] { "StreamField" });
meta.setUseExternalId(new Boolean[] { false });
meta.check(remarks, null, null, null, null, null, null, null, null, null);
hasError = false;
for (CheckResultInterface cr : remarks) {
if (cr.getType() == CheckResult.TYPE_RESULT_ERROR) {
hasError = true;
}
}
assertFalse(remarks.isEmpty());
assertFalse(hasError);
}
Aggregations