org.pentaho.di.core.row.value.ValueMetaString Java Examples
The following examples show how to use
org.pentaho.di.core.row.value.ValueMetaString.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoDbOutputTest.java From pentaho-mongodb-plugin with Apache License 2.0 | 6 votes |
@Test public void testTopLevelArrayStructureWithPrimitives() throws Exception { List<MongoDbOutputMeta.MongoField> paths = asList( mf( "field1", false, "[0]" ), mf( "field2", false, "[1]" ) ); RowMetaInterface rmi = new RowMeta(); rmi.addValueMeta( new ValueMetaString( "field1" ) ); rmi.addValueMeta( new ValueMetaInteger( "field2" ) ); Object[] row = new Object[ 2 ]; row[ 0 ] = "value1"; row[ 1 ] = 12L; VariableSpace vs = new Variables(); for ( MongoDbOutputMeta.MongoField f : paths ) { f.init( vs ); } DBObject result = kettleRowToMongo( paths, rmi, row, MongoDbOutputData.MongoTopLevel.ARRAY, false ); assertEquals( JSON.serialize( result ), "[ \"value1\" , 12]" ); }
Example #2
Source File: KettleDatabaseRepositoryConnectionDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public RowMetaAndData getJobAttributeRow( ObjectId id_job, int nr, String code ) throws KettleException { RowMetaAndData par = new RowMetaAndData(); par.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB ), id_job ); par.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_CODE ), code ); par.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_NR ), new Long( nr ) ); if ( psJobAttributesLookup == null ) { setLookupJobAttribute(); } database.setValues( par, psJobAttributesLookup ); return callRead( new Callable<RowMetaAndData>() { @Override public RowMetaAndData call() throws Exception { Object[] r = database.getLookup( psJobAttributesLookup ); if ( r == null ) { return null; } return new RowMetaAndData( database.getReturnRowMeta(), r ); } } ); }
Example #3
Source File: JaninoStepIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public RowMetaInterface createRowMetaInterface() { RowMetaInterface rm = new RowMeta(); ValueMetaInterface[] valuesMeta = { new ValueMetaString( "string" ), new ValueMetaInteger( "integer" ), new ValueMetaNumber( "number" ), new ValueMetaBigNumber( "bigdecimal" ), new ValueMetaDate( "date" ), new ValueMetaBinary( "binary" ), new ValueMetaBoolean( "bool" ), new ValueMetaTimestamp( "timestamp" ), new ValueMetaInternetAddress( "inetaddress" ), }; for ( int i = 0; i < valuesMeta.length; i++ ) { rm.addValueMeta( valuesMeta[i] ); } return rm; }
Example #4
Source File: TextFileInputTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private TextFileInputData createDataObject( String file, String separator, String... outputFields ) throws Exception { TextFileInputData data = new TextFileInputData(); data.files = new FileInputList(); data.files.addFile( KettleVFS.getFileObject( file ) ); data.separator = separator; data.outputRowMeta = new RowMeta(); if ( outputFields != null ) { for ( String field : outputFields ) { data.outputRowMeta.addValueMeta( new ValueMetaString( field ) ); } } data.dataErrorLineHandler = mock( FileErrorHandler.class ); data.fileFormatType = TextFileInputMeta.FILE_FORMAT_UNIX; data.filterProcessor = new TextFileFilterProcessor( new TextFileFilter[ 0 ], new Variables() ); data.filePlayList = new FilePlayListAll(); return data; }
Example #5
Source File: TransSingleThreadIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public RowMetaInterface createRowMetaInterface() { RowMetaInterface rm = new RowMeta(); ValueMetaInterface[] valuesMeta = { new ValueMetaString( "field1" ), new ValueMetaInteger( "field2" ), new ValueMetaNumber( "field3" ), new ValueMetaDate( "field4" ), new ValueMetaBoolean( "field5" ), new ValueMetaBigNumber( "field6" ), new ValueMetaBigNumber( "field7" ), }; for ( int i = 0; i < valuesMeta.length; i++ ) { rm.addValueMeta( valuesMeta[i] ); } return rm; }
Example #6
Source File: JavaScriptStringIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Create the meta data for the results (lpad/rpad/upper/lower). */ public RowMetaInterface createRowMetaInterfaceResult2() { RowMetaInterface rm = new RowMeta(); ValueMetaInterface[] valuesMeta = { new ValueMetaString( "string" ), new ValueMetaString( "lpadded1" ), new ValueMetaString( "lpadded2" ), new ValueMetaString( "rpadded1" ), new ValueMetaString( "rpadded2" ), new ValueMetaString( "upperStr" ), new ValueMetaString( "lowerStr" ), }; for ( int i = 0; i < valuesMeta.length; i++ ) { rm.addValueMeta( valuesMeta[ i ] ); } return rm; }
Example #7
Source File: CheckSumTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testHexOutput_md5() throws Exception { MockRowListener results = executeHexTest( 2, false, "xyz", new ValueMetaString( "test" ), false ); assertEquals( 1, results.getWritten().size() ); assertEquals( "d16fb36f0911f878998c136191af705e", results.getWritten().get( 0 )[1] ); results = executeHexTest( 2, false, 10.8, new ValueMetaNumber( "test" ), false ); assertEquals( 1, results.getWritten().size() ); assertEquals( "372df98e33ac1bf6b26d225361ba7eb5", results.getWritten().get( 0 )[1] ); results = executeHexTest( 2, false, 10.82, new ValueMetaNumber( "test" ), false ); assertEquals( 1, results.getWritten().size() ); assertEquals( "68b142f87143c917f29d178aa1715957", results.getWritten().get( 0 )[1] ); byte[] input = IOUtils.toByteArray( getFile( "/org/pentaho/di/trans/steps/loadfileinput/files/pentaho_splash.png" ) .getContent().getInputStream() ); results = executeHexTest( 2, false, input, new ValueMetaBinary( "test" ), false ); assertEquals( 1, results.getWritten().size() ); assertEquals( "8d808ff9051fdbfd8050f762daddf813", results.getWritten().get( 0 )[1] ); }
Example #8
Source File: RowTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private RowMetaInterface createTestRowMetaIndexedStringConversion1( String[] colors, Date[] dates ) { RowMetaInterface rowMeta = new RowMeta(); // A string object, indexed. ValueMetaInterface meta1 = new ValueMetaString( "stringValue", 30, 0 ); meta1.setIndex( colors ); meta1.setStorageType( ValueMetaInterface.STORAGE_TYPE_INDEXED ); rowMeta.addValueMeta( meta1 ); ValueMetaInterface meta2 = new ValueMetaDate( "dateValue" ); meta2.setIndex( dates ); meta2.setStorageType( ValueMetaInterface.STORAGE_TYPE_INDEXED ); rowMeta.addValueMeta( meta2 ); return rowMeta; }
Example #9
Source File: EnterValueDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private ValueMetaAndData getValue( String valuename ) throws KettleValueException { try { int valtype = ValueMetaFactory.getIdForValueMeta( wValueType.getText() ); ValueMetaAndData val = new ValueMetaAndData( valuename, wInputString.getText() ); ValueMetaInterface valueMeta = ValueMetaFactory.cloneValueMeta( val.getValueMeta(), valtype ); Object valueData = val.getValueData(); int formatIndex = wFormat.getSelectionIndex(); valueMeta.setConversionMask( formatIndex >= 0 ? wFormat.getItem( formatIndex ) : wFormat.getText() ); valueMeta.setLength( Const.toInt( wLength.getText(), -1 ) ); valueMeta.setPrecision( Const.toInt( wPrecision.getText(), -1 ) ); val.setValueMeta( valueMeta ); ValueMetaInterface stringValueMeta = new ValueMetaString( valuename ); stringValueMeta.setConversionMetadata( valueMeta ); Object targetData = stringValueMeta.convertDataUsingConversionMetaData( valueData ); val.setValueData( targetData ); return val; } catch ( Exception e ) { throw new KettleValueException( e ); } }
Example #10
Source File: FixedFileInputField.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String getXML() { StringBuilder retval = new StringBuilder( 300 ); retval.append( " " ).append( XMLHandler.openTag( XML_TAG ) ).append( Const.CR ); retval.append( " " ).append( XMLHandler.addTagValue( "name", name ) ); retval.append( " " ).append( XMLHandler.addTagValue( "type", ValueMetaFactory.getValueMetaName( type ) ) ); retval.append( " " ).append( XMLHandler.addTagValue( "format", format ) ); retval.append( " " ).append( XMLHandler.addTagValue( "trim_type", ValueMetaString.getTrimTypeCode( trimType ) ) ); retval.append( " " ).append( XMLHandler.addTagValue( "currency", currency ) ); retval.append( " " ).append( XMLHandler.addTagValue( "decimal", decimal ) ); retval.append( " " ).append( XMLHandler.addTagValue( "group", grouping ) ); retval.append( " " ).append( XMLHandler.addTagValue( "width", width ) ); retval.append( " " ).append( XMLHandler.addTagValue( "length", length ) ); retval.append( " " ).append( XMLHandler.addTagValue( "precision", precision ) ); retval.append( " " ).append( XMLHandler.closeTag( XML_TAG ) ).append( Const.CR ); return retval.toString(); }
Example #11
Source File: KafkaConsumerTest.java From pentaho-kafka-consumer with Apache License 2.0 | 6 votes |
/** * @param rowCount The number of rows that should be returned * @param hasFields Whether a "UUID" field should be added to each row * @return A RowMetaAndData object that can be used for input data in a test transformation */ private static List<RowMetaAndData> generateInputData(int rowCount, boolean hasFields) { List<RowMetaAndData> retval = new ArrayList<RowMetaAndData>(); RowMetaInterface rowMeta = new RowMeta(); if (hasFields) { rowMeta.addValueMeta(new ValueMetaString("UUID")); } for (int i = 0; i < rowCount; i++) { Object[] data = new Object[0]; if (hasFields) { data = new Object[]{UUID.randomUUID().toString()}; } retval.add(new RowMetaAndData(rowMeta, data)); } return retval; }
Example #12
Source File: PentahoOrcReadWriteTest.java From pentaho-hadoop-shims with Apache License 2.0 | 6 votes |
private ValueMetaInterface getValueMetaInterface( String fieldName, int fieldType ) { switch ( fieldType ) { case ValueMetaInterface.TYPE_INET: return new ValueMetaInternetAddress( fieldName ); case ValueMetaInterface.TYPE_STRING: return new ValueMetaString( fieldName ); case ValueMetaInterface.TYPE_INTEGER: return new ValueMetaInteger( fieldName ); case ValueMetaInterface.TYPE_NUMBER: return new ValueMetaNumber( fieldName ); case ValueMetaInterface.TYPE_BIGNUMBER: return new ValueMetaBigNumber( fieldName ); case ValueMetaInterface.TYPE_TIMESTAMP: return new ValueMetaTimestamp( fieldName ); case ValueMetaInterface.TYPE_DATE: return new ValueMetaDate( fieldName ); case ValueMetaInterface.TYPE_BOOLEAN: return new ValueMetaBoolean( fieldName ); case ValueMetaInterface.TYPE_BINARY: return new ValueMetaBinary( fieldName ); } return null; }
Example #13
Source File: VerticaDatabaseMetaTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testSQLStatements() { assertEquals( " LIMIT 5", nativeMeta.getLimitClause( 5 ) ); assertEquals( "--NOTE: Table cannot be altered unless all projections are dropped.\nALTER TABLE FOO ADD BAR VARCHAR(15)", nativeMeta.getAddColumnStatement( "FOO", new ValueMetaString( "BAR", 15, 0 ), "", false, "", false ) ); assertEquals( "--NOTE: Table cannot be altered unless all projections are dropped.\nALTER TABLE FOO ALTER COLUMN BAR SET DATA TYPE VARCHAR(15)", nativeMeta.getModifyColumnStatement( "FOO", new ValueMetaString( "BAR", 15, 0 ), "", false, "", false ) ); assertEquals( "SELECT FOO FROM BAR LIMIT 1", nativeMeta.getSQLColumnExists( "FOO", "BAR" ) ); assertEquals( "SELECT * FROM FOO LIMIT 1", nativeMeta.getSQLQueryFields( "FOO" ) ); assertEquals( "SELECT 1 FROM FOO LIMIT 1", nativeMeta.getSQLTableExists( "FOO" ) ); assertEquals( "SELECT sequence_name FROM sequences WHERE sequence_name = 'FOO'", nativeMeta.getSQLSequenceExists( "FOO" ) ); assertEquals( "SELECT sequence_name FROM sequences", nativeMeta.getSQLListOfSequences() ); assertEquals( "SELECT nextval('FOO')", nativeMeta.getSQLNextSequenceValue( "FOO" ) ); assertEquals( "SELECT currval('FOO')", nativeMeta.getSQLCurrentSequenceValue( "FOO" ) ); }
Example #14
Source File: MongoDbOutputTest.java From pentaho-mongodb-plugin with Apache License 2.0 | 6 votes |
/** * Testing the use of Environment Substitution during initialization of fields. * @throws Exception */ @Test public void testTopLevelArrayWithEnvironmentSubstitution() throws Exception { List<MongoDbOutputMeta.MongoField> paths = asList( mf( "${ENV_FIELD}", true, "[0]" ), mf( "field2", true, "${ENV_DOC_PATH}" ) ); RowMetaInterface rmi = new RowMeta(); rmi.addValueMeta( new ValueMetaString( "field1" ) ); rmi.addValueMeta( new ValueMetaInteger( "field2" ) ); Object[] row = new Object[ 2 ]; row[ 0 ] = "value1"; row[ 1 ] = 12L; VariableSpace vs = new Variables(); vs.setVariable( "ENV_FIELD", "field1" ); vs.setVariable( "ENV_DOC_PATH", "[1]" ); for ( MongoDbOutputMeta.MongoField f : paths ) { f.init( vs ); } DBObject result = kettleRowToMongo( paths, rmi, row, MongoDbOutputData.MongoTopLevel.ARRAY, false ); assertEquals( JSON.serialize( result ), "[ { \"field1\" : \"value1\"} , { \"field2\" : 12}]" ); }
Example #15
Source File: GroupByIntIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
List<RowMetaAndData> getTestRowMetaAndData( int count, Integer[] nulls ) { List<RowMetaAndData> list = new ArrayList<RowMetaAndData>(); RowMetaInterface rm = new RowMeta(); rm.addValueMeta( new ValueMetaString( KEY1 ) ); rm.addValueMeta( new ValueMetaInteger( KEY2 ) ); rm.addValueMeta( new ValueMetaNumber( KEY3 ) ); rm.addValueMeta( new ValueMetaBigNumber( KEY4 ) ); Object[] row = new Object[4]; List<Integer> nullsList = Arrays.asList( nulls ); for ( int i = 0; i < count; i++ ) { if ( nullsList.contains( i ) ) { for ( int j = 0; j < row.length; j++ ) { row[j] = null; } } else { row[0] = ""; row[1] = 1L; row[2] = 2.0; row[3] = new BigDecimal( 3 ); } list.add( new RowMetaAndData( rm, row ) ); } return list; }
Example #16
Source File: HTTPPOSTIT.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void test204Answer() throws Exception { startHttpServer( get204AnswerHandler() ); HTTPPOSTData data = new HTTPPOSTData(); int[] index = { 0, 1 }; RowMeta meta = new RowMeta(); meta.addValueMeta( new ValueMetaString( "fieldName" ) ); meta.addValueMeta( new ValueMetaInteger( "codeFieldName" ) ); Object[] expectedRow = new Object[] { "", 204L }; HTTPPOST HTTPPOST = new HTTPPOSTHandler( stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans, false ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); HTTPPOST.setInputRowMeta( inputRowMeta ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( stepMockHelper.processRowsStepMetaInterface.getUrl() ).thenReturn( HTTP_LOCALHOST_9998 ); when( stepMockHelper.processRowsStepMetaInterface.getQueryField() ).thenReturn( new String[] {} ); when( stepMockHelper.processRowsStepMetaInterface.getArgumentField() ).thenReturn( new String[] {} ); when( stepMockHelper.processRowsStepMetaInterface.getResultCodeFieldName() ).thenReturn( "ResultCodeFieldName" ); when( stepMockHelper.processRowsStepMetaInterface.getFieldName() ).thenReturn( "ResultFieldName" ); HTTPPOST.init( stepMockHelper.processRowsStepMetaInterface, data ); Assert.assertTrue( HTTPPOST.processRow( stepMockHelper.processRowsStepMetaInterface, data ) ); Object[] out = ( (HTTPPOSTHandler) HTTPPOST ).getOutputRow(); Assert.assertTrue( meta.equals( out, expectedRow, index ) ); }
Example #17
Source File: BaseDatabaseMetaTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testDefaultSQLStatements() { // Note - this method should use only native or odbc metas. // Use of the jndi meta here could create a race condition // when test cases are run by multiple threads String lineSep = System.getProperty( "line.separator" ); String expected = "ALTER TABLE FOO DROP BAR" + lineSep; assertEquals( expected, odbcMeta.getDropColumnStatement( "FOO", new ValueMetaString( "BAR" ), "", false, "", false ) ); assertEquals( "TRUNCATE TABLE FOO", odbcMeta.getTruncateTableStatement( "FOO" ) ); assertEquals( "SELECT * FROM FOO", odbcMeta.getSQLQueryFields( "FOO" ) ); assertEquals( "SELECT 1 FROM FOO", odbcMeta.getSQLTableExists( "FOO" ) ); assertEquals( "SELECT FOO FROM BAR", odbcMeta.getSQLColumnExists( "FOO", "BAR" ) ); assertEquals( "insert into \"FOO\".\"BAR\"(KEYFIELD, VERSIONFIELD) values (0, 1)", nativeMeta.getSQLInsertAutoIncUnknownDimensionRow( "\"FOO\".\"BAR\"", "KEYFIELD", "VERSIONFIELD" ) ); assertEquals( "select count(*) FROM FOO", nativeMeta.getSelectCountStatement( "FOO" ) ); assertEquals( "COL9", nativeMeta.generateColumnAlias( 9, "FOO" ) ); assertEquals( "[SELECT 1, INSERT INTO FOO VALUES(BAR), DELETE FROM BAR]", nativeMeta.parseStatements( "SELECT 1;INSERT INTO FOO VALUES(BAR);DELETE FROM BAR" ).toString() ); assertEquals( "CREATE TABLE ", nativeMeta.getCreateTableStatement() ); assertEquals( "DROP TABLE IF EXISTS FOO", nativeMeta.getDropTableIfExistsStatement( "FOO" ) ); }
Example #18
Source File: KettleDatabaseRepositoryMetaStoreDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public ObjectId updateElementType( ObjectId namespaceId, ObjectId elementTypeId, IMetaStoreElementType type ) throws KettleException { RowMetaAndData table = new RowMetaAndData(); table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE ), elementTypeId ); table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_NAMESPACE ), namespaceId ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_NAME ), type.getName() ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_DESCRIPTION ), type .getDescription() ); repository.connectionDelegate.updateTableRow( KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE, KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE, table ); if ( log.isDebug() ) { log.logDebug( "Updated element type [" + type.getName() + "]" ); } return elementTypeId; }
Example #19
Source File: KettleDatabaseRepositoryDirectoryDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private synchronized ObjectId insertDirectory( ObjectId id_directory_parent, RepositoryDirectoryInterface dir ) throws KettleException { ObjectId id = repository.connectionDelegate.getNextDirectoryID(); String tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY; RowMetaAndData table = new RowMetaAndData(); table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY ), id ); table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT ), id_directory_parent ); table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ), dir.getName() ); repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), tablename ); repository.connectionDelegate.getDatabase().setValuesInsert( table ); repository.connectionDelegate.getDatabase().insertRow(); repository.connectionDelegate.getDatabase().closeInsert(); return id; }
Example #20
Source File: JavaFilterIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private static List<RowMetaAndData> getInputData() { List<RowMetaAndData> input = new ArrayList<RowMetaAndData>(); RowMeta rm = new RowMeta(); rm.addValueMeta( new ValueMetaString( fieldName ) ); input.add( new RowMetaAndData( rm, new Object[]{ "Car" } ) ); input.add( new RowMetaAndData( rm, new Object[]{ "Bus" } ) ); return input; }
Example #21
Source File: WordCountSampleIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public RowMetaInterface createMapperRowMetaInterface() { RowMetaInterface rm = new RowMeta(); ValueMetaInterface[] valuesMeta = { new ValueMetaString( "key" ), new ValueMetaString( "value" ), }; for ( int i = 0; i < valuesMeta.length; i++ ) { rm.addValueMeta( valuesMeta[ i ] ); } return rm; }
Example #22
Source File: JsonInputTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testNullProp() throws Exception { final String input = "{ \"obj\": [ { \"nval\": null, \"val\": 2 }, { \"val\": 1 } ] }"; JsonInput jsonInput = createBasicTestJsonInput( "$.obj[?(@.nval)].val", new ValueMetaString( "obj" ), "json", new Object[] { input } ); RowComparatorListener rowComparator = new RowComparatorListener( new Object[] { input, "2" } ); rowComparator.setComparator( 1, new JsonComparison() ); jsonInput.addRowListener( rowComparator ); processRows( jsonInput, 2 ); // in jsonpath 2.0->2.1, null value properties started being counted as existing Assert.assertEquals( 1, jsonInput.getLinesWritten() ); }
Example #23
Source File: ExcelInputData.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public ExcelInputData() { super(); workbook = null; filenr = 0; sheetnr = 0; rownr = -1; colnr = -1; valueMetaString = new ValueMetaString( "v" ); valueMetaNumber = new ValueMetaNumber( "v" ); valueMetaDate = new ValueMetaDate( "v" ); valueMetaBoolean = new ValueMetaBoolean( "v" ); }
Example #24
Source File: JsonOutputMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void getFields( RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( getOperationType() != OPERATION_TYPE_WRITE_TO_FILE ) { ValueMetaInterface v = new ValueMetaString( space.environmentSubstitute( this.getOutputValue() ) ); v.setOrigin( name ); row.addValueMeta( v ); } }
Example #25
Source File: JsonInputTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testNullInputs() throws Exception { final String jsonInputField = getBasicTestJson(); testSimpleJsonPath( "$..book[?(@.isbn)].author", new ValueMetaString( "author w/ isbn" ), new Object[][] { new Object[] { null }, new Object[] { jsonInputField }, new Object[] { null } }, new Object[][] { new Object[] { null, null }, new Object[] { jsonInputField, "Herman Melville" }, new Object[] { jsonInputField, "J. R. R. Tolkien" }, new Object[] { null, null } } ); }
Example #26
Source File: HTTPPOSTIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testResponseHeader() throws Exception { startHttpServer( get204AnswerHandler() ); HTTPPOSTData data = new HTTPPOSTData(); int[] index = { 0, 1, 3 }; RowMeta meta = new RowMeta(); meta.addValueMeta( new ValueMetaString( "fieldName" ) ); meta.addValueMeta( new ValueMetaInteger( "codeFieldName" ) ); meta.addValueMeta( new ValueMetaInteger( "responseTimeFieldName" ) ); meta.addValueMeta( new ValueMetaString( "headerFieldName" ) ); Object[] expectedRow = new Object[] { "", 402L, 0L, "{\"host\":\"localhost\"}" }; HTTPPOST HTTPPOST = new HTTPPOSTHandler( stepMockHelper.stepMeta, data, 0, stepMockHelper.transMeta, stepMockHelper.trans, true ); RowMetaInterface inputRowMeta = mock( RowMetaInterface.class ); HTTPPOST.setInputRowMeta( inputRowMeta ); when( inputRowMeta.clone() ).thenReturn( inputRowMeta ); when( stepMockHelper.processRowsStepMetaInterface.getUrl() ).thenReturn( HTTP_LOCALHOST_9998 ); when( stepMockHelper.processRowsStepMetaInterface.getQueryField() ).thenReturn( new String[] {} ); when( stepMockHelper.processRowsStepMetaInterface.getArgumentField() ).thenReturn( new String[] {} ); when( stepMockHelper.processRowsStepMetaInterface.getResultCodeFieldName() ).thenReturn( "ResultCodeFieldName" ); when( stepMockHelper.processRowsStepMetaInterface.getFieldName() ).thenReturn( "ResultFieldName" ); when( stepMockHelper.processRowsStepMetaInterface.getEncoding() ).thenReturn( "UTF-8" ); when( stepMockHelper.processRowsStepMetaInterface.getResponseTimeFieldName() ).thenReturn( "ResponseTimeFieldName" ); when( stepMockHelper.processRowsStepMetaInterface.getResponseHeaderFieldName() ).thenReturn( "ResponseHeaderFieldName" ); HTTPPOST.init( stepMockHelper.processRowsStepMetaInterface, data ); Assert.assertTrue( HTTPPOST.processRow( stepMockHelper.processRowsStepMetaInterface, data ) ); Object[] out = ( (HTTPPOSTHandler) HTTPPOST ).getOutputRow(); Assert.assertTrue( meta.equals( out, expectedRow, index ) ); }
Example #27
Source File: TransExecutorUnitTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testGetLastIncomingFieldValuesWithData() throws KettleException { prepareMultipleRowsForExecutor(); Trans parent = new Trans(); Mockito.when( executor.getTrans() ).thenReturn( parent ); meta.setGroupField( "groupField" ); executor.init( meta, data ); RowMetaInterface rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "groupField" ) ); executor.setInputRowMeta( rowMeta ); // start processing executor.processRow( meta, data ); // 1st row - 'value1' executor.processRow( meta, data ); executor.processRow( meta, data ); executor.processRow( meta, data ); // 4th row - still 'value1' // same group, zero calls verify( executor, times( 0 ) ).getLastIncomingFieldValues(); executor.processRow( meta, data ); // 5th row - value has been changed - 'value12' // group changed - 1 calls = 1 for trans execution verify( executor, times( 1 ) ).getLastIncomingFieldValues(); executor.processRow( meta, data ); // 6th row - 'value12' executor.processRow( meta, data ); // 7th row - 'value12' executor.processRow( meta, data ); // end of file // No more rows = + 1 call to get the previous value verify( executor, times( 2 ) ).getLastIncomingFieldValues(); }
Example #28
Source File: CubeInputStepIntIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
List<RowMetaAndData> getSampleData() { List<RowMetaAndData> rmd = new ArrayList<RowMetaAndData>(); RowMeta rm = new RowMeta(); rm.addValueMeta( new ValueMetaString( "col1" ) ); rmd.add( new RowMetaAndData( rm, new Object[] { "data1" } ) ); rmd.add( new RowMetaAndData( rm, new Object[] { "data2" } ) ); rmd.add( new RowMetaAndData( rm, new Object[] { "data3" } ) ); rmd.add( new RowMetaAndData( rm, new Object[] { "data4" } ) ); rmd.add( new RowMetaAndData( rm, new Object[] { "data5" } ) ); return rmd; }
Example #29
Source File: NullIfTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private RowMeta getInputRowMeta() { RowMeta inputRowMeta = new RowMeta(); inputRowMeta.addValueMeta( new ValueMetaString( "some-field" ) ); inputRowMeta.addValueMeta( new ValueMetaString( "nullable-field" ) ); inputRowMeta.addValueMeta( new ValueMetaString( "another-field" ) ); return inputRowMeta; }
Example #30
Source File: JavaScriptSpecialIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public RowMetaInterface createRowMetaInterface3() { RowMetaInterface rm = new RowMeta(); ValueMetaInterface[] valuesMeta = { new ValueMetaInteger( "int_in" ), new ValueMetaNumber( "number_in" ), new ValueMetaString( "string_in" ), }; for ( int i = 0; i < valuesMeta.length; i++ ) { rm.addValueMeta( valuesMeta[ i ] ); } return rm; }