### Question:
TracingDataCollectionHelper { public static String collectPayload(MessageContext messageContext) { String payload = null; try { org.apache.axis2.context.MessageContext a2mc = ((Axis2MessageContext) messageContext).getAxis2MessageContext(); RelayUtils.buildMessage(a2mc, false); if (JsonUtil.hasAJsonPayload(a2mc)) { payload = JsonUtil.jsonPayloadToString(a2mc); } else { payload = messageContext.getEnvelope().toString(); } } catch (Exception e) { payload = "NONE"; } return payload; }  static String collectPayload(MessageContext messageContext); static Map<String, Object> extractContextProperties(MessageContext synCtx); static Map<String, Object> extractTransportProperties(MessageContext synCtx); static PublishingFlow createPublishingFlow(List<StatisticsLog> messageFlowLogs);  }### Answer:
@Test public void testCollectPayloadNone() { MessageContext messageContext = new TestMessageContext(); String payload = TracingDataCollectionHelper.collectPayload(messageContext); Assert.assertEquals("should return NONE for invalid message context", "NONE", payload); }
@Test public void testCollectPayload() throws Exception { String payload = TracingDataCollectionHelper.collectPayload(messageContext); Assert.assertEquals("should return envelope for a valid messageContext", messageContext.getEnvelope().toString(), payload); }