Search in sources :

Example 11 with CheckResultInterface

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

Example 12 with CheckResultInterface

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

Example 13 with CheckResultInterface

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

Example 14 with CheckResultInterface

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

Example 15 with CheckResultInterface

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