use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class SalesforceDeleteMetaTest method testGetFields.
@Test
public void testGetFields() throws KettleStepException {
SalesforceDeleteMeta meta = new SalesforceDeleteMeta();
meta.setDefault();
RowMetaInterface r = new RowMeta();
meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
assertEquals(0, r.size());
r.clear();
r.addValueMeta(new ValueMetaString("testString"));
meta.getFields(r, "thisStep", null, null, new Variables(), null, null);
assertEquals(1, r.size());
assertEquals(ValueMetaInterface.TYPE_STRING, r.getValueMeta(0).getType());
assertEquals("testString", r.getValueMeta(0).getName());
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class SalesforceInputTest method doConversions.
@Test
public void doConversions() throws Exception {
StepMeta stepMeta = new StepMeta();
String name = "test";
stepMeta.setName(name);
StepDataInterface stepDataInterface = Mockito.mock(StepDataInterface.class);
int copyNr = 0;
TransMeta transMeta = Mockito.mock(TransMeta.class);
Trans trans = Mockito.mock(Trans.class);
Mockito.when(transMeta.findStep(Mockito.eq(name))).thenReturn(stepMeta);
SalesforceInput salesforceInput = new SalesforceInput(stepMeta, stepDataInterface, copyNr, transMeta, trans);
SalesforceInputMeta meta = new SalesforceInputMeta();
SalesforceInputData data = new SalesforceInputData();
data.outputRowMeta = Mockito.mock(RowMeta.class);
Mockito.when(data.outputRowMeta.getValueMeta(Mockito.eq(0))).thenReturn(new ValueMetaBinary());
data.convertRowMeta = Mockito.mock(RowMeta.class);
Mockito.when(data.convertRowMeta.getValueMeta(Mockito.eq(0))).thenReturn(new ValueMetaString());
Field metaField = salesforceInput.getClass().getDeclaredField("meta");
metaField.setAccessible(true);
metaField.set(salesforceInput, meta);
Field dataField = salesforceInput.getClass().getDeclaredField("data");
dataField.setAccessible(true);
dataField.set(salesforceInput, data);
Object[] outputRowData = new Object[1];
byte[] binary = { 0, 1, 0, 1, 1, 1 };
salesforceInput.doConversions(outputRowData, 0, new String(Base64.encode(binary)));
Assert.assertArrayEquals(binary, (byte[]) outputRowData[0]);
binary = new byte[0];
salesforceInput.doConversions(outputRowData, 0, new String(Base64.encode(binary)));
Assert.assertArrayEquals(binary, (byte[]) outputRowData[0]);
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class SalesforceInsertTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdNO.
@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdNO() throws Exception {
SalesforceInsert sfInputStep = new SalesforceInsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceInsertMeta meta = generateSalesforceInsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
SalesforceInsertData data = generateSalesforceInsertData();
sfInputStep.init(meta, data);
RowMeta rowMeta = new RowMeta();
ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
rowMeta.addValueMeta(valueMeta);
smh.initStepDataInterface.inputRowMeta = rowMeta;
sfInputStep.writeToSalesForce(new Object[] { "001i000001c5Nv9AAE" });
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_ID, SalesforceConnection.getChildren(data.sfBuffer[0])[0].getName().getLocalPart());
assertEquals("001i000001c5Nv9AAE", SalesforceConnection.getChildren(data.sfBuffer[0])[0].getValue());
assertFalse(SalesforceConnection.getChildren(data.sfBuffer[0])[0].hasChildren());
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class SalesforceInsertTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdYES.
@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdYES() throws Exception {
SalesforceInsert sfInputStep = new SalesforceInsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceInsertMeta meta = generateSalesforceInsertMeta(new String[] { ACCOUNT_EXT_ID_ACCOUNT_ID_C_ACCOUNT }, new Boolean[] { true });
SalesforceInsertData data = generateSalesforceInsertData();
sfInputStep.init(meta, data);
RowMeta rowMeta = new RowMeta();
ValueMetaBase valueMeta = new ValueMetaString("AccExtId");
rowMeta.addValueMeta(valueMeta);
smh.initStepDataInterface.inputRowMeta = rowMeta;
sfInputStep.writeToSalesForce(new Object[] { "tkas88" });
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());
assertFalse(SalesforceConnection.getChildren(data.sfBuffer[0])[0].hasChildren());
}
use of org.pentaho.di.core.row.value.ValueMetaString in project pentaho-kettle by pentaho.
the class SalesforceInsertTest method testLogMessageInDetailedModeFotWriteToSalesForce.
@Test
public void testLogMessageInDetailedModeFotWriteToSalesForce() throws KettleException {
SalesforceInsert sfInputStep = new SalesforceInsert(smh.stepMeta, smh.stepDataInterface, 0, smh.transMeta, smh.trans);
SalesforceInsertMeta meta = generateSalesforceInsertMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
SalesforceInsertData data = generateSalesforceInsertData();
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");
}
Aggregations