aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-01 15:15:30 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-01 15:15:30 +0100
commit465bfe233d22c5366696028b50f47c3606806893 (patch)
tree6cd270f7060cbb7b043b3643ee9071083ba12691 /src/test
parentdc03cc0e64ec732d59b063331054073c85b4bf89 (diff)
Add SDC single config
Add SDC configuration JSON parser that is linked to SDC client API Issue-ID: CLAMP-81 Change-Id: I8c1c9e93813bf1444b1df455cafe0aab60236300 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
new file mode 100644
index 000000000..287bc1791
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.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.config.sdc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
+import org.onap.clamp.clds.util.ResourceFileUtil;
+
+/**
+ * This class tests the SDC Controller config.
+ */
+public class SdcSingleControllerConfigurationTest {
+
+ public final SdcSingleControllerConfiguration loadControllerConfiguration(String fileName, String sdcControllerName)
+ throws JsonParseException, JsonMappingException, IOException {
+ JsonNode jsonNode = new ObjectMapper().readValue(ResourceFileUtil.getResourceAsStream(fileName),
+ JsonNode.class);
+ SdcSingleControllerConfiguration sdcSingleControllerConfiguration = new SdcSingleControllerConfiguration(
+ jsonNode, sdcControllerName);
+ return sdcSingleControllerConfiguration;
+ }
+
+ @Test
+ public final void testTheInit() throws SdcParametersException, IOException {
+ SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
+ "sdc-controller1");
+ assertEquals("User", sdcConfig.getUser());
+ assertEquals("ThePassword", sdcConfig.getPassword());
+ assertEquals("consumerGroup", sdcConfig.getConsumerGroup());
+ assertEquals("consumerId", sdcConfig.getConsumerID());
+ assertEquals("environmentName", sdcConfig.getEnvironmentName());
+ assertEquals("hostname", sdcConfig.getAsdcAddress());
+ assertEquals(10, sdcConfig.getPollingInterval());
+ assertEquals(30, sdcConfig.getPollingTimeout());
+ assertEquals(SdcSingleControllerConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size(),
+ sdcConfig.getRelevantArtifactTypes().size());
+ assertTrue(sdcConfig.activateServerTLSAuth());
+ assertEquals("ThePassword", sdcConfig.getKeyStorePassword());
+ }
+
+ @Test(expected = SdcParametersException.class)
+ public final void testAllRequiredParameters() throws JsonParseException, JsonMappingException, IOException {
+ SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
+ "sdc-controller1");
+ // No exception should be raised
+ sdcConfig.testAllRequiredParameters();
+ sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-bad.json", "sdc-controller1");
+ fail("Should have raised an exception");
+ }
+
+ @Test
+ public final void testConsumerGroupWithNULL() throws JsonParseException, JsonMappingException, IOException {
+ SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-NULL.json",
+ "sdc-controller1");
+ assertTrue(sdcConfig.getConsumerGroup() == null);
+ }
+}