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