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