aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt
diff options
context:
space:
mode:
authorRafal Wrzesniak <r.wrzesniak@partner.samsung.com>2021-09-30 12:08:03 +0200
committerRafal Wrzesniak <r.wrzesniak@partner.samsung.com>2021-10-15 14:38:06 +0200
commitb9ed86210c28d251c7503b9b0a5b543d957614e8 (patch)
treebeadba763f10c661e51976ce70249260ce29a39e /sdnr/wt
parent8f862e52cc36716503c5aea4973031eb4e10d930 (diff)
Adds handling CM provisioning messages
Adds config, consumer and changes to run it in MountpointRegistrar Issue-ID: CCSDK-3464 Signed-off-by: Rafal Wrzesniak <r.wrzesniak@partner.samsung.com> Change-Id: I800db7082dc4a84d73ac9e5dffd90c2f3c46ca82
Diffstat (limited to 'sdnr/wt')
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java53
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java6
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java32
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java2
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/ProvisioningConfig.java41
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java82
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java4
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestProvisioningConfig.java95
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid.json49
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid.json49
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/not_a_json.json10
11 files changed, 423 insertions, 0 deletions
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java
new file mode 100644
index 000000000..245807ec3
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java
@@ -0,0 +1,53 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DMaaPCMVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DMaaPCMVESMsgConsumer.class);
+
+ public DMaaPCMVESMsgConsumer(GeneralConfig generalConfig) {
+ super(generalConfig);
+ LOG.info("DMaaPCMVESMsgConsumer started successfully");
+ }
+
+ @Override
+ public void processMsg(String msg) throws InvalidMessageException, JsonProcessingException {
+ LOG.debug("Processing CM message {}", msg);
+ JsonNode rootNode = convertMessageToJsonNode(msg);
+ JsonNode dataNode;
+ JsonNode notificationNode;
+ try {
+ dataNode = rootNode.get("event").get("stndDefinedFields").get("data").requireNonNull();
+ if(dataNode.get("notificationType").textValue().equalsIgnoreCase("notifyMOIChanges")) {
+ notificationNode = dataNode.get("moiChanges");
+ LOG.info("Read CM message from DMaaP topic that is moiChanges type with id {}", dataNode.get("notificationId"));
+ }
+ } catch (NullPointerException e) {
+ LOG.warn("Message is invalid, sending aborted, processing stopped because one of fields is missing");
+ throw new InvalidMessageException("Missing field");
+ }
+ // take required data from notificationNode
+ }
+
+}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
index f6e70c6b5..fff243893 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
@@ -21,6 +21,8 @@ package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
import java.util.Properties;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.MRConsumer;
import org.onap.dmaap.mr.client.response.MRConsumerResponse;
@@ -95,6 +97,10 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer, DM
return true;
}
+ protected JsonNode convertMessageToJsonNode(String message) throws JsonProcessingException {
+ return new ObjectMapper().readTree(message);
+ }
+
/*
* Create a consumer by specifying properties containing information such as topic name, timeout, URL etc
*/
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
index 7ce618582..c694f1d2f 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
@@ -31,14 +31,17 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(DMaaPVESMsgConsumerMain.class);
private static final String _PNFREG_CLASS = "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer";
private static final String _FAULT_CLASS = "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer";
+ private static final String _CM_CLASS = "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPCMVESMsgConsumer";
private static final String _PNFREG_DOMAIN = "pnfRegistration";
private static final String _FAULT_DOMAIN = "fault";
+ private static final String _CM_DOMAIN = "provisioning";
boolean threadsRunning = false;
List<DMaaPVESMsgConsumer> consumers = new LinkedList<>();
private PNFRegistrationConfig pnfRegistrationConfig;
private FaultConfig faultConfig;
private GeneralConfig generalConfig;
+ private ProvisioningConfig provisioningConfig;
public DMaaPVESMsgConsumerMain(Map<String, MessageConfig> configMap, GeneralConfig generalConfig) {
this.generalConfig = generalConfig;
@@ -115,6 +118,33 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
faultConfig.getHTTPProxyPassword());
threadsRunning = createConsumer(_FAULT_DOMAIN, consumerProperties);
+ } else if (domain.equalsIgnoreCase(_CM_DOMAIN)) {
+ this.provisioningConfig = (ProvisioningConfig) domainConfig;
+ consumerClass = _CM_CLASS;
+ LOG.debug("Consumer class = {}", consumerClass);
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, provisioningConfig.getTransportType());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_HOST_PORT, provisioningConfig.getHostPort());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE, provisioningConfig.getContenttype());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_GROUP, provisioningConfig.getConsumerGroup());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_ID, provisioningConfig.getConsumerId());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TOPIC, provisioningConfig.getTopic());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TIMEOUT, provisioningConfig.getTimeout());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_LIMIT, provisioningConfig.getLimit());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE, provisioningConfig.getFetchPause());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, provisioningConfig.getProtocol());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_USERNAME, provisioningConfig.getUsername());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_PASSWORD, provisioningConfig.getPassword());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
+ provisioningConfig.getClientReadTimeout());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
+ provisioningConfig.getClientConnectTimeout());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
+ provisioningConfig.getHTTPProxyURI());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
+ provisioningConfig.getHTTPProxyUsername());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
+ provisioningConfig.getHTTPProxyPassword());
+ threadsRunning = createConsumer(_CM_DOMAIN, consumerProperties);
}
}
@@ -135,6 +165,8 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
consumer = new DMaaPPNFRegVESMsgConsumer(generalConfig);
else if (consumerType.equalsIgnoreCase(_FAULT_DOMAIN))
consumer = new DMaaPFaultVESMsgConsumer(generalConfig);
+ else if (consumerType.equalsIgnoreCase(_CM_DOMAIN))
+ consumer = new DMaaPCMVESMsgConsumer(generalConfig);
handleConsumer(consumer, properties, consumers);
return !consumers.isEmpty();
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java
index 0159ed4f8..136d2a12b 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java
@@ -55,9 +55,11 @@ public class MountpointRegistrarImpl implements AutoCloseable, IConfigChangedLis
generalConfig = new GeneralConfig(configFileRepresentation);
PNFRegistrationConfig pnfRegConfig = new PNFRegistrationConfig(configFileRepresentation);
FaultConfig faultConfig = new FaultConfig(configFileRepresentation);
+ ProvisioningConfig provisioningConfig = new ProvisioningConfig(configFileRepresentation);
configMap.put("pnfRegistration", pnfRegConfig);
configMap.put("fault", faultConfig);
+ configMap.put("provisioning", provisioningConfig);
dmaapEnabled = generalConfig.getEnabled();
if (dmaapEnabled) { // start dmaap consumer thread only if dmaapEnabled=true
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/ProvisioningConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/ProvisioningConfig.java
new file mode 100644
index 000000000..91a1f3fbe
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/ProvisioningConfig.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+
+public class ProvisioningConfig extends MessageConfig {
+
+ private static final String SECTION_MARKER = "provisioning";
+ private static final String DEFAULT_VALUE_CONSUMER_USERNAME = "${DMAAP_CM_TOPIC_USERNAME}";
+ private static final String DEFAULT_VALUE_CONSUMER_PASSWORD = "${DMAAP_CM_TOPIC_PASSWORD}";
+ private static final String DEFAULT_VALUE_CONSUMER_TOPIC = "unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT";
+
+ public ProvisioningConfig(ConfigurationFileRepresentation configuration) {
+ super(configuration);
+ sectionMarker = SECTION_MARKER;
+ super.configuration.addSection(SECTION_MARKER);
+ super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_USERNAME,
+ DEFAULT_VALUE_CONSUMER_USERNAME);
+ super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PASSWORD,
+ DEFAULT_VALUE_CONSUMER_PASSWORD);
+ super.configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TOPIC,
+ DEFAULT_VALUE_CONSUMER_TOPIC);
+ defaults();
+ }
+}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java
new file mode 100644
index 000000000..0cd7f0228
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java
@@ -0,0 +1,82 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.ccsdk.features.sdnr.wt.mountpointregistrar.test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPCMVESMsgConsumer;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.InvalidMessageException;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import static org.junit.Assert.fail;
+
+public class TestDMaaPCMVESMsgConsumer {
+
+ private static final String CONFIGURATION_FILE = "cm_test.properties";
+ private DMaaPCMVESMsgConsumer dMaaPCMVESMsgConsumer;
+ private GeneralConfigForTest generalConfigForTest;
+
+ @Before
+ public void setUp() throws Exception {
+ generalConfigForTest = new GeneralConfigForTest(CONFIGURATION_FILE);
+ dMaaPCMVESMsgConsumer = new DMaaPCMVESMsgConsumer(generalConfigForTest.getCfg());
+ }
+
+ @Test
+ public void processValidMsg() throws URISyntaxException, IOException {
+ File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_valid.json").toURI());
+ String cmEvent = readFileToString(cmFileValid);
+ try {
+ dMaaPCMVESMsgConsumer.processMsg(cmEvent);
+ } catch (Exception e) {
+ fail("Test fail with message: " + e.getMessage());
+ }
+ }
+
+ @Test(expected = InvalidMessageException.class)
+ public void processMsgThatMissesField() throws URISyntaxException, IOException, InvalidMessageException {
+ File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_invalid.json").toURI());
+ String cmEvent = readFileToString(cmFileInvalid);
+ dMaaPCMVESMsgConsumer.processMsg(cmEvent);
+ }
+
+ @Test(expected = JsonProcessingException.class)
+ public void processMsgThatIsNotValidJson() throws URISyntaxException, IOException, InvalidMessageException {
+ File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/not_a_json.json").toURI());
+ String cmEvent = readFileToString(cmFileInvalid);
+ dMaaPCMVESMsgConsumer.processMsg(cmEvent);
+ }
+
+ private String readFileToString(File file) throws IOException {
+ StringBuilder fileContent = new StringBuilder();
+ Files.lines(Paths.get(file.toURI())).forEach(fileContent::append);
+ return fileContent.toString();
+ }
+
+ @After
+ public void after() {
+ generalConfigForTest.close();
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java
index 11fb2f3b9..ecfb8d081 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPVESMsgConsumerMain.java
@@ -109,9 +109,11 @@ public class TestDMaaPVESMsgConsumerMain {
generalConfig = new GeneralConfig(configFileRepresentation);
PNFRegistrationConfig pnfRegConfig = new PNFRegistrationConfig(configFileRepresentation);
FaultConfig faultConfig = new FaultConfig(configFileRepresentation);
+ ProvisioningConfig provisioningConfig = new ProvisioningConfig(configFileRepresentation);
configMap.put("pnfRegistration", pnfRegConfig);
configMap.put("fault", faultConfig);
+ configMap.put("provisioning", provisioningConfig);
} catch (Exception e) {
System.out.println("Failed in preTest execution " + e.getMessage());
}
@@ -126,9 +128,11 @@ public class TestDMaaPVESMsgConsumerMain {
generalConfig = new GeneralConfig(configFileRepresentation);
PNFRegistrationConfig pnfRegConfig = new PNFRegistrationConfig(configFileRepresentation);
FaultConfig faultConfig = new FaultConfig(configFileRepresentation);
+ ProvisioningConfig provisioningConfig = new ProvisioningConfig(configFileRepresentation);
configMap.put("pnfRegistration", pnfRegConfig);
configMap.put("fault", faultConfig);
+ configMap.put("provisioning", provisioningConfig);
} catch (Exception e) {
System.out.println("Failed in preTest execution " + e.getMessage());
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestProvisioningConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestProvisioningConfig.java
new file mode 100644
index 000000000..42c204aec
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestProvisioningConfig.java
@@ -0,0 +1,95 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.ccsdk.features.sdnr.wt.mountpointregistrar.test;
+
+import static org.junit.Assert.assertEquals;
+import com.google.common.io.Files;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.ProvisioningConfig;
+
+public class TestProvisioningConfig {
+
+ private static final String TESTCONFIG_CONTENT = "[provisioning]\n"
+ + "TransportType=HTTPNOAUTH\n"
+ + "Protocol=http\n"
+ + "username=username\n"
+ + "password=password\n"
+ + "host=onap-dmap:3904\n"
+ + "topic=unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT\n"
+ + "contenttype=application/json\n"
+ + "group=myG\n"
+ + "id=C1\n"
+ + "timeout=20000\n"
+ + "limit=10000\n"
+ + "fetchPause=5000\n"
+ + "jersey.config.client.readTimeout=25000\n"
+ + "jersey.config.client.connectTimeout=25000\n"
+ + "jersey.config.client.proxy.uri=http://http-proxy\n"
+ + "jersey.config.client.proxy.username=proxy-user\n"
+ + "jersey.config.client.proxy.password=proxy-password\n"
+ + "";
+
+ private static final String TEMP_DIR = System.getProperty("java.io.tmpdir");
+ private static File configFile;
+
+ @Test
+ public void testConfigValuesAssignment() throws IOException {
+ configFile = new File(TEMP_DIR, "test.properties");
+ Files.asCharSink(configFile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(configFile);
+ ProvisioningConfig provisioningConfig = new ProvisioningConfig(cfg);
+ assertEquals("provisioning", provisioningConfig.getSectionName());
+ assertEquals("HTTPNOAUTH", provisioningConfig.getTransportType());
+ assertEquals("onap-dmap:3904", provisioningConfig.getHostPort());
+ assertEquals("unauthenticated.SEC_3GPP_PROVISIONING_OUTPUT", provisioningConfig.getTopic());
+ assertEquals("application/json", provisioningConfig.getContenttype());
+ assertEquals("myG", provisioningConfig.getConsumerGroup());
+ assertEquals("C1", provisioningConfig.getConsumerId());
+ assertEquals("20000", provisioningConfig.getTimeout());
+ assertEquals("10000", provisioningConfig.getLimit());
+ assertEquals("5000", provisioningConfig.getFetchPause());
+ assertEquals("http", provisioningConfig.getProtocol());
+ assertEquals("username", provisioningConfig.getUsername());
+ assertEquals("password", provisioningConfig.getPassword());
+ assertEquals("25000", provisioningConfig.getClientReadTimeout());
+ assertEquals("25000", provisioningConfig.getClientConnectTimeout());
+ assertEquals("http://http-proxy", provisioningConfig.getHTTPProxyURI());
+ assertEquals("proxy-user", provisioningConfig.getHTTPProxyUsername());
+ assertEquals("proxy-password", provisioningConfig.getHTTPProxyPassword());
+ }
+
+ @After
+ public void cleanUp() {
+ if (configFile.exists()) {
+ System.out.println(String.format("File %s exists, deleting it", configFile.getName()));
+ configFile.delete();
+ }
+ }
+
+}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid.json
new file mode 100644
index 000000000..eefd58836
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid.json
@@ -0,0 +1,49 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiChanges",
+ "data": {
+ "href": "href1",
+
+
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "moiChanges": [
+ {
+ "notificationId": 123,
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "MANAGEMENT_OPERATION",
+ "path":"https://samsung.com/3GPP/simulation/network-function/ves=1",
+
+ "value": {
+ "pnf-registration": "true",
+ "faults-enabled": "true"
+ }
+ }
+ ]
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid.json
new file mode 100644
index 000000000..fe9e4c278
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid.json
@@ -0,0 +1,49 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiChanges",
+ "data": {
+ "href": "href1",
+ "notificationId": 1,
+ "notificationType": "notifyMOIChanges",
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "moiChanges": [
+ {
+ "notificationId": 123,
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "MANAGEMENT_OPERATION",
+ "path":"https://samsung.com/3GPP/simulation/network-function/ves=1",
+ "operation": "REPLACE",
+ "value": {
+ "pnf-registration": "true",
+ "faults-enabled": "true"
+ }
+ }
+ ]
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/not_a_json.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/not_a_json.json
new file mode 100644
index 000000000..b1526562e
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/not_a_json.json
@@ -0,0 +1,10 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion":
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning"
+ }
+ }
+} \ No newline at end of file