Hi Scott,

Thanks for your comment. I understand … and I don’t.
See, this is the message sequence in the two cases:

Case 1
updateCustRequest
==> calls checkStatusCustRequest
   (Will fail the check if not in an in-progress status)
<== returns to calling simple service
… do the updateCustRequest stuff

Test result: FAIL.


Case 2
createCustRequestItemNote
==> calls checkStatusCustRequest
   (Will fail the check if not in an in-progress status)
<== returns to calling simple service
… create the CustRequestItemNote

Test result: PASS.


The checkStatusCustRequest is a read-only method, only reason to run it is a 
failure message being raised when the referenced custRequest does not have an 
allowed status. Yet, it will in the background already read the custRequest 
object from the Entity store.

I tried:
- putting the copy-step first in the method before calling the StatusCheck 
(test expects the updateCustRequest.oldStatusId
 to be returned in the OUT map
- renaming the local variable in the StatusCheck method to avoid interference 
with the calling method’s context
- not returning a success message from the StatusCheck method to avoid any 
„pollution“ of the calling method’s context

Still I see the same error in all these attempts as mentioned below, namely 
that test expects the presence updateCustReuqest.oldStatusId as a return value 
of the updateCustRequest method. I do hence not seem to get it right. Any ideas?

Warm regards


Carsten



> Am 28.05.2020 um 03:11 schrieb Scott Gray <[email protected]>:
> 
> Hi Carsten,
> 
> call-simple-method executes in the same manner as if you copied the code
> from the method being called directly into your code, i.e. it has the same
> variable scope as the method it's being called from.  So the "custRequest"
> variable from checkStatusCustRequest was available to updateCustRequest.
> Now that the implementation is a service, you'd need to explicitly return
> that value from the service in order to be able to use it.
> 
> Regards
> Scott
> 
> On Thu, 28 May 2020 at 04:52, Carsten Schinzer <
> [email protected]> wrote:
> 
>> Hello MiniLang Experts,
>> 
>> 
>> I am migrating the checkStatusCustRequest service to Groovy (OFBIZ-11692 <
>> https://issues.apache.org/jira/browse/OFBIZ-11692>), part of our May
>> CommunityDays scope and sprint.
>> In the finalization I now notice that the original Minilang service
>> „checkStatusCustRequest“ is called by two other services as an inline
>> call-simple-method statement:
>> 
>> Source is /applications/order/minilang/request/CustRequestServices.xml:
>> 
>> #121
>> Was:
>> <simple-method method-name="updateCustRequest" short-description="Update
>> Customer Request">
>>    <call-simple-method method-name="checkStatusCustRequest"/>
>>    <set field="oldStatusId" from-field="custRequest.statusId“/>
>> 
>> Changed to:
>> <simple-method method-name="updateCustRequest" short-description="Update
>> Customer Request">
>>    <set field="crqCheck.custRequestId"
>> from-field="parameters.custRequestId"/>
>>    <set field="crqCheck.locale" from-field="parameters.locale"/>
>>    <set field="crqCheck.userLogin" from-field="parameters.userLogin"/>
>>    <call-service service-name="checkStatusCustRequest"
>> in-map-name="crqCheck">
>>        <results-to-map map-name="crqCheckResult"/>
>>    </call-service>
>>    <set field="oldStatusId" from-field="custRequest.statusId"/>
>> 
>> And the second service in the same minilang file
>> 
>> #237
>> Was:
>> <simple-method method-name="createCustRequestItemNote"
>> short-description="Create Customer RequestItem Note">
>>    <call-simple-method method-name="checkStatusCustRequest"/>
>>    <make-value entity-name="CustRequestItemNote" value-field="newEntity"/>
>> 
>> Changed to:
>> <simple-method method-name="createCustRequestItemNote"
>> short-description="Create Customer RequestItem Note">
>>    <set from-field="parameters.custRequestId"
>> field="crqCheck.custRequestId"/>
>>    <set from-field="parameters.locale" field="crqCheck.locale"/>
>>    <set from-field="parameters.userLogin" field="crqCheck.userLogin"/>
>>    <call-service service-name="checkStatusCustRequest"
>> in-map-name="crqCheck"/>
>>    <make-value entity-name="CustRequestItemNote" value-field="newEntity"/>
>> 
>> While the latter passes testing now, the first does not, complaining that:
>> 
>>      <testcase classname="org.apache.ofbiz.testtools.SimpleMethodTest"
>> name="custrequest-tests.testCreateNewRequest" time="0.101">
>>          <failure message="ERROR: Could not complete the update a request
>> [file:/Users/carsten/github/ofbiz-framework/applications/order/minilang/test/CustRequestTests.xml#inlineUpdateRequest]
>> process [problem invoking the [updateCustRequest] service with the map
>> named [updateRequestMap] containing
>> [{userLogin=[GenericEntity:UserLogin][createdStamp,2020-05-25
>> 09:59:39.293(java.sql.Timestamp)][createdTxStamp,2020-05-25
>> 09:59:39.167(java.sql.Timestamp)][currentPassword,null()][disabledBy,null()][disabledDateTime,null()][enabled,N(java.lang.String)][externalAuthId,null()][hasLoggedOut,null()][isSystem,Y(java.lang.String)][lastCurrencyUom,null()][lastLocale,null()][lastTimeZone,null()][lastUpdatedStamp,2020-05-25
>> 09:59:41.161(java.sql.Timestamp)][lastUpdatedTxStamp,2020-05-25
>> 09:59:41.121(java.sql.Timestamp)][partyId,system(java.lang.String)][passwordHint,null()][requirePasswordChange,null()][successiveFailedLogins,null()][userLdapDn,null()][userLoginId,system(java.lang.String)],
>> custRequestName=New Test Customer request, fromPartyId=admin,
>> statusId=CRQ_ACCEPTED, custRequestId=10530, custRequestTypeId=RF_INFO,
>> priority=2, locale=en}]: Outgoing result (in runSync : updateCustRequest)
>> does not match expected requirements (The following required parameter is
>> missing: [OUT] [updateCustRequest.oldStatusId])]"
>> type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError:
>> ERROR: Could not complete the update a request
>> [file:/Users/carsten/github/ofbiz-framework/applications/order/minilang/test/CustRequestTests.xml#inlineUpdateRequest]
>> process [problem invoking the [updateCustRequest] service with the map
>> named [updateRequestMap] containing
>> [{userLogin=[GenericEntity:UserLogin][createdStamp,2020-05-25
>> 09:59:39.293(java.sql.Timestamp)][createdTxStamp,2020-05-25
>> 09:59:39.167(java.sql.Timestamp)][currentPassword,null()][disabledBy,null()][disabledDateTime,null()][enabled,N(java.lang.String)][externalAuthId,null()][hasLoggedOut,null()][isSystem,Y(java.lang.String)][lastCurrencyUom,null()][lastLocale,null()][lastTimeZone,null()][lastUpdatedStamp,2020-05-25
>> 09:59:41.161(java.sql.Timestamp)][lastUpdatedTxStamp,2020-05-25
>> 09:59:41.121(java.sql.Timestamp)][partyId,system(java.lang.String)][passwordHint,null()][requirePasswordChange,null()][successiveFailedLogins,null()][userLdapDn,null()][userLoginId,system(java.lang.String)],
>> custRequestName=New Test Customer request, fromPartyId=admin,
>> statusId=CRQ_ACCEPTED, custRequestId=10530, custRequestTypeId=RF_INFO,
>> priority=2, locale=en}]: Outgoing result (in runSync : updateCustRequest)
>> does not match expected requirements (The following required parameter is
>> missing: [OUT] [updateCustRequest.oldStatusId])]
>>   at
>> org.apache.ofbiz.testtools.SimpleMethodTest.run(SimpleMethodTest.java:91)
>>   at
>> org.apache.ofbiz.testtools.TestRunContainer.start(TestRunContainer.java:90)
>>   at
>> org.apache.ofbiz.base.container.ContainerLoader.startLoadedContainers(ContainerLoader.java:156)
>>   at
>> org.apache.ofbiz.base.container.ContainerLoader.load(ContainerLoader.java:78)
>>   at
>> org.apache.ofbiz.base.start.StartupControlPanel.loadContainers(StartupControlPanel.java:151)
>>   at
>> org.apache.ofbiz.base.start.StartupControlPanel.start(StartupControlPanel.java:71)
>>   at org.apache.ofbiz.base.start.Start.main(Start.java:90)
>>          </failure>
>> So something in my checkStatusCustRequest call is not digesting the
>> response from the sub-service properly I suspect as the test complains that
>> the subsequent line originally in line #123 which maps the oldStatusId is
>> not executed as that field is missing in the response.
>> 
>> Now I am not an expert at all with these cross-service calls, what would
>> you suggest here?
>> 
>> Also, a tactical option could be to extend the story to port all three to
>> Groovy knowing that the other two are not called as nested
>> call-simple-method statements by other services, but always as call-service
>> statements which assumedly makes it fairly easy to port (but will cause
>> scope slippage).
>> 
>> Thanks for any views and hints.
>> Warm regards
>> 
>> 
>> Carsten
>> 
>> 
>> 
>> 

Reply via email to