InsertSQLBuilder implements SQLBuilder { @Override public String buildInsert(String tableName, String[] fields) { if ((fields == null) || (fields.length == 0)) { throw new IllegalArgumentException("Fields are null"); } StringBuilder sb = new StringBuilder(); sb.append("insert into "); sb.append(tableName); sb.append(" values ("); for (int i = 0; i < fields.length; i++) { String field = fields[i]; sb.append(field); if (i != (fields.length - 1)) { sb.append(", "); } } sb.append(")"); return sb.toString() + ";\n"; } InsertSQLBuilder();  InsertSQLBuilder(FieldSerializer fieldSerializer); @Override String buildField(Object object); @Override String buildInsert(String tableName, String[] fields);  }
@Test public void testBuildInsert() { String[] fields = {"a", "b", "c", "d"}; InsertSQLBuilder insertSQLBuilder = new InsertSQLBuilder(); Assert.assertEquals( "insert into Foo values (a, b, c, d);\n", insertSQLBuilder.buildInsert("Foo", fields)); }