Add unit tests for ConfigurationManager 75/88775/3
authorm.kowalski3 <m.kowalski3@partner.samsung.com>
Wed, 29 May 2019 14:07:52 +0000 (16:07 +0200)
committerOren Kleks <orenkle@amdocs.com>
Thu, 30 May 2019 10:14:52 +0000 (10:14 +0000)
Issue-ID: SDC-2327
Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
Change-Id: I2acfba224c46ffa743a254b1c560767b947f8fdd

common-app-api/src/test/java/org/openecomp/sdc/be/config/ConfigurationManagerTest.java [new file with mode: 0644]
common-app-api/src/test/resources/config/common/configuration.yaml [new file with mode: 0644]
common-app-api/src/test/resources/config/common/ecomp-error-configuration.yaml [new file with mode: 0644]
common-app-api/src/test/resources/config/common/error-configuration.yaml [new file with mode: 0644]

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
new file mode 100644 (file)
index 0000000..513c237
--- /dev/null
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP SDC
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. 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.be.config;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.config.EcompErrorConfiguration;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
+
+public class ConfigurationManagerTest {
+
+    private ConfigurationManager configurationManager;
+
+    @Before
+    public void setConfigurationSource() {
+        String appConfigDir = "src/test/resources/config/common";
+        ConfigurationSource configurationSource =
+                new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        configurationManager = new ConfigurationManager(configurationSource);
+    }
+
+    @Test
+    public void testGetConfiguration() {
+        assertEquals(configurationManager.getConfiguration(),
+                ConfigurationManager.getConfigurationManager().configurations.get(Configuration.class.getSimpleName()));
+    }
+
+    @Test
+    public void testGetErrorConfiguration() {
+        assertEquals(configurationManager.getErrorConfiguration(),
+                ConfigurationManager.getConfigurationManager().configurations
+                        .get(ErrorConfiguration.class.getSimpleName()));
+    }
+
+    @Test
+    public void testGetEcompErrorConfiguration() {
+        assertEquals(configurationManager.getEcompErrorConfiguration(),
+                ConfigurationManager.getConfigurationManager().configurations
+                        .get(EcompErrorConfiguration.class.getSimpleName()));
+    }
+
+    @Test
+    public void testGetDistributionEngineConfiguration() {
+        assertEquals(configurationManager.getDistributionEngineConfiguration(),
+                ConfigurationManager.getConfigurationManager().configurations
+                        .get(DistributionEngineConfiguration.class.getSimpleName()));
+    }
+
+}
diff --git a/common-app-api/src/test/resources/config/common/configuration.yaml b/common-app-api/src/test/resources/config/common/configuration.yaml
new file mode 100644 (file)
index 0000000..59d4121
--- /dev/null
@@ -0,0 +1,62 @@
+identificationHeaderFields:
+  - HTTP_IV_USER
+
+# catalog backend hostname
+beFqdn: localhost
+# sdccatalog.com
+
+# catalog backend http port
+beHttpPort: 8080
+
+# catalog backend http context
+beContext: /sdc/rest/config/get
+
+# catalog backend protocol
+beProtocol: http
+
+# catalog backend ssl port
+beSslPort: 8443
+
+version: 1.1.0
+released: 2012-11-30
+toscaConformanceLevel: 8.0
+minToscaConformanceLevel: 3.0
+
+titanCfgFile: /home/vagrant/catalog-be/config/catalog-be/titan.properties
+titanInMemoryGraph: false
+titanLockTimeout: 1800
+
+# The interval to try and reconnect to titan DB when it is down during ASDC startup:
+titanReconnectIntervalInSeconds: 3
+
+# The read timeout towards Titan DB when health check is invoked:
+titanHealthCheckReadTimeout: 1
+
+# The interval to try and reconnect to Elasticsearch when it is down during ASDC startup:
+esReconnectIntervalInSeconds: 3
+uebHealthCheckReconnectIntervalInSeconds: 15
+uebHealthCheckReadTimeout: 4
+
+# Protocols
+protocols:
+  - http
+  - https
+
+# Default imports
+defaultImports:
+  - nodes:
+      file: nodes.yml
+  - datatypes:
+      file: data.yml
+  - capabilities:
+      file: capabilities.yml
+  - relationships:
+      file: relationships.yml
+  - groups:
+      file: groups.yml
+  - policies:
+      file: policies.yml
+
+# Users
+users:
+  tom: passwd
diff --git a/common-app-api/src/test/resources/config/common/ecomp-error-configuration.yaml b/common-app-api/src/test/resources/config/common/ecomp-error-configuration.yaml
new file mode 100644 (file)
index 0000000..64bd77e
--- /dev/null
@@ -0,0 +1,25 @@
+errors:
+
+  BeRestApiGeneralError: {
+    type: SYSTEM_ERROR,
+    code: ASDC_4000,
+    severity: ERROR,
+    description: "Unexpected error during BE REST API execution",
+    alarmSeverity: CRITICAL
+  }
+
+  BeHealthCheckError: {
+    type: SYSTEM_ERROR,
+    code: ASDC_3010,
+    severity: ERROR,
+    description: "Error during BE Health Check",
+    alarmSeverity: CRITICAL
+  }
+
+  BeInitializationError: {
+    type: SYSTEM_ERROR,
+    code: ASDC_4019,
+    severity: ERROR,
+    description: "Catalog-BE was not initialized properly",
+    alarmSeverity: CRITICAL
+  }
\ No newline at end of file
diff --git a/common-app-api/src/test/resources/config/common/error-configuration.yaml b/common-app-api/src/test/resources/config/common/error-configuration.yaml
new file mode 100644 (file)
index 0000000..9db9bbd
--- /dev/null
@@ -0,0 +1,26 @@
+# Errors
+errors:
+    OK: {
+        code: 200,
+        message: "OK"
+    }
+    CREATED: {
+        code: 201,
+        message: "OK"
+    }
+    NO_CONTENT: {
+        code: 204,
+        message: "No Content"
+    }
+#--------POL4050-----------------------------
+    NOT_ALLOWED: {
+        code: 405,
+        message: "Error: Method not allowed.",
+        messageId: "POL4050"
+    }
+#--------POL5000-----------------------------
+    GENERAL_ERROR: {
+        code: 500,
+        message: "Error: Internal Server Error. Please try again later.",
+        messageId: "POL5000"
+    }