aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-01 15:19:28 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-01 15:19:28 +0100
commit44508f217d6df709ff4b9adbbe2898dfa9dee25e (patch)
tree7c271a6ae8ed24367273d71a11f930ffcab230a5 /src/test/java
parent4a991362827d0b04b9fc60bc64e79f73bf6a77bf (diff)
Add controller config code
Add SDC config parser code for mutliple SDC client configurations + unit tests Issue-ID: CLAMP-81 Change-Id: Ia97007463c6baf40456f97d9627da8b0ed3f4e49 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
new file mode 100644
index 000000000..4b632488a
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.onap.clamp.clds.it.config;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.clamp.clds.config.sdc.SdcControllersConfiguration;
+import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfiguration;
+import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
+
+/**
+ * This class tests the SDC Controller config.
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SdcControllersConfigurationItCase {
+
+ @Autowired
+ private SdcControllersConfiguration sdcControllersConfiguration;
+
+ public final void loadFile(String fileName) throws IOException {
+ ReflectionTestUtils.setField(sdcControllersConfiguration, "sdcControllerFile", fileName);
+ sdcControllersConfiguration.loadConfiguration();
+ }
+
+ @Test
+ public void testGetAllDefinedControllers() throws IOException {
+ loadFile("classpath:/clds/sdc-controllers-config.json");
+ Map<String, SdcSingleControllerConfiguration> mapResult = sdcControllersConfiguration
+ .getAllDefinedControllers();
+ assertTrue(mapResult.size() == 2);
+ assertEquals("sdc-controller1", mapResult.get("sdc-controller1").getSdcControllerName());
+ assertEquals("sdc-controller2", mapResult.get("sdc-controller2").getSdcControllerName());
+ }
+
+ @Test
+ public void testGetSdcSingleControllerConfiguration() throws IOException {
+ loadFile("classpath:/clds/sdc-controllers-config.json");
+ assertEquals("sdc-controller1", sdcControllersConfiguration
+ .getSdcSingleControllerConfiguration("sdc-controller1").getSdcControllerName());
+ assertEquals("sdc-controller2", sdcControllersConfiguration
+ .getSdcSingleControllerConfiguration("sdc-controller2").getSdcControllerName());
+ }
+
+ @Test(expected = IOException.class)
+ public void testBadJsonLoading() throws IOException {
+ loadFile("classpath:/clds/sdc-controllers-config-bad.json");
+ fail("Should have raised an exception");
+ }
+
+ @Test(expected = SdcParametersException.class)
+ public void testMissingParamInJsonLoading() throws IOException {
+ loadFile("classpath:/clds/sdc-controllers-config-missing-param.json");
+ sdcControllersConfiguration.getAllDefinedControllers();
+ fail("Should have raised an exception");
+ }
+}