Pull request cancelled and recreated after implementing unit tests and more debugging.
https://github.com/jOOQ/jOOQ/pull/3349 Also, looks like the TravisCI builds are all passing and so it appears there will be no regressions by incorporating these changes... Woot! Deven On Tuesday, June 24, 2014 2:00:26 PM UTC-4, Deven Phillips wrote: > > OK, pull request created. > > https://github.com/jOOQ/jOOQ/pull/3348 > <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FjOOQ%2FjOOQ%2Fpull%2F3348&sa=D&sntz=1&usg=AFQjCNFbQmDFpps67Ia3iLgzRyqRQ1YgXg> > > I hope that this will be useful to lots of people, because I KNOW it would > make my life lots easier! > > Deven > > On Tuesday, June 24, 2014 1:26:47 PM UTC-4, Deven Phillips wrote: >> >> Alright, I have a plan and will get back with a pull request shortly... >> >> Deven >> >> On Tuesday, June 24, 2014 12:57:01 PM UTC-4, Deven Phillips wrote: >>> >>> I just tried to implement this and apparently the API does a copy of the >>> MockDataProvider instance somewhere because the instance that I am running >>> setSelector() on is not the same instance as that used to provide the mock >>> results.... :( >>> >>> Bummer... >>> >>> Deven >>> >>> On Tuesday, June 24, 2014 12:46:05 PM UTC-4, Deven Phillips wrote: >>>> >>>> Oh, and this has the added benefit of not breaking backward >>>> compatibility. People who are already using the existing method need not >>>> change their code, but any new code could take advantage of the selector >>>> capability... >>>> >>>> Deven >>>> >>>> On Tuesday, June 24, 2014 12:41:06 PM UTC-4, Deven Phillips wrote: >>>>> >>>>> Heh! I just had a brainstorm!! >>>>> >>>>> Instead of using a complicated tree of if/then/else if/else statements >>>>> to determine which Mock data to return, could we allow developers to use >>>>> a >>>>> selector? For example, if your MockDataProvider exposed a method like: >>>>> >>>>> public void setSelector(int value); >>>>> >>>>> And before running your test code, you would call: >>>>> >>>>> mockDataProvider.setSelector(0); >>>>> >>>>> And in the MockDataProvider, we could just use the value of that >>>>> selector to determine which resultset to provide? >>>>> >>>>> That would certainly make the code more readable! Instead of >>>>> complicated boolean tests on strings and bind values, we could set up >>>>> descriptive constants for the various selectors like: >>>>> >>>>> private static final int RETURN_USER_LIST_CASE1 = 0; >>>>> private static final int RETURN_USER_LIST_CASE2 = 1; >>>>> private static final int RETURN_GROUP_CASE1 = 2; >>>>> private static final int RETURN_GROUP_CASE2 = 3; >>>>> private static final int RETURN_GROUP_CASE3 = 4; >>>>> >>>>> Thoughts? >>>>> >>>>> Deven >>>>> >>>>> On Tuesday, June 24, 2014 12:14:19 PM UTC-4, Deven Phillips wrote: >>>>>> >>>>>> Lukas, >>>>>> >>>>>> There's definitely room for improving the documentation around >>>>>> the MockDataProvider... There are MANY cases where I would like to use >>>>>> the >>>>>> bind values to help determine the result sets and that is not documented >>>>>> anywhere other than playing with the API. I will try to write up some >>>>>> concise docs on using the bind values as well as the query matching to >>>>>> be >>>>>> added. Other than that, I imagine it would be ideal to just somehow pass >>>>>> an >>>>>> identifier somehow so that you can explicitly choose a mock result for >>>>>> each >>>>>> query... I'm not sure what that would look like or how it could be >>>>>> implemented; but I will think on it.. >>>>>> >>>>>> Cheers, >>>>>> >>>>>> Deven >>>>>> >>>>>> On Tuesday, June 24, 2014 11:13:57 AM UTC-4, Lukas Eder wrote: >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> Yes, if you provide "null" to the MockResult, you will get a >>>>>>> somewhat invalid result with no columns from your statement. >>>>>>> >>>>>>> Do you think there is room for improvement in that area? >>>>>>> >>>>>>> Cheers, >>>>>>> Lukas >>>>>>> >>>>>>> >>>>>>> 2014-06-24 15:31 GMT+02:00 Deven Phillips <[email protected]>: >>>>>>> >>>>>>>> OK, back to answer my own question!!! >>>>>>>> >>>>>>>> The problem was that I needed to create the empty Result object >>>>>>>> with no members: >>>>>>>> >>>>>>>> private class EmptyResultsDataProvider implements MockDataProvider { >>>>>>>> @Override >>>>>>>> public MockResult[] execute(MockExecuteContext ctx) throws >>>>>>>> SQLException { >>>>>>>> MockResult[] mock = new MockResult[1]; >>>>>>>> Result<Record4<String>> result = create.newResult(...); >>>>>>>> mock[0] = new MockResult(0, result); >>>>>>>> return mock; >>>>>>>> } >>>>>>>> } >>>>>>>> >>>>>>>> On Tuesday, June 24, 2014 9:24:58 AM UTC-4, Deven Phillips wrote: >>>>>>>>> >>>>>>>>> I would like to know if someone could explain what I am doing >>>>>>>>> wrong here... >>>>>>>>> >>>>>>>>> I have created an implementation of MockDataProvider which always >>>>>>>>> returns an empty result set: >>>>>>>>> >>>>>>>>> private class EmptyResultsDataProvider implements MockDataProvider >>>>>>>>> { >>>>>>>>> @Override >>>>>>>>> public MockResult[] execute(MockExecuteContext ctx) throws >>>>>>>>> SQLException { >>>>>>>>> MockResult[] mock = new MockResult[1]; >>>>>>>>> mock[0] = new MockResult(0, null); >>>>>>>>> return mock; >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> But, when I try to run a query using that MockDataProvider, I get >>>>>>>>> a NullPointerException instead of a null result from fetchOne()??? >>>>>>>>> >>>>>>>>> I have another MockDataProvider that actually returns data for >>>>>>>>> that same query, and it runs fine. >>>>>>>>> >>>>>>>>> Any thoughts or suggestions? >>>>>>>>> >>>>>>>>> Thanks in advance!! >>>>>>>>> >>>>>>>>> Deven >>>>>>>>> >>>>>>>> -- >>>>>>>> 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.
