summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/test')
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java24
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java8
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java9
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java105
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java2
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/LoggerMetricTest.java322
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutableTest.java2
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientFactoryTest.java2
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactoryTest.java2
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java99
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java190
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java116
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java109
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java92
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java132
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java281
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java35
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/util/HealthCheckUtilTest.java3
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java23
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/AbstractSdncExceptionTest.java53
-rw-r--r--common-app-api/src/test/resources/config/common/configuration.yaml1
21 files changed, 71 insertions, 1539 deletions
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java
index 4878e8b85f..e12b37c107 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/BeEcompErrorManagerTest.java
@@ -87,18 +87,6 @@ public class BeEcompErrorManagerTest {
testSubject.logBeHealthCheckJanusGraphRecovery(context);
}
-
- @Test
- public void testLogBeHealthCheckElasticSearchRecovery() throws Exception {
- BeEcompErrorManager testSubject;
- String context = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.logBeHealthCheckElasticSearchRecovery(context);
- }
-
-
@Test
public void testLogBeHealthCheckUebClusterRecovery() throws Exception {
BeEcompErrorManager testSubject;
@@ -142,18 +130,6 @@ public class BeEcompErrorManagerTest {
testSubject.logBeHealthCheckJanusGraphError(context);
}
-
- @Test
- public void testLogBeHealthCheckElasticSearchError() throws Exception {
- BeEcompErrorManager testSubject;
- String context = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.logBeHealthCheckElasticSearchError(context);
- }
-
-
@Test
public void testLogBeHealthCheckUebClusterError() throws Exception {
BeEcompErrorManager testSubject;
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java
index a3d34e5ce2..8c5ce2a088 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java
@@ -80,15 +80,9 @@ public class ConfigurationManagerTest {
@Test
public void testGetDistributionEngineConfiguration() {
assertEquals(configurationManager.getDistributionEngineConfiguration(),
- ConfigurationManager.getConfigurationManager().getConfigurations()
+ ConfigurationManager.getConfigurationManager().configurations
.get(DistributionEngineConfiguration.class.getSimpleName()));
}
- @Test
- public void testGetNeo4jErrorsConfiguration() {
- assertEquals(configurationManager.getNeo4jErrorsConfiguration(),
- ConfigurationManager.getConfigurationManager().getConfigurations()
- .get(Neo4jErrorsConfiguration.class.getSimpleName()));
- }
private class TestConfiguration extends Configuration{}
@Test
public void testGetConfigurationAndWatch() {
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java
index cb92d355c1..055b41c921 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationTest.java
@@ -28,9 +28,7 @@ import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetter
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.MatcherAssert.assertThat;
-
public class ConfigurationTest {
- @Test
public void validateBean() {
assertThat(Configuration.class, allOf(
hasValidBeanConstructor(),
@@ -44,13 +42,6 @@ public class ConfigurationTest {
));
}
@Test
- public void validateBeanForElasticSearchConfig() {
- assertThat(Configuration.ElasticSearchConfig.class, allOf(
- hasValidBeanConstructor(),
- hasValidGettersAndSettersExcluding()
- ));
- }
- @Test
public void validateBeanForCassandrConfig() {
assertThat(Configuration.CassandrConfig.class, allOf(
hasValidBeanConstructor(),
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java
deleted file mode 100644
index 10da662827..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Modifications Copyright (c) 2019 Samsung
- * ================================================================================
- * 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.datastructure;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Map;
-import org.codehaus.jettison.json.JSONException;
-import org.junit.Test;
-
-
-public class ESTimeBasedEventTest {
-
- private ESTimeBasedEvent createTestSubject() {
- return new ESTimeBasedEvent();
- }
-
-
- @Test
- public void testCalculateYearIndexSuffix() {
- createTestSubject().calculateYearIndexSuffix();
- }
-
-
- @Test
- public void testCalculateMonthIndexSuffix() {
- createTestSubject().calculateMonthIndexSuffix();
- }
-
-
- @Test
- public void testCalculateDayIndexSuffix() {
- createTestSubject().calculateDayIndexSuffix();
- }
-
-
- @Test
- public void testCalculateHourIndexSuffix() {
- createTestSubject().calculateHourIndexSuffix();
- }
-
-
- @Test
- public void testCalculateMinuteIndexSuffix() {
- createTestSubject().calculateMinuteIndexSuffix();
- }
-
-
- @Test
- public void testGetTimestamp() {
- createTestSubject().getTimestamp();
- }
-
-
- @Test
- public void testSetTimestamp() {
- createTestSubject().setTimestamp("");
- }
-
-
- @Test
- public void testGetFields() {
- createTestSubject().getFields();
- }
-
-
- @Test
- public void testSetFields() {
- createTestSubject().setFields(null);
- }
-
- @Test
- public void testCreateEventFromJson() throws JSONException {
- //given
- String stringJson =
- "{\n \"TIMESTAMP\" : \"2000-05-01 20:00:00.000 z\",\n \"event_type\" : \"activation\" }";
- //when
- ESTimeBasedEvent esTimeBasedEvent = ESTimeBasedEvent.createEventFromJson(stringJson);
- Map<String, Object> fields = esTimeBasedEvent.getFields();
- //then
- assertEquals(esTimeBasedEvent.timestamp, "2000-05-01 20:00:00.000 z");
- assertEquals(fields.get("event_type"), "activation");
- }
-
-} \ No newline at end of file
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java
index 84465c7160..a62a410c0a 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/WrapperTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
public class WrapperTest {
private Wrapper createTestSubject() {
- return new Wrapper("test");
+ return new Wrapper(null);
}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/LoggerMetricTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/LoggerMetricTest.java
deleted file mode 100644
index e82dd1be84..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/ecomplog/LoggerMetricTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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.ecomplog;
-
-import org.junit.Test;
-
-import org.openecomp.sdc.common.log.elements.LoggerFactory;
-import org.openecomp.sdc.common.log.elements.LoggerMetric;
-import org.openecomp.sdc.common.log.enums.Severity;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-
-
-public class LoggerMetricTest {
- private static final Logger log = Logger.getLogger(LoggerMetricTest.class.getName());
-
- private LoggerMetric createTestSubject() {
- return LoggerFactory.getLogger(LoggerMetric.class,log);
- }
-
-
- @Test
- public void testStartTimer() throws Exception {
- LoggerMetric testSubject;
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.startTimer();
- }
-
-
- @Test
- public void testSetKeyRequestId() throws Exception {
- LoggerMetric testSubject;
- String keyRequestId = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setKeyRequestId(keyRequestId);
- }
-
-
- @Test
- public void testStopTimer() throws Exception {
- LoggerMetric testSubject;
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.stopTimer();
- }
-
-
- @Test
- public void testSetAutoServerFQDN() throws Exception {
- LoggerMetric testSubject;
- String serverFQDN = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setAutoServerFQDN(serverFQDN);
- }
-
-
- @Test
- public void testSetAutoServerIPAddress() throws Exception {
- LoggerMetric testSubject;
- String serverIPAddress = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setAutoServerIPAddress(serverIPAddress);
- }
-
-
- @Test
- public void testSetInstanceUUID() throws Exception {
- LoggerMetric testSubject;
- String instanceUUID = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setInstanceUUID(instanceUUID);
- }
-
-
- @Test
- public void testSetOptProcessKey() throws Exception {
- LoggerMetric testSubject;
- String processKey = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptProcessKey(processKey);
- }
-
-
- @Test
- public void testSetOptAlertSeverity() throws Exception {
- LoggerMetric testSubject;
- Severity alertSeverity = null;
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptAlertSeverity(alertSeverity.OK);
- }
-
-
- @Test
- public void testSetOptCustomField1() throws Exception {
- LoggerMetric testSubject;
- String customField1 = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptCustomField1(customField1);
- }
-
-
- @Test
- public void testSetOptCustomField2() throws Exception {
- LoggerMetric testSubject;
- String customField2 = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptCustomField2(customField2);
- }
-
-
- @Test
- public void testSetOptCustomField3() throws Exception {
- LoggerMetric testSubject;
- String customField3 = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptCustomField3(customField3);
- }
-
-
- @Test
- public void testSetOptCustomField4() throws Exception {
- LoggerMetric testSubject;
- String customField4 = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptCustomField4(customField4);
- }
-
-
- @Test
- public void testSetRemoteHost() throws Exception {
- LoggerMetric testSubject;
- String remoteHost = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setRemoteHost(remoteHost);
- }
-
-
- @Test
- public void testSetServiceName() throws Exception {
- LoggerMetric testSubject;
- String serviceName = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setServiceName(serviceName);
- }
-
-
- @Test
- public void testSetStatusCode() throws Exception {
- LoggerMetric testSubject;
- String statusCode = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setStatusCode(statusCode);
- }
-
-
- @Test
- public void testSetPartnerName() throws Exception {
- LoggerMetric testSubject;
- String partnerName = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setPartnerName(partnerName);
- }
-
-
- @Test
- public void testSetResponseCode() throws Exception {
- LoggerMetric testSubject;
- int responseCode = 0;
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setResponseCode(responseCode);
- }
-
-
- @Test
- public void testSetResponseDesc() throws Exception {
- LoggerMetric testSubject;
- String responseDesc = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setResponseDesc(responseDesc);
- }
-
-
- @Test
- public void testSetOptServiceInstanceId() throws Exception {
- LoggerMetric testSubject;
- String serviceInstanceId = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptServiceInstanceId(serviceInstanceId);
- }
-
-
- @Test
- public void testSetOptClassName() throws Exception {
- LoggerMetric testSubject;
- String className = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setOptClassName(className);
- }
-
-
- @Test
- public void testSetTargetEntity() throws Exception {
- LoggerMetric testSubject;
- String targetEntity = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setTargetEntity(targetEntity);
- }
-
-
- @Test
- public void testSetTargetServiceName() throws Exception {
- LoggerMetric testSubject;
- String targetServiceName = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setTargetServiceName(targetServiceName);
- }
-
-
- @Test
- public void testSetTargetVirtualEntity() throws Exception {
- LoggerMetric testSubject;
- String targetVirtualEntity = "";
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.setTargetVirtualEntity(targetVirtualEntity);
- }
-
-
- @Test
- public void testClear() throws Exception {
- LoggerMetric testSubject;
- LoggerMetric result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.clear();
- }
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutableTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutableTest.java
index eccd251b99..2593a000f8 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutableTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutableTest.java
@@ -24,11 +24,11 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.sdc.security.SecurityUtil;
import org.openecomp.sdc.common.http.config.BasicAuthorization;
import org.openecomp.sdc.common.http.config.ClientCertificate;
import org.openecomp.sdc.common.http.config.HttpClientConfig;
import org.openecomp.sdc.common.http.config.Timeouts;
-import org.openecomp.sdc.security.SecurityUtil;
import java.util.Collections;
import java.util.Map;
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientFactoryTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientFactoryTest.java
index ddfed06a66..c39bef0f4a 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientFactoryTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpClientFactoryTest.java
@@ -25,11 +25,11 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.sdc.security.SecurityUtil;
import org.openecomp.sdc.common.http.config.BasicAuthorization;
import org.openecomp.sdc.common.http.config.ClientCertificate;
import org.openecomp.sdc.common.http.config.HttpClientConfig;
import org.openecomp.sdc.common.http.config.Timeouts;
-import org.openecomp.sdc.security.SecurityUtil;
import java.util.Collections;
import java.util.Map;
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactoryTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactoryTest.java
index eb3263759e..2813d57cd0 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactoryTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactoryTest.java
@@ -22,8 +22,8 @@ package org.openecomp.sdc.common.http.client.api;
import org.apache.http.conn.HttpClientConnectionManager;
import org.junit.Test;
+import org.onap.sdc.security.SecurityUtil;
import org.openecomp.sdc.common.http.config.ClientCertificate;
-import org.openecomp.sdc.security.SecurityUtil;
import static org.junit.Assert.assertNotNull;
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
deleted file mode 100644
index 155ea4fb0b..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============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;
-import org.junit.Test;
-import org.slf4j.MDC;
-
-import static org.junit.Assert.*;
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-
-public class LogFieldsMdcHandlerTest {
-
- private LogFieldsMdcHandler ecompMdcWrapper;
-
- @Before
- public void init(){
- ecompMdcWrapper = new LogFieldsMdcHandler();
- ecompMdcWrapper.clear();
- MDC.clear();
- }
-
- @Test
- public void isMDCParamEmpty_shouldReturnTrue_onNonNullValueInMDC(){
- MDC.put("Key","value1");
- assertFalse(ecompMdcWrapper.isMDCParamEmpty("Key"));
- }
- @Test
- public void isMDCParamEmpty_shouldReturnFalse_onEmptyStringInMDC(){
- MDC.put("Key","");
- assertTrue(ecompMdcWrapper.isMDCParamEmpty("Key"));
- }
-
- @Test
- public void isMDCParamEmpty_shouldReturnFalse_onNullValueInMDC(){
- MDC.put("Key",null);
- assertTrue(ecompMdcWrapper.isMDCParamEmpty("Key"));
- }
-
- @Test
- public void startTimer_shouldFilecompMdcWrappereginTimestampField(){
- ecompMdcWrapper.startMetricTimer();
- assertFalse(ecompMdcWrapper.isMDCParamEmpty(MDC_METRIC_BEGIN_TIMESTAMP));
- }
-
- @Test
- public void stopTimer_shouldFillEndTimestampField_ifStartTimerWasCalledPreviously(){
- ecompMdcWrapper.startAuditTimer();
- ecompMdcWrapper.stopAuditTimer();
- assertFalse(ecompMdcWrapper.isMDCParamEmpty(MDC_END_TIMESTAMP));
- }
-
- @Test
- public void clear_shouldRemoveAllMandatoryAndOptionalFields_And_OnlyThem(){
- ecompMdcWrapper.setClassName("class1");
- ecompMdcWrapper.setPartnerName("partner1");
- ecompMdcWrapper.setOptCustomField1("of1");
- ecompMdcWrapper.clear();
- assertNull(MDC.get(MDC_CLASS_NAME));
- assertNull(MDC.get(MDC_PARTNER_NAME));
- assertNull(MDC.get(MDC_OPT_FIELD1));
- }
-
- @Test
- public void clear_shouldNotThrowAnException_WhenNoFieldWasAssignedAsMandatoryOrOptional(){
- ecompMdcWrapper.setClassName("class1");
- ecompMdcWrapper.setPartnerName("partner1");
- ecompMdcWrapper.setOptCustomField1("of1");
- Exception exp = null;
- try {
- ecompMdcWrapper.clear();
- }
- catch (Exception e)
- {
- exp =e;
- }
- assertNull(exp);
- }
-
-}
-
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java
deleted file mode 100644
index 693a084b25..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
-import org.openecomp.sdc.common.log.enums.LogLevel;
-import org.openecomp.sdc.common.log.enums.Severity;
-import org.openecomp.sdc.common.log.wrappers.LoggerSdcAudit;
-import org.openecomp.sdc.common.log.wrappers.LoggerSdcUtilBase;
-
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.core.UriInfo;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static java.net.HttpURLConnection.*;
-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 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 final String testUserId = "ml007";
- private final String urlWithUserName = "/api/v1/user/" + testUserId;
-
- class SdcEelfAuditTest extends LoggerSdcAudit {
-
- SdcEelfAuditTest(Class<?> clazz) {
- super(clazz);
- }
-
- public String getPartnerName(String userAgent, String userID, String url) {
- return super.getPartnerName(userAgent, userID, url);
- }
- }
-
- @Mock
- private ContainerRequestContext requestContext;
- @Mock
- UriInfo uriInfo;
-
- private SdcEelfAuditTest asdcEelfAudit;
-
- @Before
- public void Init () throws URISyntaxException {
- asdcEelfAudit = new SdcEelfAuditTest(LoggerAsdcUtilTest.class);
- when(requestContext.getHeaderString(anyString())).thenReturn("ab2222");
- when(requestContext.getUriInfo()).thenReturn(uriInfo);
- URI uri = new URI("http:/abc.com/getId");
- when(uriInfo.getRequestUri()).thenReturn(uri);
- when(uriInfo.getBaseUri()).thenReturn(uri);
-
- }
-
- @Test
- public void extract_user_id_from_userAgentTest() {
-
- String userIdChrome = asdcEelfAudit.getPartnerName(chromeUserAgent, "", "");
- assertEquals(userIdChrome.toLowerCase(), "chrome_FE".toLowerCase());
-
- String userIdFireFox = asdcEelfAudit.getPartnerName(firefoxUserAgent, "", "");
- assertEquals(userIdFireFox.toLowerCase(), "firefox_FE".toLowerCase());
-
- String userIdIE = asdcEelfAudit.getPartnerName(explorerUserAgent, "", "");
- assertEquals(userIdIE.toLowerCase(), "explorer_FE".toLowerCase());
- }
-
- @Test
- public void extract_user_id_from_urlTest() {
-
- String userId = asdcEelfAudit.getPartnerName("", "", urlWithUserName);
- assertEquals(testUserId, userId);
- }
-
- @Test
- public void extract_user_id_from_paramTest() {
-
- String userId = asdcEelfAudit.getPartnerName("", testUserId, "");
- assertEquals(userId, testUserId);
- }
-
- @Test
- public void extract_user_id_priorityTest() {
-
- String userId = asdcEelfAudit.getPartnerName(chromeUserAgent, testUserId, urlWithUserName);
- assertEquals(userId, testUserId);
-
- String userIdUrl = asdcEelfAudit.getPartnerName(chromeUserAgent, "", urlWithUserName);
- assertEquals(userIdUrl, testUserId);
-
- String userIdUserAgent = asdcEelfAudit.getPartnerName(chromeUserAgent, "", "");
- assertEquals(userIdUserAgent.toLowerCase(), "chrome_FE".toLowerCase());
- }
-
- @Test
- public void check_http_error_convert_to_eelf_code() {
- class LoggerSdcUtilBaseTest extends LoggerSdcUtilBase {
- public EcompLoggerErrorCode convertHttpCodeToErrorCode(int httpResponseCode) {
- return super.convertHttpCodeToErrorCode(httpResponseCode);
- }
- }
-
- LoggerSdcUtilBaseTest utilBase = new LoggerSdcUtilBaseTest();
-
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_BAD_REQUEST), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_UNAUTHORIZED), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_NOT_FOUND), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_CLIENT_TIMEOUT), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_GONE), EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR);
-
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_PAYMENT_REQUIRED), EcompLoggerErrorCode.PERMISSION_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_FORBIDDEN), EcompLoggerErrorCode.PERMISSION_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_BAD_METHOD), EcompLoggerErrorCode.PERMISSION_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_PROXY_AUTH), EcompLoggerErrorCode.PERMISSION_ERROR);
-
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_NOT_ACCEPTABLE), EcompLoggerErrorCode.DATA_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_LENGTH_REQUIRED), EcompLoggerErrorCode.DATA_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_PRECON_FAILED), EcompLoggerErrorCode.DATA_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_REQ_TOO_LONG), EcompLoggerErrorCode.DATA_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_ENTITY_TOO_LARGE), EcompLoggerErrorCode.DATA_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_UNSUPPORTED_TYPE), EcompLoggerErrorCode.DATA_ERROR);
-
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_CONFLICT), EcompLoggerErrorCode.SCHEMA_ERROR);
-
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_OK), EcompLoggerErrorCode.SUCCESS);
-
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_INTERNAL_ERROR), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_NOT_IMPLEMENTED), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_BAD_GATEWAY), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_UNAVAILABLE), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_GATEWAY_TIMEOUT), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR);
- Assert.assertEquals(utilBase.convertHttpCodeToErrorCode(HTTP_VERSION), EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR);
-
- }
-
- @Test
- public void takenCareOf_shouldBeTrue_ifStartedLogWasCalled(){
- asdcEelfAudit.startLog(requestContext);
- assertTrue(asdcEelfAudit.isFlowBeingTakenCare());
- }
-
- @Test
- public void takenCareOf_shouldBeFalse_ifStartedLogWasNoCalled(){
- assertFalse(asdcEelfAudit.isFlowBeingTakenCare());
- }
-
- @Test
- public void takenCareOf_shouldBeFalse_ifStartedLogWasCalleAndLogWasCalledToo(){
- asdcEelfAudit.startLog(requestContext);
-
- asdcEelfAudit.log(null,null,null, LogLevel.INFO, Severity.OK, "message");
- assertFalse(asdcEelfAudit.isFlowBeingTakenCare());
- }
-
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java
deleted file mode 100644
index 665fecec2c..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
-import org.openecomp.sdc.common.log.enums.LogLevel;
-import org.openecomp.sdc.common.log.enums.Severity;
-import org.openecomp.sdc.common.log.enums.StatusCode;
-import org.slf4j.Logger;
-import org.slf4j.MDC;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.UUID;
-
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-import static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LoggerAuditTest {
- @Mock
- private Logger logger;
-
- private LoggerAudit auditLog;
-
- @Before
- public void init() {
- auditLog = new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger);
- }
-
- @After
- public void tearDown() {
- MDC.clear();
- }
-
- @Test
- public void whenNoAuditFieldsArePopulated_ShouldReturnAssertTrue_onMdcMap() {
- auditLog.clear()
- .log(LogLevel.INFO, "some error code");
- Assert.assertNotNull(MDC.get(MDC_SERVER_FQDN));
- Assert.assertNotNull(MDC.get(MDC_SERVER_IP_ADDRESS));
- }
-
- @Test
- public void whenAllAuditFieldsArePopulated_ShouldReturnAssertTrue_onEachMACField() throws UnknownHostException {
-
- String uuid = UUID.randomUUID().toString();
- String hostName = InetAddress.getByName(hostAddress).getCanonicalHostName();
- String hostAddress = InetAddress.getLocalHost().getHostAddress();
-
- auditLog.clear()
- .startTimer()
- .stopTimer()
- .setKeyRequestId(uuid)
- .setInstanceUUID(MDC_INSTANCE_UUID)
- .setRemoteHost(MDC_REMOTE_HOST)
- .setServiceName(MDC_SERVICE_NAME)
- .setResponseCode(EcompLoggerErrorCode.DATA_ERROR)
- .setStatusCode("201")
- .setResponseDesc(MDC_RESPONSE_DESC)
- .setPartnerName(MDC_PARTNER_NAME)
-
- .setOptClassName(LoggerAuditTest.class.toString())
- .setOptAlertSeverity(Severity.CRITICAL)
- .setOptProcessKey(MDC_PROCESS_KEY)
- .setOptServiceInstanceId(MDC_SERVICE_INSTANCE_ID)
- .log(LogLevel.DEBUG, "");
-
-
- Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_AUDIT_BEGIN_TIMESTAMP));
- Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_END_TIMESTAMP));
- Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_ELAPSED_TIME));
-
- Assert.assertEquals(MDC.get(MDC_SERVER_IP_ADDRESS), hostAddress);
- Assert.assertEquals(MDC.get(MDC_SERVER_FQDN), hostName);
- Assert.assertEquals(MDC.get(MDC_REMOTE_HOST), MDC_REMOTE_HOST);
- Assert.assertEquals(MDC.get(MDC_STATUS_CODE), StatusCode.COMPLETE.getStatusCodeEnum());
-
- Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), uuid);
- Assert.assertEquals(MDC.get(MDC_SERVICE_NAME), MDC_SERVICE_NAME);
- Assert.assertEquals(MDC.get(MDC_PARTNER_NAME), MDC_PARTNER_NAME);
- Assert.assertEquals(MDC.get(MDC_RESPONSE_CODE), String.valueOf(EcompLoggerErrorCode.DATA_ERROR.getErrorCode()));
- Assert.assertEquals(MDC.get(MDC_RESPONSE_DESC), MDC_RESPONSE_DESC);
- Assert.assertEquals(MDC.get(MDC_INSTANCE_UUID), MDC_INSTANCE_UUID);
- Assert.assertEquals(MDC.get(MDC_CLASS_NAME), LoggerAuditTest.class.toString());
-
- Assert.assertEquals(MDC.get(MDC_ALERT_SEVERITY), String.valueOf(Severity.CRITICAL.getSeverityType()));
- Assert.assertEquals(MDC.get(MDC_PROCESS_KEY), MDC_PROCESS_KEY);
- Assert.assertEquals(MDC.get(MDC_SERVICE_INSTANCE_ID), MDC_SERVICE_INSTANCE_ID);
- }
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java
deleted file mode 100644
index 13f7804501..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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;
-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.util.ThreadLocalsHolder;
-import org.slf4j.Logger;
-import org.slf4j.MDC;
-
-import java.net.UnknownHostException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LoggerDebugTest {
-
- @Mock
- private Logger logger;
-
- private LoggerDebug debugLog;
-
- @Before
- public void init() {
- debugLog = new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger);
- ThreadLocalsHolder.setUuid(null);
- MDC.clear();
- }
-
- @Test
- public void whenNoFieldsIsPopulated_RequestedMdcFieldsAreEmpty() {
- debugLog.clear()
- .log(LogLevel.DEBUG, "some error code");
- assertNull(MDC.get(MDC_KEY_REQUEST_ID));
- }
-
- @Test
- public void debugLogCheckValidationValidFieldsTest() {
- debugLog.clear()
- .startTimer()
- .setKeyRequestId("uuid")
- .log(LogLevel.DEBUG, "some error code");
-
- Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), "uuid");
- }
-
- @Test
- public void whenOnlyDebugUUIDFieldsIsPopulated_ShouldReturnAssertTrue_onUUIDFieldCheck() {
- debugLog.clear()
- .setKeyRequestId("uuid")
- .log(LogLevel.DEBUG, "some error code");
-
- Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), "uuid");
- }
-
- @Test
- public void whenAllDebugFieldsArePopulated_ShouldReturnAssertTrue_onEachMACFieldCheck() throws UnknownHostException {
- debugLog.clear()
- .startTimer()
- .setKeyRequestId(MDC_KEY_REQUEST_ID)
- .log(LogLevel.DEBUG, "some message");
-
- Assert.assertTrue(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_END_TIMESTAMP));
- Assert.assertTrue(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_ELAPSED_TIME));
- Assert.assertTrue(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_STATUS_CODE));
- }
-
-
- @Test
- public void validateMandatoryFields(){
- assertEquals(MDC_KEY_REQUEST_ID, debugLog.checkMandatoryFieldsExistInMDC().trim());
- }
-
- @Test
- public void validateMandatoryFieldsWhenFieldIsSet(){
- debugLog.clear()
- .setKeyRequestId("1234");
- assertEquals("", debugLog.checkMandatoryFieldsExistInMDC());
- }
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java
deleted file mode 100644
index 99417f74bf..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.common.config.EcompErrorCode;
-import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
-import org.openecomp.sdc.common.log.enums.LogLevel;
-import org.openecomp.sdc.common.util.ThreadLocalsHolder;
-import org.slf4j.Logger;
-import org.slf4j.MDC;
-
-import static org.junit.Assert.assertEquals;
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LoggerErrorTest {
- private LoggerError errorLog;
-
- @Mock
- private Logger logger;
- @Before
- public void init() {
- errorLog = LoggerFactory.getMdcLogger(LoggerError.class, logger);
- MDC.clear();
- }
-
- @Test
- public void allFieldsArePresentTest() {
- ThreadLocalsHolder.setUuid("uuid");
- errorLog.log(LogLevel.ERROR, EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR, "service", "entity", "server error");
-
- Assert.assertEquals(MDC.get(MDC_ERROR_CODE), String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode()));
- Assert.assertEquals("uuid", MDC.get(MDC_KEY_REQUEST_ID));
- Assert.assertEquals("entity", MDC.get(MDC_TARGET_ENTITY));
- Assert.assertEquals("service", MDC.get(MDC_SERVICE_NAME));
- }
-
- @Test
- public void missingFieldsTest() {
- errorLog.clear()
- .log(LogLevel.ERROR,"some message");
- }
-
- @Test
- public void convertEcompErrorForLogging_correctName() {
- assertEquals(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR, EcompLoggerErrorCode.getByValue(EcompErrorCode.E_210.name()));
- }
-
- @Test
- public void convertEcompErrorForLogging_correctName_2() {
- assertEquals(EcompLoggerErrorCode.DATA_ERROR, EcompLoggerErrorCode.getByValue(EcompErrorCode.E_399.name()));
- }
-
- @Test
- public void convertEcompErrorForLogging_NotConvertable() {
- assertEquals(EcompLoggerErrorCode.UNKNOWN_ERROR, EcompLoggerErrorCode.getByValue("ABC"));
- }
-
- @Test
- public void convertEcompErrorForLogging_NotConvertable_2() {
- assertEquals(EcompLoggerErrorCode.UNKNOWN_ERROR, EcompLoggerErrorCode.getByValue("E_ABC"));
- }
-
- @Test
- public void convertEcompErrorForLogging_Success() {
- assertEquals(EcompLoggerErrorCode.SUCCESS, EcompLoggerErrorCode.getByValue("E_0"));
- }
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java
deleted file mode 100644
index 7d20d216ae..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-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.util.ThreadLocalsHolder;
-import org.slf4j.Logger;
-import org.slf4j.MDC;
-
-import javax.ws.rs.core.Response;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.UUID;
-
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-import static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress;
-
-/**
- * Created by dd4296 on 12/31/2017.
- */
-@RunWith(MockitoJUnitRunner.class)
-public class LoggerMetricTest {
- @Mock
- private Logger logger;
-
- @Mock
- Response.StatusType statusType;
-
- private LoggerMetric metricLog;
-
- @Before
- public void init() {
- metricLog = new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger);
- }
-
- @After
- public void tearDown() {
- MDC.clear();
- ThreadLocalsHolder.setUuid(null);
- }
-
- @Test
- public void whenNoMetricFieldsArePopulated_ShouldReturnassertEquals_onMdcMap() {
- metricLog.clear()
- .log(LogLevel.DEBUG, "some error code");
- Assert.assertNotNull(MDC.get(MDC_SERVER_FQDN));
- Assert.assertNotNull(MDC.get(MDC_SERVER_IP_ADDRESS));
- }
-
- @Test
- public void whenAllMetricFieldsArePopulated_ShouldReturnassertEquals_onEachMACField() throws UnknownHostException {
- String uuid = UUID.randomUUID().toString();
- ThreadLocalsHolder.setUuid(uuid);
-
- String hostName = InetAddress.getByName(hostAddress).getCanonicalHostName();
- String hostAddress = InetAddress.getLocalHost().getHostAddress();
-
- metricLog.clear()
- .startTimer()
- .stopTimer()
- .setInstanceUUID(MDC_INSTANCE_UUID)
- .setRemoteHost(MDC_REMOTE_HOST)
- .setServiceName(MDC_SERVICE_NAME)
- .setResponseCode(500)
- .setStatusCode("201")
- .setResponseDesc(MDC_RESPONSE_DESC)
- .setPartnerName(MDC_PARTNER_NAME)
-
- .setOptClassName(LoggerMetricTest.class.toString())
- .setOptAlertSeverity(Severity.CRITICAL)
- .setOptProcessKey(MDC_PROCESS_KEY)
- .setOptServiceInstanceId(MDC_SERVICE_INSTANCE_ID)
-
- .setTargetEntity(MDC_TARGET_ENTITY)
- .setTargetServiceName(MDC_TARGET_SERVICE_NAME)
- .setTargetVirtualEntity(MDC_TARGET_VIRTUAL_ENTITY)
-
- .log(LogLevel.DEBUG, "");
-
-
- Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_METRIC_BEGIN_TIMESTAMP));
- Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_END_TIMESTAMP));
- Assert.assertFalse(LogFieldsMdcHandler.getInstance().isMDCParamEmpty(MDC_ELAPSED_TIME));
-
- Assert.assertEquals(MDC.get(MDC_SERVER_IP_ADDRESS),hostAddress);
- Assert.assertEquals(MDC.get(MDC_SERVER_FQDN), hostName);
- Assert.assertEquals(MDC.get(MDC_REMOTE_HOST), MDC_REMOTE_HOST);
- Assert.assertEquals(MDC.get(MDC_STATUS_CODE) ,"201");
-
- Assert.assertEquals(MDC.get(MDC_KEY_REQUEST_ID), uuid);
- Assert.assertEquals(MDC.get(MDC_SERVICE_NAME) ,MDC_SERVICE_NAME);
- Assert.assertEquals(MDC.get(MDC_PARTNER_NAME) ,MDC_PARTNER_NAME);
- Assert.assertEquals(MDC.get(MDC_RESPONSE_CODE) ,"500");
- Assert.assertEquals(MDC.get(MDC_RESPONSE_DESC) ,MDC_RESPONSE_DESC);
- Assert.assertEquals(MDC.get(MDC_INSTANCE_UUID) ,MDC_INSTANCE_UUID);
- Assert.assertEquals(MDC.get(MDC_CLASS_NAME) ,LoggerMetricTest.class.toString());
-
- Assert.assertEquals(MDC.get(MDC_ALERT_SEVERITY) ,String.valueOf(Severity.CRITICAL.getSeverityType()));
- Assert.assertEquals(MDC.get(MDC_PROCESS_KEY) ,MDC_PROCESS_KEY);
- Assert.assertEquals(MDC.get(MDC_SERVICE_INSTANCE_ID) ,MDC_SERVICE_INSTANCE_ID);
-
- Assert.assertEquals(MDC.get(MDC_TARGET_ENTITY) ,MDC_TARGET_ENTITY);
- Assert.assertEquals(MDC.get(MDC_TARGET_SERVICE_NAME) ,MDC_TARGET_SERVICE_NAME);
- Assert.assertEquals(MDC.get(MDC_TARGET_VIRTUAL_ENTITY) ,MDC_TARGET_VIRTUAL_ENTITY);
- }
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java
deleted file mode 100644
index 858d777efd..0000000000
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 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;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.common.log.api.ILogConfiguration;
-import org.openecomp.sdc.common.log.elements.LoggerError;
-import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
-import org.openecomp.sdc.common.log.enums.LogLevel;
-import org.openecomp.sdc.common.log.enums.Severity;
-import org.openecomp.sdc.common.util.ThreadLocalsHolder;
-import org.slf4j.MDC;
-import org.slf4j.Marker;
-
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.core.Response;
-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.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.contains;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LoggerTest {
-
- private final static String targetEntity = "DCEA";
- 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;
- @Mock
- private ContainerRequestContext requestContext;
- @Mock
- private UriInfo uriInfo;
- @Mock
- private Response.StatusType statusType;
-
- @InjectMocks
- private Logger commonLogger;
-
- @Captor
- private ArgumentCaptor<String> captor;
-
- @Before
- public void setUp() {
- MDC.clear();
- }
-
- @Test
- public void validateErrorLogWhenErrorSettingsProvided() {
- when(logger.isErrorEnabled()).thenReturn(true);
- commonLogger.error(EcompLoggerErrorCode.PERMISSION_ERROR, serviceName, targetEntity, message);
-
- verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
- assertEquals(message, captor.getValue());
- 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(ILogConfiguration.MDC_TARGET_ENTITY));
- assertEquals(serviceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
- @Test
- public void validateWarnMessageIsLoggedWhenAllErrorSettingsProvided() {
- when(logger.isErrorEnabled()).thenReturn(true);
- commonLogger.error(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR, serviceName, targetEntity, message);
-
- 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(ILogConfiguration.MDC_ERROR_CODE));
- assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
- assertEquals(targetEntity, MDC.get(ILogConfiguration.MDC_TARGET_ENTITY));
- assertEquals(serviceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
- @Test
- public void validateFatalMessageIsLoggedWhenAllErrorSettingsProvided() {
- when(logger.isErrorEnabled()).thenReturn(true);
- commonLogger.fatal(EcompLoggerErrorCode.PERMISSION_ERROR, serviceName, targetEntity, message);
-
- verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class));
- assertEquals(message, captor.getValue());
- 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(ILogConfiguration.MDC_TARGET_ENTITY));
- assertEquals(serviceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
- @Test
- public void validateErrorMessageIsNotLoggedWhenErrorLevelIsDisabledEvenIfErrorSettingsProvided() {
- commonLogger.error(EcompLoggerErrorCode.PERMISSION_ERROR, serviceName, targetEntity, message);
- verify(logger, never()).error(any(Marker.class), any(String.class));
- }
-
- @Test
- public void validateErrorLogWhenErrorSettingsProvidedPartially() {
- when(logger.isErrorEnabled()).thenReturn(true);
- commonLogger.error(message);
-
- verify(logger).error(any(Marker.class), eq(message), any(Object[].class));
- 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(ILogConfiguration.MDC_TARGET_ENTITY));
- assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
- @Test
- public void errorMessageIsNotLoggedWhenErrorLevelIsDisabled() {
- commonLogger.error(message);
- verify(logger, times(0)).error(any(Marker.class), anyString());
- }
-
- @Test
- public void traceMessageWithExceptionIsNotLoggedWhenTraceLevelIsDisabled() {
- commonLogger.trace(message, new UnsupportedOperationException());
- verify(logger, times(0)).trace(any(Marker.class), anyString());
- }
-
- @Test
- public void verifyInfoMessage() {
- when(logger.isInfoEnabled()).thenReturn(true);
- commonLogger.info("Text");
- assertEquals(LogLevel.INFO.name(), MDC.get(MDC_ERROR_CATEGORY));
- assertEquals(String.valueOf(EcompLoggerErrorCode.SUCCESS.getErrorCode()), MDC.get(MDC_ERROR_CODE));
- assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
- @Test
- public void verifyWarnMessage() {
- when(logger.isWarnEnabled()).thenReturn(true);
- commonLogger.warn("Text");
- assertEquals(LogLevel.WARN.name(), MDC.get(MDC_ERROR_CATEGORY));
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(MDC_ERROR_CODE));
- assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
- @Test
- public void validateErrorLogWithExceptionWhenErrorSettingsProvidedPartially() {
- ThreadLocalsHolder.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(ILogConfiguration.MDC_ERROR_CODE));
- assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY));
- assertEquals("uuid", MDC.get(ILogConfiguration.MDC_KEY_REQUEST_ID));
- assertNull(MDC.get(ILogConfiguration.MDC_TARGET_ENTITY));
- assertEquals(LoggerError.defaultServiceName, MDC.get(ILogConfiguration.MDC_SERVICE_NAME));
- }
-
-
- @Test
- public void validateDebugLogWithException() {
- final String msg = "Debug message";
- ThreadLocalsHolder.setUuid("uuid");
- when(logger.isDebugEnabled()).thenReturn(true);
- commonLogger.debug(msg, new RuntimeException());
-
- verify(logger).debug(any(Marker.class), eq(msg), any(RuntimeException.class));
- }
-
- @Test
- public void validateTraceLogWithExceptionAndPartialParamsAndDebugLevelDisabled() {
- final String msg = "Debug message";
- when(logger.isTraceEnabled()).thenReturn(true);
- commonLogger.trace(msg, new RuntimeException());
-
- verify(logger).trace(any(Marker.class), eq(msg), any(RuntimeException.class));
- }
-
- @Test
- public void warnMessageWithParameterIsNotLoggedIfWarnLevelIsDisabled() {
- commonLogger.warn("msg", "param");
- verify(logger, times(0)).warn(any(Marker.class),
- anyString(), any(Object.class));
- }
-
- @Test
- public void verifyMdcValuesAreStoredWhenAuditAndErrorLoggersAreInvokedSequentially() throws URISyntaxException {
- final String uuid = "12345";
- final String message = "message";
- when(requestContext.getHeaderString(anyString())).thenReturn("ab2222");
- when(requestContext.getUriInfo()).thenReturn(uriInfo);
- when(logger.isErrorEnabled()).thenReturn(true);
-
- URI uri = new URI("http:/abc.com/getId");
- when(uriInfo.getRequestUri()).thenReturn(uri);
- when(uriInfo.getBaseUri()).thenReturn(uri);
- when(statusType.getStatusCode()).thenReturn(200);
- when(statusType.getReasonPhrase()).thenReturn("OK");
- LoggerSdcAudit audit = new LoggerSdcAudit(this.getClass());
- ThreadLocalsHolder.setUuid(uuid);
- audit.startLog(requestContext);
- audit.log("abc.log.com", requestContext, statusType, LogLevel.INFO, Severity.OK, message);
-
- commonLogger.error(message);
- verify(logger).error(any(Marker.class), eq(message), any(Object[].class));
- assertEquals(uuid, MDC.get(MDC_KEY_REQUEST_ID));
- assertEquals("/", MDC.get(MDC_SERVICE_NAME));
- assertEquals(LogLevel.ERROR.name(), MDC.get(MDC_ERROR_CATEGORY));
- assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(MDC_ERROR_CODE));
- }
-
- @Test
- public void verifyLoggerDoesNothingWhenTheLevelIsNotSet() {
- if (commonLogger.isDebugEnabled()) {
- commonLogger.debug("text");
- }
- verify(logger, times(0)).debug(any(Marker.class), anyString(), eq((Object[])null));
- }
-
- @Test
- public void verifyLoggerTraceMethodIsCalledWhenTheLevelIsSet() {
- ThreadLocalsHolder.setUuid("1234");
- when(logger.isTraceEnabled()).thenReturn(true);
- if (commonLogger.isTraceEnabled()) {
- commonLogger.trace("text");
- }
- verify(logger, times(1)).trace(any(Marker.class), anyString(), eq((Object[])null));
- }
-
-
- @Test
- public void verifyMdcValuesAreStoredWhenTraceLoggerIsInvokedAfterAuditStart() throws URISyntaxException {
- final String uuid = "12345";
- final String message = "message";
- when(requestContext.getHeaderString(anyString())).thenReturn("ab2222");
- when(requestContext.getUriInfo()).thenReturn(uriInfo);
- when(logger.isTraceEnabled()).thenReturn(true);
-
- URI uri = new URI("http:/abc.com/getId");
- when(uriInfo.getRequestUri()).thenReturn(uri);
- when(uriInfo.getBaseUri()).thenReturn(uri);
- LoggerSdcAudit audit = new LoggerSdcAudit(this.getClass());
- ThreadLocalsHolder.setUuid(uuid);
- audit.startLog(requestContext);
-
- commonLogger.trace(message);
- verify(logger).trace(any(Marker.class), captor.capture(), eq((Object[])null));
- assertEquals(message, captor.getValue());
- assertEquals(uuid, MDC.get(MDC_KEY_REQUEST_ID));
- }
-
-
-}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
index fadb9d47aa..73d8c116e2 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java
@@ -83,16 +83,6 @@ public class CommonUtilsTest {
}
- @Test
- public void testFloatParsing() {
- assertTrue(ValidationUtils.isFloatNumber("15555.45"));
- assertTrue(ValidationUtils.isFloatNumber("0.5"));
- assertFalse(ValidationUtils.isFloatNumber("15555"));
- assertFalse(ValidationUtils.isFloatNumber("1"));
- assertFalse(ValidationUtils.isFloatNumber("jk532"));
- assertFalse(ValidationUtils.isFloatNumber("12..6"));
-
- }
@Test
public void testValidateIconLength() {
@@ -380,31 +370,6 @@ public class CommonUtilsTest {
}
@Test
- public void validateConsumerNameTest() {
- assertTrue(ValidationUtils.validateConsumerName("ab037cd"));
- assertFalse(ValidationUtils.validateConsumerName(" "));
- assertTrue(ValidationUtils.validateConsumerName("_dD.d9"));
- assertTrue(ValidationUtils.validateConsumerName("_dd.G9-"));
- assertFalse(ValidationUtils.validateConsumerName(".dA.d9-"));
- assertFalse(ValidationUtils.validateConsumerName("-d"));
- assertFalse(ValidationUtils.validateConsumerName("d?"));
- assertTrue(ValidationUtils.validateConsumerName("9"));
- }
-
- @Test
- public void validateConsumerPassSaltTest() {
- assertTrue(ValidationUtils.validateConsumerPassSalt("ad35fg2"));
- assertTrue(ValidationUtils.validateConsumerPassSalt("12s"));
- assertTrue(ValidationUtils.validateConsumerPassSalt("9"));
- assertFalse(ValidationUtils.validateConsumerPassSalt("dA.d9-"));
- assertFalse(ValidationUtils.validateConsumerPassSalt("dASQe"));
- assertFalse(ValidationUtils.validateConsumerPassSalt("_d"));
- assertFalse(ValidationUtils.validateConsumerPassSalt("?"));
- assertFalse(ValidationUtils.validateConsumerPassSalt(""));
- assertFalse(ValidationUtils.validateConsumerPassSalt(" "));
- }
-
- @Test
public void validateCategoryNameFormatTest() {
assertTrue(ValidationUtils.validateCategoryDisplayNameFormat("Net ele-2_3#456&+.'=:@@@@@#####"));
// this will fail at length
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/HealthCheckUtilTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/HealthCheckUtilTest.java
index 3fc025eb22..d51f8c878b 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/HealthCheckUtilTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/HealthCheckUtilTest.java
@@ -76,10 +76,9 @@ public class HealthCheckUtilTest {
@Test
public void validateGetAggregateDescriptionReturnsProperDescription() {
- final String parentDescription = "";
when(healthCheckInfo.getHealthCheckStatus()).thenReturn(HealthCheckInfo.HealthCheckStatus.DOWN);
- final String result = healthCheckUtil.getAggregateDescription(healthCheckInfos, parentDescription);
+ final String result = healthCheckUtil.getAggregateDescription(healthCheckInfos );
assertTrue(result.contains(testComponent));
assertTrue(result.contains("Down"));
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java
index e9f607b976..467f1cf545 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/ValidationUtilsTest.java
@@ -19,6 +19,7 @@
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.common.util;
import com.google.common.collect.Lists;
@@ -526,7 +527,7 @@ public class ValidationUtilsTest {
@Test
public void checkValidateStringNotEmptyReturnsFalseIfStringIsNotEmpty() {
- final String testString = "test";
+ final String testString = "test";
boolean result = ValidationUtils.validateStringNotEmpty(testString);
@@ -802,10 +803,10 @@ public class ValidationUtilsTest {
}
@Test
- public void validateIsUTF8StrReturnsFalseIfGivenStringContainsUtf8Character() {
- final String testString = "testקString";
+ public void validateIsUTF8StrReturnsFalseIfGivenStringContainsUtf8Character(){
+final String testString="testקString";
- boolean result = ValidationUtils.isUTF8Str(testString);
+ boolean result=ValidationUtils.isUTF8Str(testString);
assertFalse(result);
}
@@ -892,10 +893,10 @@ public class ValidationUtilsTest {
}
@Test
- public void checkValidateArtifactLabelReturnsFalseIfLabelIsNotValid() {
- final String testArtifactDisplayName = "test=notValid=Label";
+ public void checkValidateArtifactLabelReturnsFalseIfLabelIsNotValid(){
+final String testArtifactDisplayName="test=notValid=Label";
- boolean result = ValidationUtils.validateArtifactLabel(testArtifactDisplayName);
+ boolean result=ValidationUtils.validateArtifactLabel(testArtifactDisplayName);
assertFalse(result);
}
@@ -910,13 +911,13 @@ public class ValidationUtilsTest {
}
@Test
- public void checkValidateConsumerNameReturnsFalseIfLabelIsNotValid() {
- final String testConsumerName = "test=notValid=ConsumerName";
+ public void checkValidateConsumerNameReturnsFalseIfLabelIsNotValid(){
+final String testConsumerName="test=notValid=ConsumerName";
- boolean result = ValidationUtils.validateConsumerName(testConsumerName);
+ boolean result=ValidationUtils.validateConsumerName(testConsumerName);
assertFalse(result);
- }
+ }
@Test
public void checkValidateConsumerPassSaltReturnsTrueIfLabelIsValid() {
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/AbstractSdncExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/AbstractSdncExceptionTest.java
new file mode 100644
index 0000000000..7b2dd19a68
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/AbstractSdncExceptionTest.java
@@ -0,0 +1,53 @@
+package org.openecomp.sdc.exception;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.openecomp.sdc.common.log.api.ILogConfiguration;
+import org.slf4j.MDC;
+
+public class AbstractSdncExceptionTest {
+ @Before
+ public void clearMdcTable(){
+ MDC.clear();
+ }
+
+
+ @Test
+ public void testServiceExceptionEcompRequestIdNull() {
+ String[] variables = {"1234","Test_VF"};
+ ServiceException serviceException = new ServiceException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
+ String requestId=serviceException.getEcompRequestId();
+ Assert.assertNull(requestId);
+ }
+
+ @Test
+ public void testServiceExceptionEcompRequestIdNotNull() {
+ String[] variables = {"1234","Test_VF"};
+ String expectedRequestId="b819266d-3b92-4e07-aec4-cb7f0d4010a4";
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,expectedRequestId);
+ ServiceException serviceException = new ServiceException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
+ String requestId=serviceException.getEcompRequestId();
+ Assert.assertEquals(requestId,expectedRequestId);
+ }
+
+
+ @Test
+ public void testPolicyExceptionEcompRequestIdfieldNull() {
+ String[] variables = {"1234","Test_VF"};
+ PolicyException policyexception = new PolicyException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
+ String requestId=policyexception.getEcompRequestId();
+ Assert.assertNull(requestId);
+ }
+
+ @Test
+ public void testPolicyExceptionEcompRequestIdNotNull() {
+ String[] variables = {"1234","Test_VF"};
+ String expectedRequestId="b819266d-3b92-4e07-aec4-cb7f0d4010a4";
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,expectedRequestId);
+ PolicyException policyexception = new PolicyException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
+ String requestId=policyexception.getEcompRequestId();
+ Assert.assertEquals(requestId,expectedRequestId);
+ }
+}
diff --git a/common-app-api/src/test/resources/config/common/configuration.yaml b/common-app-api/src/test/resources/config/common/configuration.yaml
index 24c7936d7f..eba8ee1c62 100644
--- a/common-app-api/src/test/resources/config/common/configuration.yaml
+++ b/common-app-api/src/test/resources/config/common/configuration.yaml
@@ -33,7 +33,6 @@ janusGraphReconnectIntervalInSeconds: 3
janusGraphHealthCheckReadTimeout: 1
# The interval to try and reconnect to Elasticsearch when it is down during ASDC startup:
-esReconnectIntervalInSeconds: 3
uebHealthCheckReconnectIntervalInSeconds: 15
uebHealthCheckReadTimeout: 4