public void testSqlProcedureExpression() {
log.debug("Testing SqlProcedureExpression");
// constructing
try {
new SqlProcedureExpression(null);
fail("Constructing of SqlProcedureExpression with NULL as name should fail");
} catch (Exception e) {
// normal
}
try {
new SqlProcedureExpression("a");
} catch (Exception e) {
fail("Constructing of SqlProcedureExpression with not-null name failed");
}
// SQL String
assertEquals("SqlProcedureExpression must return \"a()\"",
new SqlProcedureExpression("a").toSqlString(), "a()");
assertEquals("SqlProcedureExpression must return \"a(b)\"",
new SqlProcedureExpression("a").add(
new MockSqlStringExpression("b")).toSqlString(), "a(b)");
assertEquals("SqlProcedureExpression must return \"a(b, c)\"",
new SqlProcedureExpression("a").add(
new MockSqlStringExpression("b")).add(
new MockSqlStringExpression("c")).toSqlString(),
"a(b, c)");
// SQL arguments
assertTrue("SqlProcedureExpression must return an empty array",
Arrays.equals(new SqlProcedureExpression("x").getValues(),
new Object[0]));
assertTrue("SqlProcedureExpression must return an empty array",
Arrays
.equals(
new SqlProcedureExpression("x").add(
new MockSqlStringExpression(
new Object[0])).add(
new MockSqlStringExpression(
new Object[0])).getValues(),
new Object[0]));
assertTrue(
"SqlProcedureExpression must return (\"a\", \"b\") as values",
Arrays.equals(new SqlProcedureExpression("x").add(
new MockSqlStringExpression(new Object[] { "a" })).add(
new MockSqlStringExpression(new Object[] { "b" }))
.getValues(), new Object[] { "a", "b" }));
}