Search in sources :

Example 21 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class SalesforceUpdateTest method testWriteToSalesForceForNullExtIdField_WithExtIdNO.

@Test
public void testWriteToSalesForceForNullExtIdField_WithExtIdNO() throws Exception {
    SalesforceUpdate sfInputStep = new SalesforceUpdate(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
    SalesforceUpdateMeta meta = generateSalesforceUpdateMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpdateData data = generateSalesforceUpdateData();
    sfInputStep.init(meta, data);
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
    rowMeta.addValueMeta(valueMeta);
    smh.initStepDataInterface.inputRowMeta = rowMeta;
    sfInputStep.writeToSalesForce(new Object[] { null });
    assertEquals(1, data.sfBuffer[0].getFieldsToNull().length);
    assertEquals(ACCOUNT_ID, data.sfBuffer[0].getFieldsToNull()[0]);
    assertNull(SalesforceConnection.getChildren(data.sfBuffer[0]));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 22 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class SalesforceUpsertTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdYES.

@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdYES() throws Exception {
    SalesforceUpsert sfInputStep = new SalesforceUpsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
    SalesforceUpsertMeta meta = generateSalesforceUpsertMeta(new String[] { ACCOUNT_EXT_ID_ACCOUNT_ID_C_ACCOUNT }, new Boolean[] { true });
    SalesforceUpsertData data = generateSalesforceUpsertData();
    sfInputStep.init(meta, data);
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccExtId");
    rowMeta.addValueMeta(valueMeta);
    smh.initStepDataInterface.inputRowMeta = rowMeta;
    String extIdValue = "tkas88";
    sfInputStep.writeToSalesForce(new Object[] { extIdValue });
    assertEquals(0, data.sfBuffer[0].getFieldsToNull().length);
    assertEquals(1, SalesforceConnection.getChildren(data.sfBuffer[0]).length);
    assertEquals(Constants.PARTNER_SOBJECT_NS, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getNamespaceURI());
    assertEquals("Account", SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getLocalPart());
    assertNull(SalesforceConnection.getChildren(data.sfBuffer[0])[0].getValue());
    assertEquals(extIdValue, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getChild(EXT_ID_ACCOUNT_ID_C).getValue());
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) Matchers.anyString(org.mockito.Matchers.anyString) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 23 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class SalesforceUpsertTest method testWriteToSalesForcePentahoIntegerValue.

@Test
public void testWriteToSalesForcePentahoIntegerValue() throws Exception {
    SalesforceUpsert sfInputStep = new SalesforceUpsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
    SalesforceUpsertMeta meta = generateSalesforceUpsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpsertData data = generateSalesforceUpsertData();
    sfInputStep.init(meta, data);
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaInteger("IntValue");
    rowMeta.addValueMeta(valueMeta);
    smh.initStepDataInterface.inputRowMeta = rowMeta;
    sfInputStep.writeToSalesForce(new Object[] { 1L });
    XmlObject sObject = data.sfBuffer[0].getChild(ACCOUNT_ID);
    Assert.assertEquals(sObject.getValue(), 1);
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) XmlObject(com.sforce.ws.bind.XmlObject) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 24 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class SalesforceUpsertTest method testLogMessageInDetailedModeFotWriteToSalesForce.

@Test
public void testLogMessageInDetailedModeFotWriteToSalesForce() throws KettleException {
    SalesforceUpsert sfInputStep = new SalesforceUpsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
    SalesforceUpsertMeta meta = generateSalesforceUpsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpsertData data = generateSalesforceUpsertData();
    sfInputStep.init(meta, data);
    when(sfInputStep.getLogChannel().isDetailed()).thenReturn(true);
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
    rowMeta.addValueMeta(valueMeta);
    smh.initStepDataInterface.inputRowMeta = rowMeta;
    verify(sfInputStep.getLogChannel(), never()).logDetailed(anyString());
    sfInputStep.writeToSalesForce(new Object[] { "001i000001c5Nv9AAE" });
    verify(sfInputStep.getLogChannel()).logDetailed("Called writeToSalesForce with 0 out of 2");
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 25 with ValueMetaBase

use of org.pentaho.di.core.row.value.ValueMetaBase in project pentaho-kettle by pentaho.

the class SalesforceUpsertTest method testWriteToSalesForceForNullExtIdField_WithExtIdNO.

@Test
public void testWriteToSalesForceForNullExtIdField_WithExtIdNO() throws Exception {
    SalesforceUpsert sfInputStep = new SalesforceUpsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
    SalesforceUpsertMeta meta = generateSalesforceUpsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpsertData data = generateSalesforceUpsertData();
    sfInputStep.init(meta, data);
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
    rowMeta.addValueMeta(valueMeta);
    smh.initStepDataInterface.inputRowMeta = rowMeta;
    sfInputStep.writeToSalesForce(new Object[] { null });
    assertEquals(1, data.sfBuffer[0].getFieldsToNull().length);
    assertEquals(ACCOUNT_ID, data.sfBuffer[0].getFieldsToNull()[0]);
    assertNull(SalesforceConnection.getChildren(data.sfBuffer[0]));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Aggregations

ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)31 RowMeta (org.pentaho.di.core.row.RowMeta)26 Test (org.junit.Test)25 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)16 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)13 ArrayList (java.util.ArrayList)7 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)7 Matchers.anyString (org.mockito.Matchers.anyString)3 Strings.nullToEmpty (com.google.common.base.Strings.nullToEmpty)2 XmlObject (com.sforce.ws.bind.XmlObject)2 List (java.util.List)2 SWT (org.eclipse.swt.SWT)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)2 CTabItem (org.eclipse.swt.custom.CTabItem)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 Image (org.eclipse.swt.graphics.Image)2 FormAttachment (org.eclipse.swt.layout.FormAttachment)2 FormData (org.eclipse.swt.layout.FormData)2 FormLayout (org.eclipse.swt.layout.FormLayout)2 Button (org.eclipse.swt.widgets.Button)2