SqlTransGenerator { private StepMeta generateConstStep( List<SQLField> fields ) throws KettleException { ConstantMeta meta = new ConstantMeta(); meta.allocate( fields.size() ); for ( int i = 0; i < fields.size(); i++ ) { SQLField field = fields.get( i ); ValueMetaInterface valueMeta = field.getValueMeta(); meta.getFieldName()[i] = "Constant_" + field.getFieldIndex() + "_" + field.getField(); meta.getFieldFormat()[i] = valueMeta.getConversionMask(); meta.getFieldType()[i] = valueMeta.getTypeDesc(); meta.getFieldLength()[i] = valueMeta.getLength(); meta.getFieldPrecision()[i] = valueMeta.getPrecision(); meta.getDecimal()[i] = valueMeta.getDecimalSymbol(); meta.getGroup()[i] = valueMeta.getGroupingSymbol(); meta.getValue()[i] = valueMeta.getString( field.getValueData() ); } StepMeta stepMeta = new StepMeta( "Constants", meta ); stepMeta.setLocation( xLocation, 50 ); xLocation += 100; stepMeta.setDraw( true ); return stepMeta; } SqlTransGenerator( SQL sql, int rowLimit );  SqlTransGenerator( SQL sql, int rowLimit, int serviceLimit ); TransMeta generateTransMeta(); SQL getSql(); String getInjectorStepName(); void setInjectorStepName( String injectorStepName ); String getResultStepName(); void setResultStepName( String resultStepName ); int getRowLimit(); int getServiceRowLimit();  }
@Test public void testGenerateConstStep() throws KettleException { SQL sql = new SQL( "SELECT 'FOO' as foo FROM table" ); RowMetaInterface rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaInteger( "foo" ) ); sql.parse( rowMeta ); SqlTransGenerator generator = new SqlTransGenerator( sql, 0 ); SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta( generator.generateTransMeta() ); assertThat( selectValuesMeta.getSelectName(), equalTo( new String[] { "'FOO'" } ) ); assertThat( selectValuesMeta.getSelectRename(), equalTo( new String[] { "foo" } ) ); }