I have an utility class I use for my QueryDsl queries. I have, for example the following method:
public static StringExpression emptyIfNull(StringExpression expression) {
return expression.coalesce("").asString();
}
What I actually want to be sure of is that
""
when the original expression was null
How should I test this? Should I setup a db test with my whole context or is there a simpler way to verify that the correct expressions are added, i.e., that using the utility method gives me a COALESCE(<original>, '')
SQL function?
I'd test them in action, if you test the serialization instead you'll be looking at prepared statement templates and your tests might break when Querydsl serialization logic is changed.