Search in sources :

Example 11 with ValueMetaBase

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

the class TextFileOutputTest method testFastDumpDisableStreamEncodeTest.

/**
 * Test for PDI-13987
 * @throws Exception
 */
@Test
public void testFastDumpDisableStreamEncodeTest() throws Exception {
    textFileOutput = new TextFileOutputTestHandler(stepMockHelper.stepMeta, stepMockHelper.stepDataInterface, 0, stepMockHelper.transMeta, stepMockHelper.trans);
    textFileOutput.meta = stepMockHelper.processRowsStepMetaInterface;
    String testString = "ÖÜä";
    String inputEncode = "UTF-8";
    String outputEncode = "Windows-1252";
    Object[] rows = { testString.getBytes(inputEncode) };
    ValueMetaBase valueMetaInterface = new ValueMetaBase("test", ValueMetaInterface.TYPE_STRING);
    valueMetaInterface.setStringEncoding(inputEncode);
    valueMetaInterface.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
    valueMetaInterface.setStorageMetadata(new ValueMetaString());
    TextFileOutputData data = new TextFileOutputData();
    data.binarySeparator = " ".getBytes();
    data.binaryEnclosure = "\"".getBytes();
    data.binaryNewline = "\n".getBytes();
    textFileOutput.data = data;
    RowMeta rowMeta = new RowMeta();
    rowMeta.addValueMeta(valueMetaInterface);
    Mockito.doReturn(outputEncode).when(stepMockHelper.processRowsStepMetaInterface).getEncoding();
    textFileOutput.data.writer = Mockito.mock(BufferedOutputStream.class);
    textFileOutput.writeRow(rowMeta, rows);
    Mockito.verify(textFileOutput.data.writer, Mockito.times(1)).write(testString.getBytes(outputEncode));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) FileObject(org.apache.commons.vfs2.FileObject) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) BufferedOutputStream(java.io.BufferedOutputStream) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 12 with ValueMetaBase

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

the class BaseStepTest method nullFieldName.

