Hi Carlos, The interseting part will now be: How are you creating this query with jOOQ?
SELECT MIN(column_name), MAX(column_name) FROM table_name Because from your log output, I suspect you're just using simple DSL.min() and DSL.max() functions, which produce "min" and "max" column names if you do not alias them: 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener - Fetched result : > +------+------+ > 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener - > : | min| max| > 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener - > : +------+------+ However, in your MockDataProvider, you're producing a result that has only one column called MyTable.DOBLEVALUE_COLUMN In other words, the mock database produces a record of type +-----------------+ |DOBLEVALUE_COLUMN| +-----------------+ But your query selects only: +------+------+ | min| max| +------+------+ The "min" and "max" values don't exist in your mock databases's result set, which is why they are null. I hope this helps, Lukas 2015-02-03 10:52 GMT+01:00 <[email protected]>: > Hi, > > I try to find a way to create JUnit test the following sql statement; > SELECT MIN(column_name), MAX(column_name) FROM table_name > > but I can't understand how to? Any one who has ideas on how to mock the > sql statement above? > > I have tried do the following using the MockDataProvider to mock the > result without luck. > > In the execute method I do; > > DSLContext dslContext = DSL.using(SQLDialect.SQLSERVER2008); > > > Result<MyTableRecord> tableRecords = dslContext.newResult(MyTable); > > tableRecords.add(dslContext.newRecord(MyTable)); > tableRecords.get(0).setValue(MyTable.DOBLEVALUE_COLUMN, minValue); > > tableRecords.add(dslContext.newRecord(turbineTable)); > tableRecords.get(1).setValue(MyTable.DOBLEVALUE_COLUMN, maxValue); > > results[0] = new MockResult(1, tableRecords); > return results; > > > And I get the following result?? > 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener - Fetched result > : +------+------+ > 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener > - : | min| max| > 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener > - : +------+------+ > 10:46:22.460 [main] DEBUG org.jooq.tools.LoggerListener > - : |{null}|{null}| > 10:46:22.461 [main] DEBUG org.jooq.tools.LoggerListener > - : |{null}|{null}| > 10:46:22.461 [main] DEBUG org.jooq.tools.LoggerListener > - : +------+------+ > 10:46:22.461 [main] DEBUG org.jooq.tools.StopWatch - > Finishing : Total: 14.906s, +4.469s > > > > Best regards > Carlos > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
