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