Fix dcae url status
[clamp.git] / src / test / java / org / onap / clamp / flow / FlowLogOperationTestItCase.java
1 package org.onap.clamp.flow;
2
3 import org.apache.camel.CamelContext;
4 import org.apache.camel.Exchange;
5 import org.apache.camel.impl.DefaultExchange;
6 import org.junit.Test;
7 import org.mockito.Mockito;
8 import org.onap.clamp.clds.util.LoggingUtils;
9 import org.onap.clamp.clds.util.ONAPLogConstants;
10 import org.onap.clamp.flow.log.FlowLogOperation;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.test.util.ReflectionTestUtils;
13 import static org.assertj.core.api.Assertions.assertThat;
14 import static org.mockito.Mockito.mock;
15
16
17 public class FlowLogOperationTestItCase {
18
19     @Autowired
20     CamelContext camelContext;
21
22     @Test
23     public void testStratLog() {
24         //given
25         FlowLogOperation flowLogOperation = new FlowLogOperation();
26         Exchange exchange = new DefaultExchange(camelContext);
27         LoggingUtils loggingUtils = mock(LoggingUtils.class);
28         ReflectionTestUtils.setField(flowLogOperation, "util", loggingUtils);
29
30         //when
31         Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)).thenReturn("MockRequestId");
32         Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID)).thenReturn("MockInvocationId");
33         Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME)).thenReturn("MockPartnerName");
34         flowLogOperation.startLog(exchange, "serviceName");
35
36         //then
37         assertThat(exchange.getProperty(ONAPLogConstants.Headers.REQUEST_ID)).isEqualTo("MockRequestId");
38         assertThat(exchange.getProperty(ONAPLogConstants.Headers.INVOCATION_ID)).isEqualTo("MockInvocationId");
39         assertThat(exchange.getProperty(ONAPLogConstants.Headers.PARTNER_NAME)).isEqualTo("MockPartnerName");
40     }
41 }