4

Encountered munit failure with similar actual value and expected value. Both expected and actual value is in json format.
But the only different is their byte array. The actual value has 419 bytes and the expected value has 600 bytes. Could you help us how to solve this. Thanks

java.lang.AssertionError: The response payload is not correct! expected:<[
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  },
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  }
]> but was:<[
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  },
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  }
]>
    at post:/products/search:application/json:api-config-200-application/json-FlowTest.munit:assert-on-equals{doc:name=assert that - payload is as expected, actualValue=[
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  },
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  }
], expectedValue=[
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  },
  {
    "type": "abc",
    "customerAccount": "111",
    "id": "ABC"
  }
], message=The response payload is not correct!}(api-apikit-test.xml:31)
Scott Jones
  • 175
  • 2
  • 12
  • 2
    If you are expecting json to be same, why not to compare jsons? – Orifjon Apr 10 '17 at 05:40
  • Yes, I compare the json but it failed. The flow's last component is DataWeave, and the output payload has mime type application/json. https://forums.mulesoft.com/questions/54465/munit-java-convert-object-to-json.html – Scott Jones Apr 10 '17 at 06:31
  • Could you please show us the code of the test, the assertion part in particular. – Holgergp Apr 14 '17 at 10:19
  • It works. I just used jackson object mapper readTree()... #[(new com.fasterxml.jackson.databind.ObjectMapper().readTree(payload.toString())).equals(new com.fasterxml.jackson.databind.ObjectMapper().readTree(getResource('scaffolder/response/post_200_cust_search_app_json.json').asString()))] – Scott Jones Apr 28 '17 at 06:14

0 Answers0