How to validate Http 401 Unauthorized error using vars.httpStatus returned by Dataweave 2.0 in MUnit 2.1.3 in Mule 4?
Validating or Asserting http status code which is returned by data weave 2.0 in mule 4
In case the httpStatus is set by Transform and here is the way to validate it. Please note that by default the error code is type of Number. Ensure that you are considered as number during validation and not adding any quotes around code.
<munit:validation >
<munit-tools:assert-that
doc:name="Check http.Status 401"
doc:id="93e077c8-012c-46b8-ad41-14367f695fbc"
expression="#[vars.httpStatus]" is="#[MunitTools::equalTo(401)]"
message='Expected output is Http Unauthorized error' />
<logger level="INFO" doc:name="Logger" doc:id="40df23fa-e9e1-4061-83bb-d806518a5010" message="#[payload]" />
</munit:validation>
Thanks
Jayaraman Pancharathinam
28 Nov 2018
Keywords: Mulesoft, Mule 4, MUnit 2.1.3, Anypoint Studio, Mocking, SOAP web service call, Transform processor, Dataweave, %dw 2.0
Excellent!! You have provided very useful information in this article. I have read many articles in various sites but this article gives detailed information.
ReplyDeleteMulesoft Online Training
Mulesoft Training in Hyderabad
Thanks for sharing such a good and informative content to all of us
ReplyDeleteMulesoft Training in Hyderabad
Mulesoft Online Training
Thanks for sharing a useful information..
ReplyDeleteMulesoft Training in Hyderabad
Mulesoft Online Training
karabük
ReplyDeletetunceli
ardahan
giresun
ordu
RC5F5