aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-logging/src/test/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-logging/src/test/java/org/openecomp')
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java2
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java37
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java29
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java20
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java26
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java22
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java30
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java88
8 files changed, 69 insertions, 185 deletions
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
index 1634115b06..c6b854ea06 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
@@ -26,7 +26,7 @@ import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
import static org.junit.Assert.*;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
public class LogFieldsMdcHandlerTest {
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java
index 4b0533ae24..1bd733664e 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.elements;
@@ -45,16 +25,21 @@ import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
+/**
+ * Created by dd4296 on 12/19/2017.
+ *
+ * test get partner name
+ */
@RunWith(MockitoJUnitRunner.class)
public class LoggerAsdcUtilTest {
- private static final String chromeUserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
- private static final String firefoxUserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 Firefox";
- private static final String explorerUserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)";
+ private final String chromeUserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
+ private final String firefoxUserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 Firefox";
+ private final String explorerUserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)";
- private static final String testUserId = "ml007";
- private static final String urlWithUserName = "/api/v1/user/" + testUserId;
- private static final String xOnapPartnerName = "ml007";
+ private final String testUserId = "ml007";
+ private final String urlWithUserName = "/api/v1/user/" + testUserId;
+ private final String xOnapPartnerName = "ml007";
class SdcEelfAuditTest extends LoggerSdcAudit {
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java
index 7ca1cf16cc..8c37e23d97 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.elements;
import org.junit.After;
@@ -38,7 +18,14 @@ import java.net.UnknownHostException;
import java.util.UUID;
import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.*;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_CLASS_NAME;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_ELAPSED_TIME;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_END_TIMESTAMP;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_PROCESS_KEY;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_REMOTE_HOST;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVER_IP_ADDRESS;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVICE_INSTANCE_ID;
import static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress;
import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.DATA_ERROR;
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java
index 91e1aab267..b423102cb3 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.elements;
import org.junit.Test;
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java
index 020b55cba6..404f5c1c62 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java
@@ -1,25 +1,9 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.elements;
+/**
+ * Created by dd4296 on 12/25/2017.
+ */
+
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -37,7 +21,7 @@ import java.net.UnknownHostException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
@RunWith(MockitoJUnitRunner.class)
public class LoggerDebugTest {
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java
index 06376ed48f..8d54397c88 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.elements;
import org.junit.Before;
@@ -34,7 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.MDC;
import static org.junit.Assert.assertEquals;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.MDC_ERROR_CODE;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_ERROR_CODE;
@RunWith(MockitoJUnitRunner.class)
public class LoggerErrorTest {
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java
index 3bd1afcce9..0d8c80797d 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.elements;
import org.junit.After;
@@ -28,6 +8,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.common.log.enums.LogLevel;
+import org.openecomp.sdc.common.log.enums.Severity;
import org.openecomp.sdc.common.log.utils.LoggingThreadLocalsHolder;
import org.slf4j.Logger;
import org.slf4j.MDC;
@@ -39,7 +20,14 @@ import java.util.UUID;
import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.*;
import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_CLASS_NAME;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_ELAPSED_TIME;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_END_TIMESTAMP;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_PROCESS_KEY;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_REMOTE_HOST;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVER_IP_ADDRESS;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVICE_INSTANCE_ID;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY;
import static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress;
/**
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java
index fd66efffc7..da721fa4f5 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java
@@ -1,23 +1,3 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package org.openecomp.sdc.common.log.wrappers;
import org.junit.Before;
@@ -29,7 +9,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.openecomp.sdc.common.log.api.LogConfigurationConstants;
+import org.openecomp.sdc.common.log.api.ILogConfiguration;
import org.openecomp.sdc.common.log.elements.ErrorLogOptionalData;
import org.openecomp.sdc.common.log.elements.LoggerError;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
@@ -46,14 +26,12 @@ import javax.ws.rs.core.UriInfo;
import java.net.URI;
import java.net.URISyntaxException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.REQUEST_ID;
import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.SERVICE_NAME;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.MDC_ERROR_CATEGORY;
-import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.MDC_ERROR_CODE;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
@RunWith(MockitoJUnitRunner.class)
public class LoggerTest {
@@ -63,6 +41,7 @@ public class LoggerTest {
private final static String serviceName = "testService";
private final static String message = "Logger message";
private final static String exceptionMsg= "Exception testing";
+ private final static String missingFieldsMessageFragment = "mandatory parameters for ECOMP logging";
@Mock
private org.slf4j.Logger logger;
@@ -91,8 +70,8 @@ public class LoggerTest {
verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
}
@@ -104,8 +83,8 @@ public class LoggerTest {
verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
}
@@ -117,8 +96,8 @@ public class LoggerTest {
verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.FATAL.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.FATAL.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
}
@@ -132,8 +111,8 @@ public class LoggerTest {
commonLogger.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message);
verify(logger).warn(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
@@ -147,8 +126,8 @@ public class LoggerTest {
commonLogger.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message);
verify(logger).warn(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
@@ -162,8 +141,8 @@ public class LoggerTest {
commonLogger.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message);
verify(logger).warn(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
@@ -179,8 +158,8 @@ public class LoggerTest {
commonLogger.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message);
verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
@@ -194,8 +173,8 @@ public class LoggerTest {
commonLogger.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message);
verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
@@ -209,8 +188,8 @@ public class LoggerTest {
commonLogger.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message);
verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
assertEquals(message, captor.getValue());
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(serviceName, MDC.get(SERVICE_NAME));
assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME));
@@ -230,8 +209,8 @@ public class LoggerTest {
commonLogger.error(message);
verify(logger).error(any(Marker.class), eq(message), any(Object[].class));
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertNull(MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(LoggerError.defaultServiceName, MDC.get(SERVICE_NAME));
}
@@ -268,13 +247,14 @@ public class LoggerTest {
@Test
public void validateErrorLogWithExceptionWhenErrorSettingsProvidedPartially() {
LoggingThreadLocalsHolder.setUuid("uuid");
+ final String logFieldsNotProvidedMsg = "mandatory parameters for ECOMP logging, missing fields: ServiceName PartnerName";
when(logger.isWarnEnabled()).thenReturn(true);
commonLogger.warn(message, new NullPointerException(exceptionMsg));
//the expected warn message
verify(logger).warn(any(Marker.class), contains(message), any(Object[].class));
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE));
- assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY));
+ assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE));
+ assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
assertEquals("uuid", MDC.get(REQUEST_ID));
assertNull(MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
assertEquals(LoggerError.defaultServiceName, MDC.get(SERVICE_NAME));
@@ -310,7 +290,7 @@ public class LoggerTest {
@Test
public void verifyMdcValuesAreStoredWhenAuditAndErrorLoggersAreInvokedSequentially() throws URISyntaxException {
final String uuid = "12345";
- final String messageInt = "message";
+ final String message = "message";
when(requestContext.getHeaderString(anyString())).thenReturn("ab2222");
when(requestContext.getUriInfo()).thenReturn(uriInfo);
when(logger.isErrorEnabled()).thenReturn(true);
@@ -323,11 +303,11 @@ public class LoggerTest {
LoggerSdcAudit audit = new LoggerSdcAudit(this.getClass());
LoggingThreadLocalsHolder.setUuid(uuid);
audit.startLog(requestContext);
- audit.logExit("abc.log.com", requestContext, statusType, LogLevel.INFO, Severity.OK, messageInt,
+ audit.logExit("abc.log.com", requestContext, statusType, LogLevel.INFO, Severity.OK, message,
MarkerFactory.getMarker(ONAPLogConstants.Markers.EXIT.getName()));
- commonLogger.error(messageInt);
- verify(logger).error(any(Marker.class), eq(messageInt), any(Object[].class));
+ commonLogger.error(message);
+ verify(logger).error(any(Marker.class), eq(message), any(Object[].class));
assertEquals(uuid, MDC.get(REQUEST_ID));
assertEquals("/", MDC.get(SERVICE_NAME));
assertEquals(LogLevel.ERROR.name(), MDC.get(MDC_ERROR_CATEGORY));
@@ -356,7 +336,7 @@ public class LoggerTest {
@Test
public void verifyMdcValuesAreStoredWhenTraceLoggerIsInvokedAfterAuditStart() throws URISyntaxException {
final String uuid = "12345";
- final String messageInt = "message";
+ final String message = "message";
when(requestContext.getHeaderString(anyString())).thenReturn("ab2222");
when(requestContext.getUriInfo()).thenReturn(uriInfo);
when(logger.isTraceEnabled()).thenReturn(true);
@@ -368,9 +348,9 @@ public class LoggerTest {
LoggingThreadLocalsHolder.setUuid(uuid);
audit.startLog(requestContext);
- commonLogger.trace(messageInt);
+ commonLogger.trace(message);
verify(logger).trace(any(Marker.class), captor.capture(), eq((Object[])null));
- assertEquals(messageInt, captor.getValue());
+ assertEquals(message, captor.getValue());
assertEquals(uuid, MDC.get(REQUEST_ID));
}