### Question:
DBSetExpr extends DBExpr { @Override public void addSQL(StringBuilder buf, long context) { if ((context & CTX_NAME) != 0) column.addSQL(buf, CTX_NAME); if ((context & CTX_NAME) != 0 && (context & CTX_VALUE) != 0) buf.append("="); if ((context & CTX_VALUE) != 0) buf.append(getObjectValue(column.getDataType(), value, context, "+")); } DBSetExpr(DBColumn expr, Object value); @Override DBDatabase getDatabase(); DBRowSet getTable(); DBColumn getColumn(); Object getValue(); void setValue(Object value); @Override void addReferencedColumns(Set<DBColumn> list); @Override void addSQL(StringBuilder buf, long context); final DBColumn column; public Object value; }### Answer:
@Test public void testAddSQL() { StringBuilder builder = new StringBuilder(); expr.addSQL(builder, 0); assertEquals("", builder.toString()); expr.addSQL(builder, DBExpr.CTX_DEFAULT); assertEquals("FIRSTNAME='JUnit'", builder.toString()); }
@Test public void testAddSQLEmptyString() { StringBuilder builder = new StringBuilder(); DBSetExpr setExpr = new DBSetExpr(testDB.EMPLOYEE.FIRSTNAME, ""); setExpr.addSQL(builder, DBExpr.CTX_DEFAULT); assertEquals("FIRSTNAME=null", builder.toString()); }
@Test public void testAddSQLEmptyStringConstant() { StringBuilder builder = new StringBuilder(); DBSetExpr setExpr = new DBSetExpr(testDB.EMPLOYEE.FIRSTNAME, DBDatabase.EMPTY_STRING); setExpr.addSQL(builder, DBExpr.CTX_DEFAULT); assertEquals("FIRSTNAME=''", builder.toString()); }