aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm.kowalski3 <m.kowalski3@partner.samsung.com>2019-05-08 08:57:34 +0200
committerm.kowalski3 <m.kowalski3@partner.samsung.com>2019-05-08 08:58:18 +0200
commit7ba1265367a756ef3fcc98ca3babbf34674e0137 (patch)
tree342b77ff6806dbea9b71fdbac0731741e2478400
parent41e8ba1581415521546a4f6e91bfcc1ed32710d6 (diff)
Add unit tests fot FlowLogOperation
Change-Id: I499ca3ffe5d5f9a6fca4f5b92fc3c5da6a424d37 Issue-ID: CLAMP-355 Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
-rw-r--r--src/test/java/org/onap/clamp/flow/FlowLogOperationTestItCase.java41
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 00000000..1abeb104
--- /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