public void testSqlLikeExpression() {
log.debug("Testing SqlLikeExpression");
// constructing
try {
new SqlLikeExpression(null, null);
fail("Constructing of SqlLikeExpression with NULL as SqlExpression arguments should fail");
} catch (Exception e) {
// normal
}
try {
new SqlLikeExpression(null, new MockSqlStringExpression("a"));
fail("Constructing of SqlLikeExpression with NULL as first SqlExpression argument should fail");
} catch (Exception e) {
// normal
}
try {
new SqlLikeExpression(new MockSqlStringExpression("a"), null);
fail("Constructing of SqlLikeExpression with NULL as second SqlExpression argument should fail");
} catch (Exception e) {
// normal
}
// SQL String
assertEquals("SqlLikeExpression must return \" LIKE \"",
new SqlLikeExpression(new MockSqlStringExpression(""),
new MockSqlStringExpression("")).toSqlString(),
" LIKE ");
assertEquals("SqlLikeExpression must return \"a LIKE b\"",
new SqlLikeExpression(new MockSqlStringExpression("a"),
new MockSqlStringExpression("b")).toSqlString(),
"a LIKE b");
// SQL arguments
assertTrue("SqlLikeExpression must return an empty array", Arrays
.equals(new SqlLikeExpression(new MockSqlStringExpression(""),
new MockSqlStringExpression("")).getValues(),
new Object[0]));
assertTrue("SqlLikeExpression must return an empty array", Arrays
.equals(new SqlLikeExpression(new MockSqlStringExpression(
new Object[] { "a" }), new MockSqlStringExpression(
new Object[] { "b" })).getValues(), new Object[] { "a",
"b" }));
}