cancel
Showing results for 
Search instead for 
Did you mean: 

How to properly mock transition messages using "ui5-middleware-fe-mockserver"?

DominikFuchs
Associate
Associate
0 Kudos
384

Hi experts,

I am trying to mock a function import returning a message using the "ui5-middleware-fe-mockserver" middleware of the UI5 tooling. As another user has already asked how to do so in a similar post, I have tried using the proposed solution of using the "addMessage" method of the "odataRequest" parameter of the "executeAction" method. Unfortunately, while this does add a message to the header of the function import's response, the message is not displayed by our Fiori Elements app upon being returned by the mockserver. This is why I have compared the HTTP responses of both our actual back-end implementation of the function import and the mockserver:

Response returned by the back-end implementation:

 

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1738
dataserviceversion: 2.0
sap-message: {"code":"CM_EHFND_RAP_CCI/001","message":"Data calculation has been requested.","target":"","severity":"success","transition":true,"details":[]}
...

{"d":{ ... }}

 

Response returned by the mockserver:

 

HTTP/1.1 200 OK
sap-tenantid: tenant-default
sap-messages: [{"code":"CM_EHFND_RAP_CCI/001","message":"Data calculation has been requested.","numericSeverity":1,"target":""}]
dataserviceversion: 2.0
cache-control: no-store, no-cache
content-type: application/json

{"d":{ ... }}

 

While the fact that the mockserver returns an "sap-messages" array instead of just an "sap-message" in the header should not make a difference in my understanding, the missing "transition" flag does: If I don't explicitly set the "transition" flag for our message in the back-end (see parameter "iv_is_transition_message" of method "/iwbep/if_message_container~add_message"), the returned message will not be displayed by Fiori Elements, either.

This is why I have been wondering, how I can set the "transition" flag for messages mocked via the "ui5-middleware-fe-mockserver" middleware. Neither the example provided in the previously linked post nor the base API example mention the "transition" flag, as the "addMessage" method does not seem to offer a parameter for this at all. And while the example for the "onBeforeAction" and "onAfterAction" methods seem to mention the "transition" flag of a message, this example merely adds the message to the response body instead of the response header, which also results in the message not being displayed by a Fiori Elements app.

Could you please clarify how to properly mock transition messages using the "ui5-middleware-fe-mockserver" middleware in order for them to be displayed by a Fiori Elements app? Thanks a lot in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

marcel_waechter
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dominik,
may I ask you if you are referring to SAP Fiori elements for OData v2 or v4? As you are talking about function imports I guess you are using a SAP Fiori elements for OData v2 application, right? (SAP Fiori elements for OData v4 does not support function imports).

Indeed there's also a slightly difference between v2 and v4 in regards of the message handling. While v4 only shows unbound messages in the dialog and bound messages in the message popover (and doesn't care if it's a transition message or not), v2 shows only the transition messages in the dialog. Thus, without having the transition flag set, the message would not be shown in the dialog (only in the message popover of the object page once you are in the edit mode).

This sounds like an issue with our mockserver, or at least with our documentation. Therefore, can I ask you to report an issue here:
https://github.com/SAP/open-ux-odata/issues

Thanks and best regards,
Marcel