Search in sources :

Example 26 with ValueMetaBase

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

the class SalesforceUpsertTest method testWriteToSalesForceForNullExtIdField_WithExtIdYES.

@Test
public void testWriteToSalesForceForNullExtIdField_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;
    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 27 with ValueMetaBase

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

the class SalesforceInsertTest method testWriteToSalesForceForNullExtIdField_WithExtIdNO.

@Test
public void testWriteToSalesForceForNullExtIdField_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[] { 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 28 with ValueMetaBase

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

the class SalesforceInsertTest method testWriteToSalesForcePentahoIntegerValue.

@Test
public void testWriteToSalesForcePentahoIntegerValue() 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 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 29 with ValueMetaBase

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

the class BaseStepTest method notEmptyFieldName.

@Test
public void notEmptyFieldName() throws KettleStepException {
    BaseStep baseStep = new BaseStep(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
    baseStep.setRowHandler(rowHandler);
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaBase("name", ValueMetaInterface.TYPE_INTEGER));
    baseStep.putRow(rowMeta, new Object[] { 0 });
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 30 with ValueMetaBase

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

the class BaseStepTest method blankFieldName.

@Test(expected = KettleStepException.class)
public void blankFieldName() throws KettleStepException {
    BaseStep baseStep = new BaseStep(mockHelper.stepMeta, mockHelper.stepDataInterface, 0, mockHelper.transMeta, mockHelper.trans);
    baseStep.setRowHandler(rowHandler);
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaBase("  ", ValueMetaInterface.TYPE_INTEGER));
    baseStep.putRow(rowMeta, new Object[] { 0 });
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) 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