summaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
authorJakub Zieba <jakub.zieba@nokia.com>2018-08-28 11:08:17 +0200
committerJakub Zieba <jakub.zieba@nokia.com>2018-08-28 11:37:06 +0200
commit5b4e3b195960af161604eccb1c1c805bb91c6648 (patch)
tree59809c77ec8597dbbcec49d0e1c6659ae70c8ffc /prh-app-server
parent0a64f9a3f976a2472c42729353773839deea5e02 (diff)
Fix config parser
Correct cloud config parser by fixing builder Change-Id: Ic381385138c4e78b4c3247e9cf66226f2fabdde0 Issue-ID: DCAEGEN2-696 Signed-off-by: Jakub Zieba <jakub.zieba@nokia.com>
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java4
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java131
2 files changed, 133 insertions, 2 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java
index 808c4a54..32d8a562 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParser.java
@@ -67,11 +67,11 @@ class CloudConfigParser {
DmaapConsumerConfiguration getDmaapConsumerConfig() {
return new ImmutableDmaapConsumerConfiguration.Builder()
- .timeoutMs(jsonObject.get("dmaap.dmaapConsumerConfiguration.timeoutMS").getAsInt())
+ .timeoutMs(jsonObject.get("dmaap.dmaapConsumerConfiguration.timeoutMs").getAsInt())
.dmaapHostName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapHostName").getAsString())
.dmaapUserName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapUserName").getAsString())
.dmaapUserPassword(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapUserPassword").getAsString())
- .dmaapUserPassword(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapTopicName").getAsString())
+ .dmaapTopicName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapTopicName").getAsString())
.dmaapPortNumber(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapPortNumber").getAsInt())
.dmaapContentType(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapContentType").getAsString())
.messageLimit(jsonObject.get("dmaap.dmaapConsumerConfiguration.messageLimit").getAsInt())
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java
new file mode 100644
index 00000000..6d74771d
--- /dev/null
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/configuration/CloudConfigParserTest.java
@@ -0,0 +1,131 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PNF-REGISTRATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.configuration;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.prh.config.*;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class CloudConfigParserTest {
+
+ private static final String correctJson =
+ "{\"aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors\": true, "
+ + "\"dmaap.dmaapProducerConfiguration.dmaapTopicName\": \"/events/unauthenticated.PNF_READY\", "
+ + "\"dmaap.dmaapConsumerCon"
+ + "figuration.timeoutMs\": -1, \"dmaap.dmaapConsumerConfiguration.dmaapHostName\": "
+ + "\"message-router.onap.svc.cluster.local\", \"aai.aaiClientConfiguration.aaiPnfPath\": "
+ + "\"/network/pnfs/pnf\", \"aai.aaiClientConfiguration.aai"
+ + "UserPassword\": \"AAI\", \"dmaap.dmaapConsumerConfiguration.dmaapUserName\": \"admin\", "
+ + "\"aai.aaiClientConfiguration.aaiBasePath\": \"/aai/v12\", "
+ + "\"dmaap.dmaapProducerConfiguration.dmaapPortNumber\": 3904, \"aai.aaiClientConf"
+ + "iguration.aaiHost\": \"aai.onap.svc.cluster.local\", "
+ + "\"dmaap.dmaapConsumerConfiguration.dmaapUserPassword\": \"admin\", "
+ + "\"dmaap.dmaapProducerConfiguration.dmaapProtocol\": \"http\", \"dmaap.dmaapProducerConfiguration.dmaapC"
+ + "ontentType\": \"application/json\", "
+ + "\"dmaap.dmaapConsumerConfiguration.dmaapTopicName\": \"/events/unauthenticated.SEC_OTHER_OUTPUT\", "
+ + "\"dmaap.dmaapConsumerConfiguration.dmaapPortNumber\": 3904, \"dmaap.dmaapConsumerConfi"
+ + "guration.dmaapContentType\": \"application/json\", \"dmaap.dmaapConsumerConfiguration.messageLimit\": "
+ + "-1, \"dmaap.dmaapConsumerConfiguration.dmaapProtocol\": \"http\", "
+ + "\"aai.aaiClientConfiguration.aaiUserName\": \"AAI\", \"dm"
+ + "aap.dmaapConsumerConfiguration.consumerId\": \"c12\", \"dmaap.dmaapProducerConfiguration.dmaapHostName\""
+ + ": \"message-router.onap.svc.cluster.local\", \"aai.aaiClientConfiguration.aaiHostPortNumber\": "
+ + "8443, \"dmaap.dmaapConsumerConfiguration.consumerGroup\": \"OpenDCAE-c12\", "
+ + "\"aai.aaiClientConfiguration.aaiProtocol\": \"https\", "
+ + "\"dmaap.dmaapProducerConfiguration.dmaapUserName\": \"admin\", "
+ + "\"dmaap.dmaapProducerConfiguration.dmaapUserPasswor"
+ + "d\": \"admin\"}";
+
+ private static final ImmutableAaiClientConfiguration correctAaiClientConfig =
+ new ImmutableAaiClientConfiguration.Builder()
+ .aaiHost("aai.onap.svc.cluster.local")
+ .aaiPort(8443)
+ .aaiUserName("AAI")
+ .aaiPnfPath("/network/pnfs/pnf")
+ .aaiIgnoreSslCertificateErrors(true)
+ .aaiUserPassword("AAI")
+ .aaiProtocol("https")
+ .aaiBasePath("/aai/v12")
+ .build();
+
+ private static final ImmutableDmaapConsumerConfiguration correctDmaapConsumerConfig =
+ new ImmutableDmaapConsumerConfiguration.Builder()
+ .timeoutMs(-1)
+ .dmaapHostName("message-router.onap.svc.cluster.local")
+ .dmaapUserName("admin")
+ .dmaapUserPassword("admin")
+ .dmaapTopicName("/events/unauthenticated.SEC_OTHER_OUTPUT")
+ .dmaapPortNumber(3904)
+ .dmaapContentType("application/json")
+ .messageLimit(-1)
+ .dmaapProtocol("http")
+ .consumerId("c12")
+ .consumerGroup("OpenDCAE-c12")
+ .build();
+
+ private static final ImmutableDmaapPublisherConfiguration correctDmaapPublisherConfig =
+ new ImmutableDmaapPublisherConfiguration.Builder()
+ .dmaapTopicName("/events/unauthenticated.PNF_READY")
+ .dmaapUserPassword("admin")
+ .dmaapPortNumber(3904)
+ .dmaapProtocol("http")
+ .dmaapContentType("application/json")
+ .dmaapHostName("message-router.onap.svc.cluster.local")
+ .dmaapUserName("admin")
+ .build();
+
+ private CloudConfigParser cloudConfigParser = new CloudConfigParser(new Gson().fromJson(correctJson, JsonObject.class));
+
+
+ @Test
+ public void shouldCreateAaiConfigurationCorrectly(){
+ // when
+ AaiClientConfiguration aaiClientConfig = cloudConfigParser.getAaiClientConfig();
+
+ // then
+ assertThat(aaiClientConfig).isNotNull();
+ assertThat(aaiClientConfig).isEqualToComparingFieldByField(correctAaiClientConfig);
+ }
+
+
+ @Test
+ public void shouldCreateDmaapConsumerConfigurationCorrectly(){
+ // when
+ DmaapConsumerConfiguration dmaapConsumerConfig = cloudConfigParser.getDmaapConsumerConfig();
+
+ // then
+ assertThat(dmaapConsumerConfig).isNotNull();
+ assertThat(dmaapConsumerConfig).isEqualToComparingFieldByField(correctDmaapConsumerConfig);
+ }
+
+
+ @Test
+ public void shouldCreateDmaapPublisherConfigurationCorrectly(){
+ // when
+ DmaapPublisherConfiguration dmaapPublisherConfig = cloudConfigParser.getDmaapPublisherConfig();
+
+ // then
+ assertThat(dmaapPublisherConfig).isNotNull();
+ assertThat(dmaapPublisherConfig).isEqualToComparingFieldByField(correctDmaapPublisherConfig);
+ }
+} \ No newline at end of file