mercredi 30 septembre 2020

Cannot mock 0 rows result in jOOQ

I have a problem mocking an empty result with jOOQ (version 3.12.3). I use MockDataProvider, but it still returns one row. Here is the code of MockDataProvider:

        class DataProvider implements MockDataProvider {
            @Override
            public MockResult[] execute(MockExecuteContext ctx) {
                return new MockResult[]{new MockResult(0, null)};
            }
        }
        var dbContext = DSL.using(new MockConnection(new DataProvider()));
        //....

So it should return 0 rows, and that's what is needed. However, it actually returns 1 row with 0 as value.

12:51:34.799 [main] DEBUG org.jooq.tools.LoggerListener - Affected row(s)          : 0
12:51:34.863 [main] DEBUG org.jooq.tools.LoggerListener - Fetched result           : +--------+
12:51:34.863 [main] DEBUG org.jooq.tools.LoggerListener -                          : |metadata|
12:51:34.863 [main] DEBUG org.jooq.tools.LoggerListener -                          : +--------+
12:51:34.863 [main] DEBUG org.jooq.tools.LoggerListener -                          : |0       |
12:51:34.863 [main] DEBUG org.jooq.tools.LoggerListener -                          : +--------+
12:51:34.863 [main] DEBUG org.jooq.tools.LoggerListener - Fetched row(s)           : 1

Any help or advice is very appreciated.

Aucun commentaire:

Enregistrer un commentaire