This has been fixed for jOOQ 3.15.0 and 3.14.9. Thanks again for your 
report.

Lukas

On Wednesday, March 3, 2021 at 5:09:49 PM UTC+1 Lukas Eder wrote:

> Hi Ben,
>
> Thanks a lot for your patience. I can reproduce this. Looks like a bug: 
> https://github.com/jOOQ/jOOQ/issues/11560
>
> I can't think of a workaround from within jOOQ other than mocking your 
> logic on a different layer than JDBC
>
> Thanks again for your report,
> Lukas
>
> On Thu, Feb 25, 2021 at 7:20 PM Lukas Eder <lukas...@gmail.com> wrote:
>
>> Hi Benjamin,
>>
>> Thanks for your message. I'll try to reproduce your case, soon. In the 
>> meantime, for that particular case of mocking, it might be easier to use 
>> e.g. mockito to mock the fGetArms() method directly, I suppose?
>>
>> Will report with findings about the exception soon.
>> Lukas
>>
>> On Thu, Feb 25, 2021 at 6:31 PM Benjamin Greiner <
>> benjamin...@avocetsys.com> wrote:
>>
>>> Hello,
>>>
>>> I've been very impressed with the functionality and ease of the JOOQ 
>>> thus far, but I think I've stumbled into my first real-head scratcher. 
>>>
>>> I am attempting to mock an oracle stored proc that utilized JOOQ's code 
>>> generator capabilities. The procedure has multiple input params and one 
>>> single return value parameter of type Result<Record>. 
>>>
>>> public static Result<Record> fGetArms(
>>>           Configuration configuration
>>>         , String param1
>>>         , Number param2
>>>     ) {
>>>         FGetArms f = new FGetArms();
>>>         f.setParam1(param1);
>>>         f.setParam2(param2);
>>>
>>>         f.execute(configuration);
>>>         return f.getReturnValue();
>>>     }
>>>
>>> When I run my integration tests it works as expected. However unit tests 
>>> I cannot seem to be able to create a successful mock of the Result<Record> 
>>> return type with configured values. 
>>>
>>> With the following code I am getting this exceptions
>>> java.lang.ClassCastException: class org.jooq.impl.ResultImpl cannot be 
>>> cast to class java.sql.ResultSet (org.jooq.impl.ResultImpl is in module 
>>> org....@3.14.6 of loader 'app'; java.sql.ResultSet is in module java.sql of 
>>> loader 'platform')
>>>
>>> Perhaps I am fundamentally misunderstanding how to return the data via 
>>> the returnValue field.
>>>
>>> final MockDataProvider mockDataProvider;
>>>         
>>>         mockDataProvider = (MockExecuteContext context) -> {
>>>             
>>>             // Use ordinary jOOQ API to create an org.jooq.Result object.
>>>             // You can also use ordinary jOOQ API to load CSV files or
>>>             // other formats, here!
>>>             DSLContext create = DSL.using(SQLDialect.ORACLE);
>>>                                
>>>             // Cursor column definitions.
>>>             Field<String> meterName = DSL.field("METER_NAME", 
>>> SQLDataType.VARCHAR);
>>>             Field<String> armDescription = DSL.field("ARM_DESCRIPTION", 
>>> SQLDataType.VARCHAR);
>>>             Field<String> meterId = DSL.field("METER_ID", 
>>> SQLDataType.VARCHAR);
>>>            
>>>             // Add rows to cursor results.
>>>             Result cursorResult = create.newResult(meterName, 
>>> armDescription, meterId);
>>>             cursorResult.add(create.newRecord(meterName, armDescription, 
>>> meterId).values("B1", "Arm Desc", "B1HK"));
>>>             cursorResult.add(create.newRecord(meterName, armDescription, 
>>> meterId).values("B2", "Arm Desc", "B2DB"));
>>>             
>>>             
>>>             // Define the return value column as defined by the code-gen.
>>>             Field<Result<Record>> returnValue =  
>>> DSL.field("RETURN_VALUE", SQLDataType.RESULT);
>>>             
>>>             // Create new Result and set its single row value for 
>>> returnValue to the cursor results.
>>>             Result outResult = create.newResult(returnValue);
>>>             
>>> outResult.add(create.newRecord(returnValue).values(cursorResult));
>>>                                                                
>>>             // Now, return 1-many results, depending on whether this is
>>>             // a batch/multi-result context
>>>             return new MockResult[]
>>>             {
>>>                 new MockResult(1, outResult)
>>>             };
>>>         };
>>>
>>> Cheers,
>>> Ben
>>>
>>> -- 
>>> 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 jooq-user+...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jooq-user/22cd3d7a-6d8f-4aea-99a7-90b82a59da4an%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jooq-user/22cd3d7a-6d8f-4aea-99a7-90b82a59da4an%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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 jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/9bebcd20-1cf5-4a3e-b204-1c2ec1ad5edbn%40googlegroups.com.

Reply via email to