aboutsummaryrefslogtreecommitdiffstats
path: root/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api
diff options
context:
space:
mode:
Diffstat (limited to 'prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api')
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiClientConfigurations.java60
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiGetServiceInstanceClientTest.java69
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpGetClientTest.java80
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpPatchClientTest.java93
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiPnfResultModelTest.java88
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiServiceInstanceResultModelTest.java90
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AbstractHttpClientTest.java41
7 files changed, 178 insertions, 343 deletions
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiClientConfigurations.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiClientConfigurations.java
deleted file mode 100644
index ab29e02a..00000000
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiClientConfigurations.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * DCAEGEN2-SERVICES-SDK
- * ================================================================================
- * Copyright (C) 2019 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.adapter.aai.api;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.onap.dcaegen2.services.prh.adapter.aai.main.AaiClientConfiguration;
-import org.onap.dcaegen2.services.prh.adapter.aai.main.ImmutableAaiClientConfiguration;
-
-public final class AaiClientConfigurations {
-
- private AaiClientConfigurations() {
- }
-
- public static AaiClientConfiguration secureConfiguration() {
- return secureConfiguration(new HashMap<>());
- }
-
- public static AaiClientConfiguration secureConfiguration(Map<String, String> headers) {
- return validConfiguration(headers, true);
- }
-
- public static AaiClientConfiguration insecureConfiguration() {
- return validConfiguration(new HashMap<>(), false);
- }
-
- private static AaiClientConfiguration validConfiguration(Map<String, String> headers, boolean secure) {
- return new ImmutableAaiClientConfiguration.Builder()
- .baseUrl("https://aai.onap.svc.cluster.local:8443/aai/v12")
- .aaiUserName("sample-username")
- .aaiUserPassword("sample-password")
- .aaiIgnoreSslCertificateErrors(false)
- .trustStorePath("/trust.pkcs12")
- .trustStorePasswordPath("/trust.pass")
- .keyStorePath("/server.pkcs12")
- .keyStorePasswordPath("/server.pass")
- .enableAaiCertAuth(secure)
- .aaiHeaders(headers)
- .aaiServiceInstancePath(
- "/business/customers/customer/${customer}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}")
- .build();
- }
-} \ No newline at end of file
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiGetServiceInstanceClientTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiGetServiceInstanceClientTest.java
deleted file mode 100644
index 551f93fb..00000000
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiGetServiceInstanceClientTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * DCAEGEN2-SERVICES-SDK
- * ================================================================================
- * Copyright (C) 2019 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.adapter.aai.api;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfigurations.secureConfiguration;
-
-import io.vavr.collection.HashMap;
-import io.vavr.collection.Map;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-class AaiGetServiceInstanceClientTest extends AbstractHttpClientTest {
-
- public static final String SERVICE_INSTANCE_PATH =
- "https://aai.onap.svc.cluster.local:8443/aai/v12/business/customers/customer/Demonstration/"
- + "service-subscriptions/service-subscription/VCPE/service-instances/service-instance/df018f76-7fc8-46ab-8444-7d67e1efc284";
-
- @Test
- void getAaiResponse_shouldCallGetMethod_withGivenAaiHeaders() {
-
- // given
- AaiServiceInstanceQueryModel model = mock(AaiServiceInstanceQueryModel.class);
- Map<String, String> headers = HashMap.of("sample-key", "sample-value");
- AaiGetServiceInstanceClient cut = new AaiGetServiceInstanceClient(secureConfiguration(headers.toJavaMap()),
- httpClient);
-
- given(model.customerId()).willReturn("Demonstration");
- given(model.serviceInstanceId()).willReturn("df018f76-7fc8-46ab-8444-7d67e1efc284");
- given(model.serviceType()).willReturn("VCPE");
-
- given(httpClient.call(any(HttpRequest.class)))
- .willReturn(Mono.just(response));
-
- // when
- StepVerifier
- .create(cut.getAaiResponse(model))
- .expectNext(response)
- .verifyComplete();
-
- //then
- verify(httpClient)
- .call(argThat(httpRequest -> httpRequest.customHeaders().equals(headers) &&
- httpRequest.url().equals(SERVICE_INSTANCE_PATH)));
- }
-}
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpGetClientTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpGetClientTest.java
deleted file mode 100644
index f69fca54..00000000
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpGetClientTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * DCAEGEN2-SERVICES-SDK
- * ================================================================================
- * Copyright (C) 2019 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.adapter.aai.api;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.verify;
-import static org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfigurations.secureConfiguration;
-
-import io.vavr.collection.HashMap;
-import io.vavr.collection.Map;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.services.prh.adapter.aai.main.AaiClientConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-class AaiHttpGetClientTest extends AbstractHttpClientTest {
-
- @Test
- void getAaiResponse_shouldCallGetMethod_withGivenAaiHeaders() {
-
- // given
- Map<String, String> headers = HashMap.of("sample-key", "sample-value");
- AaiHttpGetClient cut = new AaiHttpGetClient(secureConfiguration(headers.toJavaMap()), httpClient);
-
- given(httpClient.call(any(HttpRequest.class)))
- .willReturn(Mono.just(response));
-
- // when
- StepVerifier
- .create(cut.getAaiResponse(aaiModel))
- .expectNext(response)
- .verifyComplete();
-
- //then
- verify(httpClient)
- .call(argThat(httpRequest -> httpRequest.customHeaders().equals(headers)));
- }
-
- @Test
- void getAaiResponse_shouldCallGetMethod_withProperUri() {
-
- // given
- AaiClientConfiguration configuration = secureConfiguration();
- String uri = constructAaiUri(configuration, aaiModel.getCorrelationId());
- AaiHttpGetClient cut = new AaiHttpGetClient(configuration, httpClient);
-
- given(httpClient.call(any(HttpRequest.class)))
- .willReturn(Mono.just(response));
-
- // when
- StepVerifier
- .create(cut.getAaiResponse(aaiModel))
- .expectNext(response)
- .verifyComplete();
-
- // then
- verify(httpClient)
- .call(argThat(httpRequest -> httpRequest.url().equals(uri)));
- }
-}
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpPatchClientTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpPatchClientTest.java
deleted file mode 100644
index de53d4d4..00000000
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiHttpPatchClientTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * DCAEGEN2-SERVICES-SDK
- * ================================================================================
- * Copyright (C) 2019 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.adapter.aai.api;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.verify;
-import static org.onap.dcaegen2.services.prh.adapter.aai.api.AaiClientConfigurations.secureConfiguration;
-
-import io.vavr.collection.HashMap;
-import io.vavr.collection.Map;
-import org.junit.jupiter.api.Test;
-import org.onap.dcaegen2.services.prh.adapter.aai.main.AaiClientConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpRequest;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-class AaiHttpPatchClientTest extends AbstractHttpClientTest {
-
- private final Map<String, String> DEFAULT_PATCH_HEADERS =
- HashMap.of("Content-Type", "application/merge-patch+json");
-
- @Test
- void getAaiResponse_shouldCallPatchMethod_withGivenHeaders_combinedWithContentType() {
-
- // given
- Map<String, String> headers = HashMap.of("sample-key", "sample-value");
- Map<String, String> expectedHeaders = DEFAULT_PATCH_HEADERS.merge(headers);
-
- AaiHttpPatchClient cut =
- new AaiHttpPatchClient(secureConfiguration(headers.toJavaMap()), bodyBuilder, httpClient);
-
- given(bodyBuilder.createJsonBody(eq(aaiModel)))
- .willReturn("test-body");
-
- given(httpClient.call(any(HttpRequest.class)))
- .willReturn(Mono.just(response));
-
- // when
- StepVerifier
- .create(cut.getAaiResponse(aaiModel))
- .expectNext(response)
- .verifyComplete();
-
- // then
- verify(httpClient)
- .call(argThat(httpRequest -> httpRequest.customHeaders().equals(expectedHeaders)));
- }
-
- @Test
- void getAaiResponse_shouldCallPatchMethod_withProperUri() {
-
- // given
- AaiClientConfiguration configuration = secureConfiguration();
- String uri = constructAaiUri(configuration, aaiModel.getCorrelationId());
- AaiHttpPatchClient cut = new AaiHttpPatchClient(configuration, bodyBuilder, httpClient);
-
- given(bodyBuilder.createJsonBody(eq(aaiModel)))
- .willReturn("test-body");
-
- given(httpClient.call(any(HttpRequest.class)))
- .willReturn(Mono.just(response));
-
- // when
- StepVerifier
- .create(cut.getAaiResponse(aaiModel))
- .expectNext(response)
- .verifyComplete();
-
- // then
- verify(httpClient)
- .call(argThat(httpRequest -> httpRequest.url().equals(uri)));
- }
-}
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiPnfResultModelTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiPnfResultModelTest.java
new file mode 100644
index 00000000..aa193e8a
--- /dev/null
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiPnfResultModelTest.java
@@ -0,0 +1,88 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PNF-REGISTRATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2019 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.adapter.aai.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.gson.Gson;
+import java.io.InputStreamReader;
+import java.util.Objects;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.prh.model.RelationshipData;
+import org.onap.dcaegen2.services.prh.model.RelationshipDict;
+import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder;
+
+class AaiPnfResultModelTest {
+
+ @Test
+ void shouldParseAaiPnf() {
+ Gson gson = PrhModelAwareGsonBuilder.createGson();
+ AaiPnfResultModel pnf = gson.fromJson(new InputStreamReader(Objects.requireNonNull(
+ ClassLoader.getSystemResourceAsStream("some_aai_pnf.json"))), AaiPnfResultModel.class);
+
+ assertThat(pnf.getPnfName()).isEqualTo("some pnfName");
+ assertThat(pnf.getPnfName2()).isEqualTo("some pnfName2");
+ assertThat(pnf.getSelflink()).isEqualTo("some selflink");
+ assertThat(pnf.getPnfName2Source()).isEqualTo("some pnfName2Source");
+ assertThat(pnf.getPnfId()).isEqualTo("some pnfId");
+ assertThat(pnf.getEquipType()).isEqualTo("some equipType");
+ assertThat(pnf.getEquipVendor()).isEqualTo("some equipVendor");
+ assertThat(pnf.getEquipModel()).isEqualTo("some equipModel");
+ assertThat(pnf.getManagementOption()).isEqualTo("some managementOption");
+ assertThat(pnf.getIpaddressV4Oam()).isEqualTo("some ipaddressV4Oam");
+ assertThat(pnf.getSwVersion()).isEqualTo("some swVersion");
+ assertThat(pnf.isInMaint()).isFalse();
+ assertThat(pnf.getFrameId()).isEqualTo("some frameId");
+ assertThat(pnf.getSerialNumber()).isEqualTo("some serialNumber");
+ assertThat(pnf.getIpaddressV4Loopback0()).isEqualTo("some ipaddressV4Loopback0");
+ assertThat(pnf.getIpaddressV6Loopback0()).isEqualTo("some ipaddressV6Loopback0");
+ assertThat(pnf.getIpaddressV4Aim()).isEqualTo("some ipaddressV4Aim");
+ assertThat(pnf.getIpaddressV6Aim()).isEqualTo("some ipaddressV6Aim");
+ assertThat(pnf.getIpaddressV6Oam()).isEqualTo("some ipaddressV6Oam");
+ assertThat(pnf.getInvStatus()).isEqualTo("some invStatus");
+ assertThat(pnf.getResourceVersion()).isEqualTo("some resourceVersion");
+ assertThat(pnf.getProvStatus()).isEqualTo("some provStatus");
+ assertThat(pnf.getNfRole()).isEqualTo("some nfRole");
+
+ assertThat(pnf.getRelationshipList().getRelationship()).hasSize(1);
+ RelationshipDict relationshipDict = pnf.getRelationshipList().getRelationship().get(0);
+ assertThat(relationshipDict.getRelatedTo()).isEqualTo("some relatedTo");
+ assertThat(relationshipDict.getRelationshipData()).hasSize(1);
+ RelationshipData relationshipData = relationshipDict.getRelationshipData().get(0);
+ assertThat(relationshipData.getRelationshipKey()).isEqualTo("some relationshipKey");
+ assertThat(relationshipData.getRelationshipValue()).isEqualTo("some relationshipValue");
+ }
+
+ @Test
+ void shouldProvideEmptyRelationshipListForEmptyJson() {
+ Gson gson = PrhModelAwareGsonBuilder.createGson();
+ AaiPnfResultModel pnf = gson.fromJson("{}", AaiPnfResultModel.class);
+ assertThat(pnf.getRelationshipList()).isNotNull();
+ assertThat(pnf.getRelationshipList().getRelationship()).isEmpty();
+ }
+
+ @Test
+ void shouldIgnoreUnexpectedFieldsInJson() {
+ Gson gson = PrhModelAwareGsonBuilder.createGson();
+ gson.fromJson("{\"foo\":\"bar\"}", AaiPnfResultModel.class);
+ }
+
+} \ No newline at end of file
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiServiceInstanceResultModelTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiServiceInstanceResultModelTest.java
new file mode 100644
index 00000000..278e8b53
--- /dev/null
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AaiServiceInstanceResultModelTest.java
@@ -0,0 +1,90 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PNF-REGISTRATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2019 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.adapter.aai.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.gson.Gson;
+import java.io.InputStreamReader;
+import java.util.Objects;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.prh.model.RelationshipData;
+import org.onap.dcaegen2.services.prh.model.RelationshipDict;
+import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder;
+
+class AaiServiceInstanceResultModelTest {
+
+ @Test
+ void shouldParseAaiServiceInstance() {
+ AaiServiceInstanceResultModel serviceInstance = PrhModelAwareGsonBuilder.createGson().fromJson(
+ new InputStreamReader(Objects.requireNonNull(
+ ClassLoader.getSystemResourceAsStream("some_aai_service_instance.json"))),
+ AaiServiceInstanceResultModel.class);
+
+ assertThat(serviceInstance.getServiceInstanceId()).isEqualTo("some serviceInstanceId");
+ assertThat(serviceInstance.getServiceInstanceName()).isEqualTo("some serviceInstanceName");
+ assertThat(serviceInstance.getServiceType()).isEqualTo("some serviceType");
+ assertThat(serviceInstance.getServiceRole()).isEqualTo("some serviceRole");
+ assertThat(serviceInstance.getEnvironmentContext()).isEqualTo("some environmentContext");
+ assertThat(serviceInstance.getWorkloadContext()).isEqualTo("some workloadContext");
+ assertThat(serviceInstance.getCreatedAt()).isEqualTo("some createdAt");
+ assertThat(serviceInstance.getUpdatedAt()).isEqualTo("some updatedAt");
+ assertThat(serviceInstance.getDescription()).isEqualTo("some description");
+ assertThat(serviceInstance.getModelInvariantId()).isEqualTo("some modelInvariantId");
+ assertThat(serviceInstance.getModelVersionId()).isEqualTo("some modelVersionId");
+ assertThat(serviceInstance.getPersonaModelVersion()).isEqualTo("some personaModelVersion");
+ assertThat(serviceInstance.getWidgetModelId()).isEqualTo("some widgetModelId");
+ assertThat(serviceInstance.getWidgetModelVersion()).isEqualTo("some widgetModelVersion");
+ assertThat(serviceInstance.getBandwidthTotal()).isEqualTo("some bandwidthTotal");
+ assertThat(serviceInstance.getBandwidthUpWan1()).isEqualTo("some bandwidthUpWan1");
+ assertThat(serviceInstance.getBandwidthDownWan1()).isEqualTo("some bandwidthDownWan1");
+ assertThat(serviceInstance.getBandwidthUpWan2()).isEqualTo("some bandwidthUpWan2");
+ assertThat(serviceInstance.getBandwidthDownWan2()).isEqualTo("some bandwidthDownWan2");
+ assertThat(serviceInstance.getVhnPortalUrl()).isEqualTo("some vhnPortalUrl");
+ assertThat(serviceInstance.getServiceInstanceLocationId()).isEqualTo("some serviceInstanceLocationId");
+ assertThat(serviceInstance.getResourceVersion()).isEqualTo("some resourceVersion");
+ assertThat(serviceInstance.getSelflink()).isEqualTo("some selflink");
+ assertThat(serviceInstance.getOrchestrationStatus()).isEqualTo("some orchestrationStatus");
+
+ RelationshipDict relationshipDict = serviceInstance.getRelationshipList().getRelationship().get(0);
+ assertThat(relationshipDict.getRelatedTo()).isEqualTo("some relatedTo");
+ assertThat(relationshipDict.getRelationshipData()).hasSize(1);
+ RelationshipData relationshipData = relationshipDict.getRelationshipData().get(0);
+ assertThat(relationshipData.getRelationshipKey()).isEqualTo("some relationshipKey");
+ assertThat(relationshipData.getRelationshipValue()).isEqualTo("some relationshipValue");
+ }
+
+
+ @Test
+ void shouldProvideEmptyRelationshipListForEmptyJson() {
+ Gson gson = PrhModelAwareGsonBuilder.createGson();
+ AaiServiceInstanceResultModel serviceInstance = gson.fromJson("{}", AaiServiceInstanceResultModel.class);
+ assertThat(serviceInstance.getRelationshipList()).isNotNull();
+ assertThat(serviceInstance.getRelationshipList().getRelationship()).isEmpty();
+ }
+
+ @Test
+ void shouldIgnoreUnexpectedFieldsInJson() {
+ Gson gson = PrhModelAwareGsonBuilder.createGson();
+ gson.fromJson("{\"foo\":\"bar\"}", AaiServiceInstanceResultModel.class);
+ }
+
+} \ No newline at end of file
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AbstractHttpClientTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AbstractHttpClientTest.java
deleted file mode 100644
index 1ccb8cbd..00000000
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/adapter/aai/api/AbstractHttpClientTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * DCAEGEN2-SERVICES-SDK
- * ================================================================================
- * Copyright (C) 2019 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.adapter.aai.api;
-
-import static org.mockito.Mockito.mock;
-
-import org.onap.dcaegen2.services.prh.adapter.aai.main.AaiClientConfiguration;
-import org.onap.dcaegen2.services.prh.model.AaiJsonBodyBuilderImpl;
-import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpResponse;
-import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.RxHttpClient;
-
-public class AbstractHttpClientTest {
-
- protected final ConsumerDmaapModel aaiModel = mock(ConsumerDmaapModel.class);
- protected final RxHttpClient httpClient = mock(RxHttpClient.class);
- protected final AaiJsonBodyBuilderImpl bodyBuilder = mock(AaiJsonBodyBuilderImpl.class);
- protected final HttpResponse response = mock(HttpResponse.class);
-
-
- protected String constructAaiUri(AaiClientConfiguration configuration, String pnfName) {
- return configuration.pnfUrl() + "/" + pnfName;
- }
-}