Search in sources :

Example 1 with ValueMetaBase

use of org.apache.hop.core.row.value.ValueMetaBase in project hop by apache.

the class GreenplumValueMetaBaseTest method setUp.

@Before
public void setUp() {
    listener = new StoreLoggingEventListener();
    HopLogStore.getAppender().addLoggingEventListener(listener);
    dbMeta = spy(DatabaseMeta.class);
    dbMeta.setIDatabase(spy(GreenplumDatabaseMeta.class));
    valueMetaBase = new ValueMetaBase();
    resultSet = mock(ResultSet.class);
    variables = spy(new Variables());
}
Also used : IVariables(org.apache.hop.core.variables.IVariables) Variables(org.apache.hop.core.variables.Variables) ResultSet(java.sql.ResultSet) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Example 2 with ValueMetaBase

use of org.apache.hop.core.row.value.ValueMetaBase in project hop by apache.

the class TeradataValueMetaBaseTest method setUp.

@Before
public void setUp() {
    listener = new StoreLoggingEventListener();
    HopLogStore.getAppender().addLoggingEventListener(listener);
    valueMetaBase = new ValueMetaBase();
    dbMeta = spy(new DatabaseMeta());
    dbMeta.setIDatabase(spy(TeradataDatabaseMeta.class));
    resultSet = mock(ResultSet.class);
    variables = spy(new Variables());
}
Also used : IVariables(org.apache.hop.core.variables.IVariables) Variables(org.apache.hop.core.variables.Variables) ResultSet(java.sql.ResultSet) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Example 3 with ValueMetaBase

use of org.apache.hop.core.row.value.ValueMetaBase in project hop by apache.

the class SalesforceUpdateTest method testWriteToSalesForceForNullExtIdField_WithExtIdNO.

@Test
public void testWriteToSalesForceForNullExtIdField_WithExtIdNO() throws Exception {
    SalesforceUpdateMeta meta = generateSalesforceUpdateMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpdateData data = generateSalesforceUpdateData();
    SalesforceUpdate sfInputTransform = new SalesforceUpdate(smh.transformMeta, meta, data, 0, smh.pipelineMeta, smh.pipeline);
    sfInputTransform.init();
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
    rowMeta.addValueMeta(valueMeta);
    data.inputRowMeta = rowMeta;
    sfInputTransform.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.apache.hop.core.row.value.ValueMetaString) RowMeta(org.apache.hop.core.row.RowMeta) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Example 4 with ValueMetaBase

use of org.apache.hop.core.row.value.ValueMetaBase in project hop by apache.

the class SalesforceUpdateTest method testLogMessageInDetailedModeFotWriteToSalesForce.

@Test
public void testLogMessageInDetailedModeFotWriteToSalesForce() throws HopException {
    SalesforceUpdateMeta meta = generateSalesforceUpdateMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpdateData data = generateSalesforceUpdateData();
    SalesforceUpdate sfInputTransform = new SalesforceUpdate(smh.transformMeta, meta, data, 0, smh.pipelineMeta, smh.pipeline);
    sfInputTransform.init();
    when(sfInputTransform.getLogChannel().isDetailed()).thenReturn(true);
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
    rowMeta.addValueMeta(valueMeta);
    data.inputRowMeta = rowMeta;
    verify(sfInputTransform.getLogChannel(), never()).logDetailed(anyString());
    sfInputTransform.writeToSalesForce(new Object[] { "001i000001c5Nv9AAE" });
    verify(sfInputTransform.getLogChannel()).logDetailed("Called writeToSalesForce with 0 out of 2");
}
Also used : ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) RowMeta(org.apache.hop.core.row.RowMeta) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Example 5 with ValueMetaBase

use of org.apache.hop.core.row.value.ValueMetaBase in project hop by apache.

the class SalesforceUpdateTest method testWriteToSalesForceForNotNullExtIdField_WithExtIdNO.

@Test
public void testWriteToSalesForceForNotNullExtIdField_WithExtIdNO() throws Exception {
    SalesforceUpdateMeta meta = generateSalesforceUpdateMeta(new String[] { ACCOUNT_ID }, new Boolean[] { false });
    SalesforceUpdateData data = generateSalesforceUpdateData();
    SalesforceUpdate sfInputTransform = new SalesforceUpdate(smh.transformMeta, meta, data, 0, smh.pipelineMeta, smh.pipeline);
    sfInputTransform.init();
    RowMeta rowMeta = new RowMeta();
    ValueMetaBase valueMeta = new ValueMetaString("AccNoExtId");
    rowMeta.addValueMeta(valueMeta);
    data.inputRowMeta = rowMeta;
    sfInputTransform.writeToSalesForce(new Object[] { "001i000001c5Nv9AAE" });
    XmlObject[] children = SalesforceConnection.getChildren(data.sfBuffer[0]);
    assertNotNull(children);
    assertEquals(0, data.sfBuffer[0].getFieldsToNull().length);
    assertEquals(1, children.length);
    assertEquals(Constants.PARTNER_SOBJECT_NS, children[0].getName().getNamespaceURI());
    assertEquals(ACCOUNT_ID, children[0].getName().getLocalPart());
    assertEquals("001i000001c5Nv9AAE", children[0].getValue());
    assertFalse(children[0].hasChildren());
}
Also used : ValueMetaString(org.apache.hop.core.row.value.ValueMetaString) RowMeta(org.apache.hop.core.row.RowMeta) XmlObject(com.sforce.ws.bind.XmlObject) ValueMetaBase(org.apache.hop.core.row.value.ValueMetaBase)

Aggregations

ValueMetaBase (org.apache.hop.core.row.value.ValueMetaBase)32 RowMeta (org.apache.hop.core.row.RowMeta)25 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)16 IRowMeta (org.apache.hop.core.row.IRowMeta)10 Test (org.junit.Test)5 XmlObject (com.sforce.ws.bind.XmlObject)4 IValueMeta (org.apache.hop.core.row.IValueMeta)4 DatabaseMeta (org.apache.hop.core.database.DatabaseMeta)3 IVariables (org.apache.hop.core.variables.IVariables)3 ResultSet (java.sql.ResultSet)2 ValueMetaInteger (org.apache.hop.core.row.value.ValueMetaInteger)2 Variables (org.apache.hop.core.variables.Variables)2 Matchers.anyString (org.mockito.Matchers.anyString)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringUtils (org.apache.commons.lang.StringUtils)1 FileObject (org.apache.commons.vfs2.FileObject)1 BaseDatabaseMeta (org.apache.hop.core.database.BaseDatabaseMeta)1 IDatabase (org.apache.hop.core.database.IDatabase)1