Я пытаюсь провести модульное тестирование заводного компонента.
<sub-flow name="public_sf_util_munit"
doc:description="Input:Mule Message
Processing:Adds correlationId to MuleMessage
Output:MuleMessage with populated correlationId property">
<scripting:component doc:name="Add correlationId">
<scripting:script engine="Groovy"><![CDATA[String correlationId = message.correlationId;
if(message.correlationId==null){
correlationId = message.getInboundProperty('x-messageid');
if(correlationId == null){
correlationId = message.rootId;
}
}
message.correlationId = correlationId;
return message]]></scripting:script>
</scripting:component>
</sub-flow>
В приведенной ниже строке ожидается свойство входящего сообщения, как я могу добавить его в свое тестовое сообщение Mule? Я использую MUnit 3.6.1.
correlationId = message.getInboundProperty('x-messageid');
Пока у меня есть тест, как показано ниже, и мне нужно добавить входящее свойство
@Test
public void givenAMuleMessageWithNullCorrelationIdAndXMessageIdHeader_whenCorrelationIdIsSet_itShouldSetCorrelationWithMessageId() throws Exception {
MuleEvent testEvent = testEvent("something");
MuleEvent resultMuleEvent = runFlow("transformToOutbound", testEvent);
assertThat(resultMuleEvent).isNotNull();
assertThat(resultMuleEvent.getMessage().getCorrelationId()).isEqualTo("321");
}