Search in sources :

Example 26 with CheckResultInterface

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());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 27 with CheckResultInterface

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());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) Test(org.junit.Test)

Example 28 with CheckResultInterface

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);
}
Also used : Variables(org.pentaho.di.core.variables.Variables) ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) Test(org.junit.Test)

Example 29 with CheckResultInterface

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));
}
Also used : VariableSpace(org.pentaho.di.core.variables.VariableSpace) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Repository(org.pentaho.di.repository.Repository) InvocationOnMock(org.mockito.invocation.InvocationOnMock) FileObject(javax.tools.FileObject) FileObject(javax.tools.FileObject) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) FileInputList(org.pentaho.di.core.fileinput.FileInputList) Test(org.junit.Test)

Example 30 with CheckResultInterface

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);
}
Also used : ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) SalesforceMetaTest(org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest) Test(org.junit.Test)

Aggregations

CheckResultInterface (org.pentaho.di.core.CheckResultInterface)37 ArrayList (java.util.ArrayList)33 Test (org.junit.Test)23 Variables (org.pentaho.di.core.variables.Variables)20 TransMeta (org.pentaho.di.trans.TransMeta)8 StepMeta (org.pentaho.di.trans.step.StepMeta)8 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)7 Repository (org.pentaho.di.repository.Repository)6 IMetaStore (org.pentaho.metastore.api.IMetaStore)6 SalesforceMetaTest (org.pentaho.di.trans.steps.salesforce.SalesforceMetaTest)5 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)4 KettleException (org.pentaho.di.core.exception.KettleException)4 VariableSpace (org.pentaho.di.core.variables.VariableSpace)3 Result (org.pentaho.di.core.Result)2 KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 Trans (org.pentaho.di.trans.Trans)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Throwables (com.google.common.base.Throwables)1