New parameter Sdc controller
There is a need to have that new parameter (message bus addresses) if
the sdcAddress is not present
Issue-ID: CLAMP-149
Change-Id: I336e7af6784a70b0b65c9610fc2e69e40126bdc0
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
diff --git a/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
index d8bd992..e2aac55 100644
--- a/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
@@ -28,6 +28,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import java.security.GeneralSecurityException;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -65,6 +66,7 @@
public static final String ACTIVATE_SERVER_TLS_AUTH = "activateServerTLSAuth";
public static final String KEY_STORE_KEY = "keyStorePassword";
public static final String KEY_STORE_PATH = "keyStorePath";
+ public static final String MESSAGE_BUS_ADDRESSES = "messageBusAddresses";
private String errorMessageKeyNotFound;
/**
* Supported artifact types.
@@ -239,7 +241,10 @@
throw new SdcParametersException(ENVIRONMENT_NAME_ATTRIBUTE_NAME + errorMessageKeyNotFound);
}
if (this.getAsdcAddress() == null || this.getAsdcAddress().isEmpty()) {
- throw new SdcParametersException(SDC_ADDRESS_ATTRIBUTE_NAME + errorMessageKeyNotFound);
+ if (this.getMsgBusAddress() == null || this.getMsgBusAddress().isEmpty()) {
+ throw new SdcParametersException(SDC_ADDRESS_ATTRIBUTE_NAME + " and " + MESSAGE_BUS_ADDRESSES
+ + " are not set, one of them should be set for SDC client" + errorMessageKeyNotFound);
+ }
}
if (this.getPassword() == null || this.getPassword().isEmpty()) {
throw new SdcParametersException(SDC_KEY_ATTRIBUTE_NAME + errorMessageKeyNotFound);
@@ -265,11 +270,17 @@
*/
@Override
public boolean isFilterInEmptyResources() {
- return true;
+ return false;
}
@Override
public List<String> getMsgBusAddress() {
- return null;
+ List<String> addressesList = new ArrayList<>();
+ if (jsonRootNode != null && jsonRootNode.get(MESSAGE_BUS_ADDRESSES) != null) {
+ jsonRootNode.get(MESSAGE_BUS_ADDRESSES).forEach(k -> addressesList.add(k.asText()));
+ return addressesList;
+ } else {
+ return addressesList;
+ }
}
}
diff --git a/src/main/resources/clds/sdc-controllers-config.json b/src/main/resources/clds/sdc-controllers-config.json
index df73a50..bf1a758 100644
--- a/src/main/resources/clds/sdc-controllers-config.json
+++ b/src/main/resources/clds/sdc-controllers-config.json
@@ -5,10 +5,11 @@
"consumerGroup": "consumerGroup1",
"consumerId": "consumerId1",
"environmentName": "environmentName1",
- "sdcAddress": "hostname1",
+ "sdcAddress": "sdc.api.simpledemo.onap.org:8080",
"password": "bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
"pollingInterval":10,
- "pollingTimeout":30
+ "pollingTimeout":30,
+ "messageBusAddresses":["localhost"]
},
"sdc-controller2":{
@@ -16,10 +17,11 @@
"consumerGroup": "consumerGroup2",
"consumerId": "consumerId2",
"environmentName": "environmentName2",
- "sdcAddress": "hostname2",
+ "sdcAddress": "sdc.api.simpledemo.onap.org:8080",
"password": "bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
"pollingInterval":10,
- "pollingTimeout":30
+ "pollingTimeout":30,
+ "messageBusAddresses":["localhost"]
}
}
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
index ecef30e..dd60d27 100644
--- a/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
+++ b/src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
@@ -20,6 +20,7 @@
package org.onap.clamp.clds.config.sdc;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -65,6 +66,9 @@
sdcConfig.getRelevantArtifactTypes().size());
assertTrue(sdcConfig.activateServerTLSAuth());
assertEquals("ThePassword", sdcConfig.getKeyStorePassword());
+ assertArrayEquals(new String[] {
+ "localhost"
+ }, sdcConfig.getMsgBusAddress().toArray());
}
@Test(expected = SdcParametersException.class)
@@ -77,6 +81,15 @@
fail("Should have raised an exception");
}
+ @Test(expected = SdcParametersException.class)
+ public final void testAllRequiredParametersAddresses()
+ throws JsonParseException, JsonMappingException, IOException {
+ SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration(
+ "clds/sdc-controller-config-bad-address.json", "sdc-controller1");
+ sdcConfig.testAllRequiredParameters();
+ fail("Should have raised an exception");
+ }
+
@Test
public final void testConsumerGroupWithNull() throws JsonParseException, JsonMappingException, IOException {
SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-NULL.json",
diff --git a/src/test/resources/clds/sdc-controller-config-TLS.json b/src/test/resources/clds/sdc-controller-config-TLS.json
index d7642e6..066448e 100644
--- a/src/test/resources/clds/sdc-controller-config-TLS.json
+++ b/src/test/resources/clds/sdc-controller-config-TLS.json
@@ -8,6 +8,7 @@
"pollingInterval":10,
"pollingTimeout":30,
"activateServerTLSAuth": true,
- "keyStorePassword":"bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
- "keyStorePath": "/test"
+ "keyStorePassword":"bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
+ "keyStorePath": "/test",
+ "messageBusAddresses":["localhost"]
}
diff --git a/src/test/resources/clds/sdc-controller-config-bad-address.json b/src/test/resources/clds/sdc-controller-config-bad-address.json
new file mode 100644
index 0000000..6775c6b
--- /dev/null
+++ b/src/test/resources/clds/sdc-controller-config-bad-address.json
@@ -0,0 +1,12 @@
+{
+ "user": "User",
+ "consumerGroup": "consumerGroup",
+ "consumerId": "consumerId",
+ "environmentName": "environmentName",
+ "password": "bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
+ "pollingInterval":10,
+ "pollingTimeout":30,
+ "activateServerTLSAuth": true,
+ "keyStorePassword":"bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
+ "keyStorePath": "/test"
+}
diff --git a/src/test/resources/clds/sdc-controllers-config.json b/src/test/resources/clds/sdc-controllers-config.json
index df73a50..ce56fef 100644
--- a/src/test/resources/clds/sdc-controllers-config.json
+++ b/src/test/resources/clds/sdc-controllers-config.json
@@ -5,21 +5,22 @@
"consumerGroup": "consumerGroup1",
"consumerId": "consumerId1",
"environmentName": "environmentName1",
- "sdcAddress": "hostname1",
+ "sdcAddress": "localhost:${docker.http-cache.port.host}",
"password": "bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
"pollingInterval":10,
- "pollingTimeout":30
-
+ "pollingTimeout":30,
+ "messageBusAddresses":["localhost"]
},
"sdc-controller2":{
"user": "User2",
"consumerGroup": "consumerGroup2",
"consumerId": "consumerId2",
"environmentName": "environmentName2",
- "sdcAddress": "hostname2",
+ "sdcAddress": "localhost:${docker.http-cache.port.host}",
"password": "bb3871669d893c7fb8aaacda31b77b4f537E67A081C2726889548ED7BC4C2DE6",
"pollingInterval":10,
- "pollingTimeout":30
+ "pollingTimeout":30,
+ "messageBusAddresses":["localhost"]
}
}