You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Pawan Verma (Jira)" <ji...@apache.org> on 2020/04/28 08:49:00 UTC

[jira] [Updated] (OFBIZ-11247) Providing utilities for integration tests

     [ https://issues.apache.org/jira/browse/OFBIZ-11247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pawan Verma updated OFBIZ-11247:
--------------------------------
    Attachment: 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
>            Assignee: Pawan Verma
>            Priority: Minor
>         Attachments: 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: 'test_email@example.com',
>              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)