SAP IS Working with MPL Attachments
Int4 Suite allows fetching payloads for Test Case creation and execution from MPL Attachments. This can be a very convenient way of storing required payloads without usage of Trace.
To use attachments instead of Cloud Integration iFlow blocks, you just need to specify the Attachment names in the Automation Object:
For Example:
As Attachments requires additional storage - they are storing additional data, it’s very important to make this option switchable, so it can be decided if the attachment logging is on (we are collecting Test Cases or we are running tests) or it is off (normal BAU usage of Cloud Integration). To make it configurable you need to create a property in the iFlow that will control this. In below example the property name is “logattachments”. Externalize this property and set the default value to “false”.
Second step is to add Groovy scripts that will do the actual attachment logging in all places that requires validation. Minimum will be the input message logging and at least one output message logging.
Example of Groovy that will use configured property and dynamically log or not the payload:
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
//get Body as a string
def body = message.getBody(java.lang.String) as String;
def msgLog = messageLogFactory.getMessageLog(message);
def properties = message.getProperties();
def header = message.getHeaders();
//Check if logging is switched on by the HTTP Header
String logInt4 = header.get("Int4LogAttachments");
//Check if loggign is switched on iFlow level
String add_attachment = properties.get("logattachments");
if(add_attachment.equals("true")|logInt4.equals("true")){
if(msgLog != null){
//Write an attachment to the Message Processing Log
//Input is an example name of attachment
msgLog.addAttachmentAsString("Input", body, "text/plain");
}
}
return message;
}
Now you should be able to switch attachment logging via Configuration of an iFlow.
For test purpose when Test Case is executed from the Int4 Suite it can automatically switch on logging of attachments when “Int4LogAttachmets=true” is passed as a HTTP Header. Thanks to this feature, there is no need to change configuration of an iFlow for testing in non-Productive environments.
© 2017 - 2022 Int4 AG All rights reserved