SqlWriter implements DataWriter { public SqlWriter(final OutputStream os, final String[] outTemplate, final String schema, final String tableName, final SqlStatementType sqlStatement) { this.os = os; this.outTemplate = outTemplate; this.schema = schema; this.tableName = tableName; this.sqlStatement = sqlStatement; } SqlWriter(final OutputStream os, final String[] outTemplate, final String schema,
                     final String tableName, final SqlStatementType sqlStatement); @Override void writeOutput(DataPipe cr); String getSqlFormatted(Map<String, String> dataMap);  }
@Test public void testSqlWriter() { DataPipe dataFormatter = new DataPipe(); dataFormatter.getDataMap().put("var1", "var1val"); dataFormatter.getDataMap().put("var2", "var2val"); dataFormatter.getDataMap().put("var3", "var3val"); dataFormatter.getDataMap().put("var4", "var4val"); dataFormatter.getDataMap().put("var5", "var5val"); String[] outTemplate = new String[]{ "var1", "var2", "var3", "var4", "var5" }; String schema = "QC_ADMIN"; String tableName = "DATA_SERVICE"; SqlWriter.SqlStatementType sqlStatement = SqlWriter.SqlStatementType.INSERT; SqlWriter sqlWriter = new SqlWriter(System.out, outTemplate, schema, tableName, sqlStatement); String expected = sqlStatement + " INTO " + schema + "." + tableName + " (var1,var2,var3,var4,var5) " + "VALUES (var1val,var2val,var3val,var4val,var5val);"; Assert.assertEquals(5, dataFormatter.getDataMap().size()); Assert.assertEquals(expected, sqlWriter.getSqlFormatted(dataFormatter.getDataMap())); }