[
https://issues.apache.org/jira/browse/OFBIZ-11247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094410#comment-17094410 ]
Pawan Verma commented on OFBIZ-11247:
-------------------------------------
Thanks, [~jleroux] for the review.
I took reference from GroovyBaseScript.groovy, in that we have from() and select() method. Agree to add DynamicViewEntity. Rest of the methods can be directly called using the from() method like where, cache() etc.
Attaching a new patch here. [^OFBIZ-11247.patch]
> Providing utilities for integration tests
> -----------------------------------------
>
> Key: OFBIZ-11247
> URL:
https://issues.apache.org/jira/browse/OFBIZ-11247> Project: OFBiz
> Issue Type: Improvement
> Components: ALL APPLICATIONS, framework
> Reporter: Jacques Le Roux
> Priority: Minor
> Attachments: OFBIZ-11247.patch, OFBIZ-11247.patch
>
>
> At
https://markmail.org/message/bdf4ntvwwdl4hxtx [~mthl] suggested:
> {quote}
> In order to avoid repetitive code a nice first helper method would be
> for example one for retrieving the default userLogin like what is done
> in 'QuoteTests.groovy'
> {code:java}
> // Retrieves a particular login record.
> GenericValue getUserLogin(String userLoginId) {
> GenericValue userLogin = EntityQuery.use(delegator)
> .from('UserLogin').where(userLoginId: userLoginId).queryOne()
> assert userLogin
> return userLogin
> }
> {code}
> We could even add a default login user.
> {code:java}
> // Retrieves the default login record.
> GenericValue getUserLogin() {
> return getUserLogin('system');
> }
> {code}
> I guess we should add such method directly in the 'OFBizTestCase' class
> to be able to reuse it in all test cases and avoid having to pass the
> 'delegator' and 'dispatcher' as method arguments.
> The creation of the service input map of your example would look like
> this:
> {code:java}
> void testSendOrderChangeNotification() {
> Map serviceCtx = [
> orderId: 'TEST_DEMO10090',
> sendTo: '
[hidden email]',
> userLogin: getUserLogin()
> ]
> Map serviceResult = dispatcher.runSync('sendOrderChangeNotification', serviceCtx)
> assert ServiceUtil.isSuccess(serviceResult)
> assert serviceResult.emailType.equals("PRDS_ODR_CHANGE")
> }
> {code}
> In any case I think that finding the generic and reusable helper methods
> can be done incrementally.
> {quote}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)