public void testSqlAndExpression() {
log.debug("Testing SqlAndExpression");
// constructing
try {
new SqlAndExpression();
} catch (Exception e) {
fail("Constructing of SqlAndExpression failed");
}
// SQL String
assertEquals("SqlAndExpression must return an empty string",
new SqlAndExpression().toSqlString(), "");
assertEquals("SqlAndExpression must return \"a\"",
new SqlAndExpression().add(new MockSqlStringExpression("a"))
.toSqlString(), "a");
assertEquals("SqlAndExpression must return \"a AND b\"",
new SqlAndExpression().add(new MockSqlStringExpression("a"))
.add(new MockSqlStringExpression("b")).toSqlString(),
"a AND b");
// SQL arguments
assertTrue("SqlAndExpression must return an empty array", Arrays
.equals(new SqlAndExpression().getValues(), new Object[0]));
assertTrue("SqlAndExpression must return an empty array",
Arrays
.equals(
new SqlAndExpression().add(
new MockSqlStringExpression(
new Object[0])).add(
new MockSqlStringExpression(
new Object[0])).getValues(),
new Object[0]));
assertTrue("SqlAndExpression must return (\"a\", \"b\") as values",
Arrays.equals(new SqlAndExpression().add(
new MockSqlStringExpression(new Object[] { "a" })).add(
new MockSqlStringExpression(new Object[] { "b" }))
.getValues(), new Object[] { "a", "b" }));
}