Search in sources :

Example 31 with CheckResultInterface

use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.

the class MQTTConsumerMetaTest method testCheckDefaults.

@Test
public void testCheckDefaults() {
    List<CheckResultInterface> remarks = new ArrayList<>();
    meta.check(remarks, null, null, null, null, null, null, new Variables(), 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)

Example 32 with CheckResultInterface

use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.

the class MQTTConsumerMetaTest method testCheckFailAll.

@Test
public void testCheckFailAll() {
    List<CheckResultInterface> remarks = new ArrayList<>();
    meta.setKeepAliveInterval("asdf");
    meta.setMaxInflight("asdf");
    meta.setConnectionTimeout("asdf");
    meta.setCleanSession("asdf");
    meta.setAutomaticReconnect("adsf");
    meta.setMqttVersion("9");
    meta.check(remarks, null, null, null, null, null, null, new Variables(), null, null);
    assertEquals(6, remarks.size());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotANumber", BaseMessages.getString(PKG, "MQTTDialog.Options." + KEEP_ALIVE_INTERVAL)), remarks.get(0).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotANumber", BaseMessages.getString(PKG, "MQTTDialog.Options." + MAX_INFLIGHT)), remarks.get(1).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotANumber", BaseMessages.getString(PKG, "MQTTDialog.Options." + CONNECTION_TIMEOUT)), remarks.get(2).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotABoolean", BaseMessages.getString(PKG, "MQTTDialog.Options." + CLEAN_SESSION)), remarks.get(3).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotCorrectVersion", BaseMessages.getString(PKG, "MQTTDialog.Options." + MQTT_VERSION)), remarks.get(4).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotABoolean", BaseMessages.getString(PKG, "MQTTDialog.Options." + AUTOMATIC_RECONNECT)), remarks.get(5).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 33 with CheckResultInterface

use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.

the class MQTTProducerMetaTest method testCheckOptionsFail.

@Test
public void testCheckOptionsFail() {
    List<CheckResultInterface> remarks = new ArrayList<>();
    MQTTProducerMeta meta = new MQTTProducerMeta();
    meta.setMqttServer("theserver:1883");
    meta.setClientId("client100");
    meta.setTopic("newtopic");
    meta.setQOS("2");
    meta.setMessageField("Messages");
    meta.setUsername("testuser");
    meta.setKeepAliveInterval("asdf");
    meta.setMaxInflight("asdf");
    meta.setConnectionTimeout("asdf");
    meta.setCleanSession("asdf");
    meta.setAutomaticReconnect("adsf");
    meta.setMqttVersion("asdf");
    meta.check(remarks, null, null, null, null, null, null, new Variables(), null, null);
    assertEquals(6, remarks.size());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotANumber", BaseMessages.getString(PKG, "MQTTDialog.Options." + KEEP_ALIVE_INTERVAL)), remarks.get(0).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotANumber", BaseMessages.getString(PKG, "MQTTDialog.Options." + MAX_INFLIGHT)), remarks.get(1).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotANumber", BaseMessages.getString(PKG, "MQTTDialog.Options." + CONNECTION_TIMEOUT)), remarks.get(2).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotABoolean", BaseMessages.getString(PKG, "MQTTDialog.Options." + CLEAN_SESSION)), remarks.get(3).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotCorrectVersion", BaseMessages.getString(PKG, "MQTTDialog.Options." + MQTT_VERSION)), remarks.get(4).getText());
    assertEquals(BaseMessages.getString(PKG, "MQTTMeta.CheckResult.NotABoolean", BaseMessages.getString(PKG, "MQTTDialog.Options." + AUTOMATIC_RECONNECT)), remarks.get(5).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 34 with CheckResultInterface

use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.

the class SalesforceMetaTest method testBaseCheck.

@SuppressWarnings("deprecation")
@Test
public void testBaseCheck() {
    SalesforceStepMeta meta = mock(SalesforceStepMeta.class, Mockito.CALLS_REAL_METHODS);
    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("anonymous");
    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);
    remarks.clear();
    meta.setDefault();
    meta.setTargetURL(null);
    meta.setUserName("anonymous");
    meta.setPassword("password");
    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());
    assertTrue(hasError);
    remarks.clear();
    meta.setDefault();
    meta.setUsername("anonymous");
    meta.setModule(null);
    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());
    assertTrue(hasError);
}
Also used : ArrayList(java.util.ArrayList) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) Test(org.junit.Test)

Example 35 with CheckResultInterface

use of org.pentaho.di.core.CheckResultInterface in project pentaho-kettle by pentaho.

the class SalesforceInputMetaTest method testCheck.

@Test
public void testCheck() {
    SalesforceInputMeta meta = new SalesforceInputMeta();
    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.setInputFields(new SalesforceInputField[] { new SalesforceInputField("test") });
    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);
    remarks.clear();
    meta.setDefault();
    meta.setUsername("user");
    meta.setIncludeDeletionDate(true);
    meta.setIncludeModule(true);
    meta.setIncludeRowNumber(true);
    meta.setIncludeSQL(true);
    meta.setIncludeTargetURL(true);
    meta.setIncludeTimestamp(true);
    meta.setInputFields(new SalesforceInputField[] { new SalesforceInputField("test") });
    meta.check(remarks, null, null, null, null, null, null, null, null, null);
    hasError = false;
    int errorCount = 0;
    for (CheckResultInterface cr : remarks) {
        if (cr.getType() == CheckResult.TYPE_RESULT_ERROR) {
            hasError = true;
            errorCount++;
        }
    }
    assertFalse(remarks.isEmpty());
    assertTrue(hasError);
    assertEquals(6, errorCount);
    remarks.clear();
    meta.setDefault();
    meta.setUsername("user");
    meta.setIncludeDeletionDate(true);
    meta.setDeletionDateField("delDate");
    meta.setIncludeModule(true);
    meta.setModuleField("mod");
    meta.setIncludeRowNumber(true);
    meta.setRowNumberField("rownum");
    meta.setIncludeSQL(true);
    meta.setSQLField("theSQL");
    meta.setIncludeTargetURL(true);
    meta.setTargetURLField("theURL");
    meta.setIncludeTimestamp(true);
    meta.setTimestampField("ts_Field");
    meta.setInputFields(new SalesforceInputField[] { new SalesforceInputField("test") });
    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;
            errorCount++;
        }
    }
    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