summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2019-05-28 10:47:03 +0200
committerpwielebs <piotr.wielebski@nokia.com>2019-05-28 15:52:10 +0200
commit37dd2cb2d2ad38ad1e6dd83f3ff5b40bc2c0f614 (patch)
treef0ed1982612bdca8a2b17d67c554d53d5083f5d4 /prh-app-server/src
parent57cbc1a3e9f3c1b8049115461266d15736d2f391 (diff)
Refactor due to AAI model changes
Change-Id: I1684cb798b40c5d58b531549f2596582f14bc901 Issue-ID: DCAEGEN2-1533 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java18
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java5
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java26
-rw-r--r--prh-app-server/src/test/resources/correct_config.json77
-rw-r--r--prh-app-server/src/test/resources/flattened_configuration.json3
6 files changed, 18 insertions, 116 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
index 51d86399..63947fa9 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
@@ -82,16 +82,11 @@ class CbsContentParser {
AaiClientConfiguration getAaiClientConfig() {
return new ImmutableAaiClientConfiguration.Builder()
.pnfUrl(jsonObject.get("aai.aaiClientConfiguration.pnfUrl").getAsString())
- .aaiHost(jsonObject.get("aai.aaiClientConfiguration.aaiHost").getAsString())
- .aaiPort(jsonObject.get("aai.aaiClientConfiguration.aaiHostPortNumber").getAsInt())
.aaiUserName(jsonObject.get("aai.aaiClientConfiguration.aaiUserName").getAsString())
- .aaiPnfPath(jsonObject.get("aai.aaiClientConfiguration.aaiPnfPath").getAsString())
.aaiServiceInstancePath(jsonObject.get("aai.aaiClientConfiguration.aaiServiceInstancePath").getAsString())
.aaiIgnoreSslCertificateErrors(
jsonObject.get("aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors").getAsBoolean())
.aaiUserPassword(jsonObject.get("aai.aaiClientConfiguration.aaiUserPassword").getAsString())
- .aaiProtocol(jsonObject.get("aai.aaiClientConfiguration.aaiProtocol").getAsString())
- .aaiBasePath(jsonObject.get("aai.aaiClientConfiguration.aaiBasePath").getAsString())
.trustStorePath(jsonObject.get(SECURITY_TRUST_STORE_PATH).getAsString())
.trustStorePasswordPath(jsonObject.get(SECURITY_TRUST_STORE_PASS_PATH).getAsString())
.keyStorePath(jsonObject.get(SECURITY_KEY_STORE_PATH).getAsString())
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
index a0d844b1..ba0ed2a7 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
@@ -33,7 +33,6 @@ import org.onap.dcaegen2.services.prh.model.bbs.RelationshipWrapper;
import org.onap.dcaegen2.services.prh.model.utils.HttpUtils;
import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder;
import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.*;
-import org.onap.dcaegen2.services.sdk.rest.services.uri.URI.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,8 +50,8 @@ public class BbsActionsTaskImpl implements BbsActionsTask {
private static final Logger LOGGER = LoggerFactory.getLogger(BbsActionsTaskImpl.class);
private static final String ATTACHMENT_POINT = "attachmentPoint";
- private static final String LOGICAL_LINK_URI = "/network/logical-links/logical-link/";
- private static final String PNF_URI = "/network/pnfs/pnf/";
+ private static final String LOGICAL_LINK_URI = "/network/logical-links/logical-link";
+ private static final String PNF_URI = "/network/pnfs/pnf";
private final Config config;
private final RxHttpClient httpClient;
@@ -130,18 +129,13 @@ public class BbsActionsTaskImpl implements BbsActionsTask {
.builder()
.relationship(ImmutableRelationship
.builder()
- .relatedLink(PNF_URI + pnfName)
+ .relatedLink(PNF_URI + "/" + pnfName)
.build())
.build());
}
private String buildLogicalLinkUri(String linkName) {
- return new URIBuilder()
- .scheme(config.getAaiClientConfiguration().aaiProtocol())
- .host(config.getAaiClientConfiguration().aaiHost())
- .port(config.getAaiClientConfiguration().aaiPort())
- .path(config.getAaiClientConfiguration().aaiBasePath() + LOGICAL_LINK_URI + linkName)
- .build()
- .toString();
+ return config.getAaiClientConfiguration().pnfUrl().replace(PNF_URI, LOGICAL_LINK_URI) + "/" + linkName;
}
-} \ No newline at end of file
+}
+
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java
index fb0b1b43..b398c501 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/TestAppConfiguration.java
@@ -56,14 +56,9 @@ public class TestAppConfiguration {
public static ImmutableAaiClientConfiguration createDefaultAaiClientConfiguration() {
return new ImmutableAaiClientConfiguration.Builder()
.pnfUrl("https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf")
- .aaiHost("aai.onap.svc.cluster.local")
- .aaiPort(8443)
- .aaiProtocol("https")
.aaiUserName("AAI")
.aaiUserPassword("AAI")
.aaiIgnoreSslCertificateErrors(true)
- .aaiBasePath("/aai/v12")
- .aaiPnfPath("/network/pnfs/pnf")
.aaiServiceInstancePath("/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}")
.trustStorePath("/opt/app/prh/local/org.onap.prh.trust.jks")
.trustStorePasswordPath("change_it")
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
index 5edf15a8..c8b3a92b 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
@@ -20,23 +20,11 @@
package org.onap.dcaegen2.services.prh.tasks;
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.verifyZeroInteractions;
-
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.HttpResponseStatus;
-import java.io.InputStreamReader;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.onap.dcaegen2.services.prh.TestAppConfiguration;
@@ -52,13 +40,21 @@ import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;
+import java.io.InputStreamReader;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.*;
+
class BbsActionsTaskTest {
- private static final String CORRECT_LOGICAL_LINK_JSON = "bbs_action/correct_logical_link.json";
- public static final String AAI_URL = "https://aai.onap.svc.cluster.local:8443/aai/v12/network/logical-links/logical-link/some-link";
+ private static final String AAI_URL = "https://aai.onap.svc.cluster.local:8443/aai/v12/network/logical-links/logical-link/some-link";
private CbsConfiguration cbsConfiguration = mock(CbsConfiguration.class);
-
private AaiClientConfiguration aaiClientConfiguration = TestAppConfiguration.createDefaultAaiClientConfiguration();
private RxHttpClient httpClient = mock(RxHttpClient.class);
diff --git a/prh-app-server/src/test/resources/correct_config.json b/prh-app-server/src/test/resources/correct_config.json
deleted file mode 100644
index 7ec2f74c..00000000
--- a/prh-app-server/src/test/resources/correct_config.json
+++ /dev/null
@@ -1,77 +0,0 @@
-{
- "config":{
- "dmaap.dmaapConsumerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT",
- "dmaap.dmaapConsumerConfiguration.dmaapHostName":"dmaap-mr",
- "dmaap.dmaapConsumerConfiguration.dmaapPortNumber":2223,
- "dmaap.dmaapConsumerConfiguration.dmaapTopicName":"events/unauthenticated.VES_PNFREG_OUTPUT",
- "dmaap.dmaapConsumerConfiguration.dmaapProtocol":"http",
- "dmaap.dmaapConsumerConfiguration.dmaapUserName":"admin",
- "dmaap.dmaapConsumerConfiguration.dmaapUserPassword":"admin",
- "dmaap.dmaapConsumerConfiguration.dmaapContentType":"application/json",
- "dmaap.dmaapConsumerConfiguration.consumerId":"c12",
- "dmaap.dmaapConsumerConfiguration.consumerGroup":"OpenDCAE-c12",
- "dmaap.dmaapConsumerConfiguration.timeoutMs":-1,
- "dmaap.dmaapConsumerConfiguration.messageLimit":-1,
- "dmaap.dmaapProducerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.PNF_READY",
- "dmaap.dmaapProducerConfiguration.dmaapHostName":"dmaap-mr",
- "dmaap.dmaapProducerConfiguration.dmaapPortNumber":2223,
- "dmaap.dmaapProducerConfiguration.dmaapTopicName":"events/unauthenticated.PNF_READY",
- "dmaap.dmaapProducerConfiguration.dmaapProtocol":"http",
- "dmaap.dmaapProducerConfiguration.dmaapUserName":"admin",
- "dmaap.dmaapProducerConfiguration.dmaapUserPassword":"admin",
- "dmaap.dmaapProducerConfiguration.dmaapContentType":"application/json",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapUrl":"http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapHostName":"dmaap-mr",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber":2223,
- "dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName":"events/unauthenticated.PNF_UPDATE",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol":"http",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapUserName":"admin",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword":"admin",
- "dmaap.dmaapUpdateProducerConfiguration.dmaapContentType":"application/json",
- "aai.aaiClientConfiguration.pnfUrl":"https://aai:3333/aai/v12/network/pnfs/pnf",
- "aai.aaiClientConfiguration.aaiHost":"aai",
- "aai.aaiClientConfiguration.aaiHostPortNumber":3334,
- "aai.aaiClientConfiguration.aaiProtocol":"https",
- "aai.aaiClientConfiguration.aaiUserName":"DCAE",
- "aai.aaiClientConfiguration.aaiUserPassword":"DCAE",
- "aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors":true,
- "aai.aaiClientConfiguration.aaiBasePath":"/aai/v12",
- "aai.aaiClientConfiguration.aaiPnfPath":"/network/pnfs/pnf",
- "aai.aaiClientConfiguration.aaiServiceInstancePath":"/business/customers/customer//service-subscriptions/service-subscription//service-instances/service-instance/",
- "aai.aaiClientConfiguration.aaiHeaders":{
- "X-FromAppId":"prh",
- "X-TransactionId":"9999",
- "Accept":"application/json",
- "Real-Time":"true",
- "Authorization":"Basic QUFJOkFBSQ=="
- },
- "security.trustStorePath":"change it",
- "security.trustStorePasswordPath":"change it",
- "security.keyStorePath":"change it",
- "security.keyStorePasswordPath":"change it",
- "security.enableAaiCertAuth":false,
- "security.enableDmaapCertAuth":false,
- "streams_publishes":{
- "pnf-update":{
- "type": "message_router",
- "dmaap_info":{
- "topic_url":"http://dmaap-mr:2222/events/unauthenticated.PNF_UPDATE"
- }
- },
- "pnf-ready":{
- "type": "message_router",
- "dmaap_info":{
- "topic_url":"http://dmaap-mr:2222/events/unauthenticated.PNF_READY"
- }
- }
- },
- "streams_subscribes":{
- "ves-reg-output":{
- "type": "message_router",
- "dmaap_info":{
- "topic_url":"http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT"
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/prh-app-server/src/test/resources/flattened_configuration.json b/prh-app-server/src/test/resources/flattened_configuration.json
index 9997f583..4b846b70 100644
--- a/prh-app-server/src/test/resources/flattened_configuration.json
+++ b/prh-app-server/src/test/resources/flattened_configuration.json
@@ -29,8 +29,7 @@
"dmaap.dmaapUpdateProducerConfiguration.dmaapUserName":"admin",
"dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword":"admin",
"dmaap.dmaapUpdateProducerConfiguration.dmaapContentType":"application/json",
-
- "aai.aaiClientConfiguration.pnfUrl":"https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf",
+ "aai.aaiClientConfiguration.pnfUrl": "https://aai.onap.svc.cluster.local:8443/aai/v12/network/pnfs/pnf",
"aai.aaiClientConfiguration.aaiHost":"aai.onap.svc.cluster.local",
"aai.aaiClientConfiguration.aaiHostPortNumber":8443,
"aai.aaiClientConfiguration.aaiProtocol":"https",