@Test(expected = KettleStepException.class)
public void nullFieldName() 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(null, 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 13 with ValueMetaBase

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

the class SSTableOutputIT method testCQLS2SSTableWriter.

@Test
public void testCQLS2SSTableWriter() throws Exception {
    SSTableOutput ssTableOutput = new SSTableOutput(helper.stepMeta, helper.stepDataInterface, 0, helper.transMeta, helper.trans);
    ValueMetaInterface one = new ValueMetaBase("key", ValueMetaBase.TYPE_INTEGER);
    ValueMetaInterface two = new ValueMetaBase("two", ValueMetaBase.TYPE_STRING);
    List<ValueMetaInterface> valueMetaList = new ArrayList<ValueMetaInterface>();
    valueMetaList.add(one);
    valueMetaList.add(two);
    String[] fieldNames = new String[] { "key", "two" };
    RowMetaInterface inputRowMeta = mock(RowMetaInterface.class);
    when(inputRowMeta.clone()).thenReturn(inputRowMeta);
    when(inputRowMeta.size()).thenReturn(2);
    when(inputRowMeta.getFieldNames()).thenReturn(fieldNames);
    when(inputRowMeta.getValueMetaList()).thenReturn(valueMetaList);
    RowSet rowset = helper.getMockInputRowSet(new Object[] { 1, "some" });
    when(rowset.getRowMeta()).thenReturn(inputRowMeta);
    ssTableOutput.addRowSetToInputRowSets(rowset);
    SSTableOutputMeta meta = createStepMeta(false);
    ssTableOutput.init(meta, helper.initStepDataInterface);
    ssTableOutput.processRow(meta, helper.processRowsStepDataInterface);
    Assert.assertEquals("Step init error.", 0, ssTableOutput.getErrors());
    assertEquals("org.pentaho.di.trans.steps.cassandrasstableoutput.writer.CQL2SSTableWriter", ssTableOutput.writer.getClass().getName());
    ssTableOutput.dispose(meta, helper.initStepDataInterface);
    Assert.assertEquals("Step dispose error", 0, ssTableOutput.getErrors());
}
Also used : ArrayList(java.util.ArrayList) RowSet(org.pentaho.di.core.RowSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Matchers.anyString(org.mockito.Matchers.anyString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 14 with ValueMetaBase

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

the class SSTableOutputIT method testCQLS3SSTableWriter.

@Test
public void testCQLS3SSTableWriter() throws Exception {
    SSTableOutput ssTableOutput = new SSTableOutput(helper.stepMeta, helper.stepDataInterface, 0, helper.transMeta, helper.trans);
    i = new AtomicInteger(0);
    ValueMetaInterface one = new ValueMetaBase("key", ValueMetaBase.TYPE_INTEGER);
    ValueMetaInterface two = new ValueMetaBase("two", ValueMetaBase.TYPE_STRING);
    List<ValueMetaInterface> valueMetaList = new ArrayList<ValueMetaInterface>();
    valueMetaList.add(one);
    valueMetaList.add(two);
    String[] fieldNames = new String[] { "key", "two" };
    RowMetaInterface inputRowMeta = mock(RowMetaInterface.class);
    when(inputRowMeta.clone()).thenReturn(inputRowMeta);
    when(inputRowMeta.size()).thenReturn(2);
    when(inputRowMeta.getFieldNames()).thenReturn(fieldNames);
    when(inputRowMeta.getValueMetaList()).thenReturn(valueMetaList);
    when(inputRowMeta.indexOfValue(anyString())).thenAnswer(new Answer<Integer>() {

        @Override
        public Integer answer(InvocationOnMock invocation) throws Throwable {
            return i.getAndIncrement();
        }
    });
    RowSet rowset = helper.getMockInputRowSet(new Object[] { 1L, "some" });
    when(rowset.getRowMeta()).thenReturn(inputRowMeta);
    ssTableOutput.addRowSetToInputRowSets(rowset);
    SSTableOutputMeta meta = createStepMeta(true);
    ssTableOutput.init(meta, helper.initStepDataInterface);
    ssTableOutput.processRow(meta, helper.processRowsStepDataInterface);
    Assert.assertEquals("Step init error.", 0, ssTableOutput.getErrors());
    assertEquals("org.pentaho.di.trans.steps.cassandrasstableoutput.writer.CQL3SSTableWriter", ssTableOutput.writer.getClass().getName());
    ssTableOutput.dispose(meta, helper.initStepDataInterface);
    Assert.assertEquals("Step dispose error", 0, ssTableOutput.getErrors());
}
Also used : ArrayList(java.util.ArrayList) RowSet(org.pentaho.di.core.RowSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Matchers.anyString(org.mockito.Matchers.anyString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) Test(org.junit.Test)

Example 15 with ValueMetaBase

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

the class TransLogTable method getRecommendedIndexes.

public List<RowMetaInterface> getRecommendedIndexes() {
    List<RowMetaInterface> indexes = new ArrayList<RowMetaInterface>();
    // 
    if (isBatchIdUsed()) {
        RowMetaInterface batchIndex = new RowMeta();
        LogTableField keyField = getKeyField();
        ValueMetaInterface keyMeta = new ValueMetaBase(keyField.getFieldName(), keyField.getDataType());
        keyMeta.setLength(keyField.getLength());
        batchIndex.addValueMeta(keyMeta);
        indexes.add(batchIndex);
    }
    // The next index includes : ERRORS, STATUS, TRANSNAME:
    RowMetaInterface lookupIndex = new RowMeta();
    LogTableField errorsField = findField(ID.ERRORS);
    if (errorsField != null) {
        ValueMetaInterface valueMeta = new ValueMetaBase(errorsField.getFieldName(), errorsField.getDataType());
        valueMeta.setLength(errorsField.getLength());
        lookupIndex.addValueMeta(valueMeta);
    }
    LogTableField statusField = findField(ID.STATUS);
    if (statusField != null) {
        ValueMetaInterface valueMeta = new ValueMetaBase(statusField.getFieldName(), statusField.getDataType());
        valueMeta.setLength(statusField.getLength());
        lookupIndex.addValueMeta(valueMeta);
    }
    LogTableField transNameField = findField(ID.TRANSNAME);
    if (transNameField != null) {
        ValueMetaInterface valueMeta = new ValueMetaBase(transNameField.getFieldName(), transNameField.getDataType());
        valueMeta.setLength(transNameField.getLength());
        lookupIndex.addValueMeta(valueMeta);
    }
    indexes.add(lookupIndex);
    return indexes;
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase)

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