### Question:
OptionalSqlClause { public String toString() { String result = ""; if (_st != null) { if (_value != null) { _st.setAttribute(_key, _value); result = _st.toString(); } } else { if (!StringUtils.isEmpty(_variablePart)) { result = new StringBuilder(_staticPart).append(" ").append(_variablePart).toString(); } } return result; } OptionalSqlClause(String staticPart, String variablePart);  OptionalSqlClause(StringTemplate st, String key, String value); String toString();  }### Answer:
@Test public void testOptionalSqlClauseStringString() { String staticPart = "static"; String variablePart = "variable"; classUnderTest = new OptionalSqlClause(staticPart, variablePart); String result = classUnderTest.toString(); assertEquals(staticPart + " " + variablePart, result); }
@Test public void testOptionalSqlClauseStringTemplateStringString() { String staticPart = "A test template "; StringTemplate st = new StringTemplate(staticPart + "$subst$"); String key = "subst"; String value = "works!"; classUnderTest = new OptionalSqlClause(st, key, value); String result = classUnderTest.toString(); assertEquals(staticPart+value, result); }