I want to return a mocked result for the query:
return dslContext.fetchExists(
dslContext
.selectFrom(CARDS)
.where(CARDS.CARD_ID.eq(cardId)));
The returned value is
+---------+
|exists |
+---------+
|true |
+---------+
Mocking Connection has code examples on how to create a record from a generated Record class (like CARDS
). How to generate a custom record for the return value of select exists (... some query ...)
?
This manual page shows how to create arbitrary Field
references in jOOQ, e.g.
Field<Boolean> exists = DSL.field("exists", SQLDataType.BOOLEAN)
That's just one way to do it (probably the simplest). There are many others. There isn't any fundamental difference between this kind of Field
and a generated one.
Of course, you could also just reproduce the exists
expression instead:
Field<Boolean> exists = DSL.exists(...);
Or really, just any dummy expression.