aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java')
-rw-r--r--src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java b/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
index 16136ae2..648c0330 100644
--- a/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
+++ b/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
@@ -25,13 +25,14 @@ package org.onap.clamp.flow;
import static junit.framework.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+
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.clds.util.OnapLogConstants;
import org.onap.clamp.flow.log.FlowLogOperation;
import org.slf4j.MDC;
import org.slf4j.spi.MDCAdapter;
@@ -43,57 +44,57 @@ public class FlowLogOperationTest {
@Test
public void testStratLog() {
- //given
- Exchange exchange = new DefaultExchange(mock(CamelContext.class));
+ // given
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");
+ // 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");
+ Exchange exchange = new DefaultExchange(mock(CamelContext.class));
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");
+ // 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");
}
@Test
public void testInvokeLog() {
- //given
+ // given
final String mockEntity = "mockEntity";
final String mockServiceName = "mockSerivceName";
MDCAdapter mdcAdapter = MDC.getMDCAdapter();
- //when
+ // when
flowLogOperation.invokeLog(mockEntity, mockServiceName);
- //then
- String entity = mdcAdapter.get(ONAPLogConstants.MDCs.TARGET_ENTITY);
- String serviceName = mdcAdapter.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
- assertEquals(entity,mockEntity);
- assertEquals(serviceName,mockServiceName);
+ // then
+ String entity = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_ENTITY);
+ String serviceName = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME);
+ assertEquals(entity, mockEntity);
+ assertEquals(serviceName, mockServiceName);
}
- @Test
+ @Test
public void testEndLog() {
- //given
- MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
- MDCAdapter mdcAdapter = MDC.getMDCAdapter();
- ///when
- flowLogOperation.endLog();
- //then
- assertThat(mdcAdapter.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)).isNull();
+ // given
+ MDC.put(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
+ MDCAdapter mdcAdapter = MDC.getMDCAdapter();
+ /// when
+ flowLogOperation.endLog();
+ // then
+ assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
@Test
public void testErrorLog() {
- //given
- MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
+ // given
+ MDC.put(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
MDCAdapter mdcAdapter = MDC.getMDCAdapter();
- //when
+ // when
flowLogOperation.errorLog();
- //then
- assertThat(mdcAdapter.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)).isNull();
+ // then
+ assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
} \ No newline at end of file