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