diff options
-rw-r--r-- | src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java b/src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java new file mode 100644 index 000000000..1abeb104c --- /dev/null +++ b/src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java @@ -0,0 +1,41 @@ +package org.onap.clamp.flow; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.impl.DefaultExchange; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.clamp.clds.util.LoggingUtils; +import org.onap.clamp.clds.util.ONAPLogConstants; +import org.onap.clamp.flow.log.FlowLogOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.util.ReflectionTestUtils; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + + +public class FlowLogOperationTestItCase { + + @Autowired + CamelContext camelContext; + + @Test + public void testStratLog() { + //given + FlowLogOperation flowLogOperation = new FlowLogOperation(); + Exchange exchange = new DefaultExchange(camelContext); + LoggingUtils loggingUtils = mock(LoggingUtils.class); + ReflectionTestUtils.setField(flowLogOperation, "util", loggingUtils); + + //when + Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)).thenReturn("MockRequestId"); + Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID)).thenReturn("MockInvocationId"); + Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME)).thenReturn("MockPartnerName"); + flowLogOperation.startLog(exchange, "serviceName"); + + //then + assertThat(exchange.getProperty(ONAPLogConstants.Headers.REQUEST_ID)).isEqualTo("MockRequestId"); + assertThat(exchange.getProperty(ONAPLogConstants.Headers.INVOCATION_ID)).isEqualTo("MockInvocationId"); + assertThat(exchange.getProperty(ONAPLogConstants.Headers.PARTNER_NAME)).isEqualTo("MockPartnerName"); + } +}
\ No newline at end of file |