You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Jacques Le Roux (Jira)" <ji...@apache.org> on 2019/10/14 09:17:00 UTC

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

Jacques Le Roux created OFBIZ-11247:
---------------------------------------

             Summary: 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


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)