aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java29
-rw-r--r--vid-app-common/src/test/resources/responses/aai/listServicesByOwningEntity.json97
-rw-r--r--vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java10
6 files changed, 135 insertions, 8 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
index be77e2bc0..1baca9ffa 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClient.java
@@ -143,7 +143,7 @@ public class AaiClient implements AaiClientInterface {
}
@Override
- public AaiResponse getServicesByOwningEntityId(List<String> owningEntityIds){
+ public AaiResponse<OwningEntityResponse> getServicesByOwningEntityId(List<String> owningEntityIds){
Response resp = doAaiGet(getUrlFromLIst("business/owning-entities?", "owning-entity-id=", owningEntityIds), false);
return processAaiResponse(resp, OwningEntityResponse.class, null);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
index 5b36828c6..b39b80943 100644
--- a/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/aai/AaiClientInterface.java
@@ -29,6 +29,7 @@ import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironme
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
import org.onap.vid.aai.model.ModelVer;
+import org.onap.vid.aai.model.OwningEntityResponse;
import org.onap.vid.aai.model.PortDetailsTranslator;
import org.onap.vid.aai.model.Properties;
import org.onap.vid.aai.model.ResourceType;
@@ -53,7 +54,7 @@ public interface AaiClientInterface extends ProbeInterface {
AaiResponse getServices();
- AaiResponse getServicesByOwningEntityId(List<String> owningEntityIds);
+ AaiResponse<OwningEntityResponse> getServicesByOwningEntityId(List<String> owningEntityIds);
AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
index 9db8233a7..a992519cf 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java
@@ -173,7 +173,7 @@ public class AaiServiceImpl implements AaiService {
}
}
- private List<ServiceInstanceSearchResult> getServicesByOwningEntityId(List<String> owningEntities, RoleValidator roleValidator) {
+ List<ServiceInstanceSearchResult> getServicesByOwningEntityId(List<String> owningEntities, RoleValidator roleValidator) {
AaiResponse<OwningEntityResponse> owningEntityResponse = aaiClient.getServicesByOwningEntityId(owningEntities);
List<ServiceInstanceSearchResult> serviceInstanceSearchResultList = new ArrayList<>();
if (owningEntityResponse.getT() != null) {
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java
index 12774f431..663d86255 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java
@@ -20,11 +20,14 @@
package org.onap.vid.services;
+import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
+import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -34,6 +37,7 @@ import static org.testng.Assert.assertNotNull;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Arrays;
@@ -50,13 +54,17 @@ import org.onap.vid.aai.model.AaiGetPnfResponse;
import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
import org.onap.vid.aai.model.LogicalLinkResponse;
+import org.onap.vid.aai.model.OwningEntityResponse;
import org.onap.vid.aai.model.Relationship;
import org.onap.vid.aai.model.RelationshipData;
import org.onap.vid.aai.model.RelationshipList;
import org.onap.vid.aai.model.ServiceRelationships;
+import org.onap.vid.model.ServiceInstanceSearchResult;
import org.onap.vid.model.aaiTree.AAITreeNode;
import org.onap.vid.roles.RoleValidator;
import org.onap.vid.roles.RoleValidatorFactory;
+import org.onap.vid.roles.WithPermissionProperties;
+import org.onap.vid.testUtils.TestUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -276,4 +284,25 @@ public class AaiServiceTest {
}
}
+ @Test
+ public void testGetServicesByOwningEntityId() {
+ List<String> owningEntityIds = ImmutableList.of("43b8a85a-0421-4265-9069-117dd6526b8a", "26dcc4aa-725a-447d-8346-aa26dfaa4eb7");
+ RoleValidator roleValidator = mock(RoleValidator.class);
+
+ OwningEntityResponse owningEntityResponse = TestUtils.readJsonResourceFileAsObject("/responses/aai/listServicesByOwningEntity.json", OwningEntityResponse.class);
+ when(roleValidator.isServicePermitted(any(WithPermissionProperties.class))).thenReturn(true);
+ when(aaiClientInterface.getServicesByOwningEntityId(owningEntityIds)).thenReturn(new AaiResponse<>(owningEntityResponse, "", 200));
+ List<ServiceInstanceSearchResult> result = aaiService.getServicesByOwningEntityId(owningEntityIds, roleValidator);
+
+
+ ServiceInstanceSearchResult expected1 = new ServiceInstanceSearchResult(
+ "af9d52f9-13b2-4657-a198-463677f82dc0", "256cddb4-3aa1-43cc-a08f-315bb50b275e", "MSO-dev-service-type", "xbghrftgr_shani", null, null, null, null, true);
+ ServiceInstanceSearchResult expected2 = new ServiceInstanceSearchResult(
+ "49769492-5def-4c89-8e73-b236f958fa40", "e02fd6f2-7fc2-434b-a92d-15abdb24b68d", "JUST-another-service-type", "fghghfhgf", null, null, null, null, true);
+ ServiceInstanceSearchResult expected3 = new ServiceInstanceSearchResult(
+ "1d8fd482-2f53-4d62-a7bd-20e4bab14c45", "256cddb4-3aa1-43cc-a08f-315bb50b275e", "MSO-dev-service-type", "Bryant", null, null, null, null, true);
+
+ assertThat(result, jsonEquals(ImmutableList.of(expected1, expected2, expected3)).when(IGNORING_ARRAY_ORDER).whenIgnoringPaths("[*].subscriberName")); //ignore in array
+ }
+
}
diff --git a/vid-app-common/src/test/resources/responses/aai/listServicesByOwningEntity.json b/vid-app-common/src/test/resources/responses/aai/listServicesByOwningEntity.json
new file mode 100644
index 000000000..a97a74a06
--- /dev/null
+++ b/vid-app-common/src/test/resources/responses/aai/listServicesByOwningEntity.json
@@ -0,0 +1,97 @@
+{
+ "owning-entity": [
+ {
+ "owning-entity-id": "43b8a85a-0421-4265-9069-117dd6526b8a",
+ "owning-entity-name": "Melissa",
+ "resource-version": "1527418700853",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v12/business/customers/customer/256cddb4-3aa1-43cc-a08f-315bb50b275e/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/af9d52f9-13b2-4657-a198-463677f82dc0",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "256cddb4-3aa1-43cc-a08f-315bb50b275e"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "MSO-dev-service-type"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "af9d52f9-13b2-4657-a198-463677f82dc0"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "xbghrftgr_shani"
+ }
+ ]
+ },
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v12/business/customers/customer/e02fd6f2-7fc2-434b-a92d-15abdb24b68d/service-subscriptions/service-subscription/JUST-another-service-type/service-instances/service-instance/49769492-5def-4c89-8e73-b236f958fa40",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "e02fd6f2-7fc2-434b-a92d-15abdb24b68d"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "JUST-another-service-type"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "49769492-5def-4c89-8e73-b236f958fa40"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "fghghfhgf"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "owning-entity-id": "26dcc4aa-725a-447d-8346-aa26dfaa4eb7",
+ "owning-entity-name": "Kobe",
+ "resource-version": "1527418700844",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.BelongsTo",
+ "related-link": "/aai/v12/business/customers/customer/256cddb4-3aa1-43cc-a08f-315bb50b275e/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/1d8fd482-2f53-4d62-a7bd-20e4bab14c45",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "256cddb4-3aa1-43cc-a08f-315bb50b275e"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "MSO-dev-service-type"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "1d8fd482-2f53-4d62-a7bd-20e4bab14c45"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "Bryant"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java b/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java
index b1d31f8e2..abeffca4f 100644
--- a/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java
+++ b/vid-automation/src/main/java/vid/automation/test/test/SearchExistingInstanceTest.java
@@ -1,7 +1,10 @@
package vid.automation.test.test;
-import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import vid.automation.test.Constants;
@@ -12,9 +15,6 @@ import vid.automation.test.sections.SideMenu;
import vid.automation.test.services.BulkRegistration;
import vid.automation.test.services.SimulatorApi;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
public class SearchExistingInstanceTest extends VidBaseTestCase {
public static final String serviceIdOeWirelineProjectX1 = "7e4f8130-5dee-47c4-8770-1abc5f5ded83";
@@ -27,7 +27,7 @@ public class SearchExistingInstanceTest extends VidBaseTestCase {
}
@Test
- private void testSearchExistingInstanceByOwningEntitySingleValue() {
+ public void testSearchExistingInstanceByOwningEntitySingleValue() {
SearchExistingPage searchExistingPage = new SearchExistingPage();
SideMenu.navigateToSearchExistingPage();
searchExistingPage.searchByOwningEntity("Melissa");