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