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]));
}
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());
}
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);
}
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");
}
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]));
}
Aggregations