VISHNU
VISHNU

Reputation: 1

How to Use Java Reflection in MUnit to Modify `error.muleMessage` in Mule 4?

I am trying to create an MUnit test for a flow that uses the error.muleMessage variable. If it's error.errorMessage, I can modify the content by creating a custom exception and providing a description, but unfortunately, I need to set a variable for error.muleMessage, and there isn't any documentation available that I can use.

I can create an error with a custom description using the format #[java!java::lang::Exception::new('custom error with status code 422')], but it always sets the value in error.description. I need to set that value in error.muleMessage.

Any ideas on how to use Java reflection to modify the behavior of error.muleMessage to return a custom message in Anypoint Studio? If so, can anyone help me with using Java reflection to mock an MUnit test that returns a custom error.muleMessage? Also, is it safe to use reflection for MUnit? My MUnit version is 2.3.0 and Mule version is 4.3.0

I tried creating a subflow in MUnit to mock the main flow, expecting it to replicate the exact issue, but it seems it doesn't set the value for error.muleMessage.

Upvotes: 0

Views: 123

Answers (0)

Related Questions