From 9e73da42126982f247a0c64882ac8958e504ca24 Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Tue, 4 Feb 2020 23:34:13 +0200 Subject: add owningEntityId to each result of getServicesByOwningEntityId Issue-ID: VID-758 Signed-off-by: Eylon Malin Change-Id: I4546b5d86e6a1b929b3430aa41f13980f07cfdaf --- .../src/main/java/org/onap/vid/services/AaiServiceImpl.java | 12 +++++++----- .../src/test/java/org/onap/vid/services/AaiServiceTest.java | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'vid-app-common') 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 a73d690da..36333b163 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 @@ -179,7 +179,7 @@ public class AaiServiceImpl implements AaiService { if (owningEntityResponse.getT() != null) { for (OwningEntity owningEntity : owningEntityResponse.getT().getOwningEntity()) { if (owningEntity.getRelationshipList() != null) { - serviceInstanceSearchResultList = convertRelationshipToSearchResult(owningEntity, serviceInstanceSearchResultList, roleValidator); + serviceInstanceSearchResultList.addAll(convertRelationshipToSearchResult(owningEntity, roleValidator, owningEntity.getOwningEntityId())); } } } @@ -192,20 +192,22 @@ public class AaiServiceImpl implements AaiService { if (projectByIdResponse.getT() != null) { for (Project project : projectByIdResponse.getT().getProject()) { if (project.getRelationshipList() != null) { - serviceInstanceSearchResultList = convertRelationshipToSearchResult(project, serviceInstanceSearchResultList, roleValidator); + serviceInstanceSearchResultList.addAll(convertRelationshipToSearchResult(project, roleValidator, null)); } } } return serviceInstanceSearchResultList; } - private List convertRelationshipToSearchResult(AaiRelationResponse owningEntityResponse, List serviceInstanceSearchResultList, RoleValidator roleValidator) { - if (owningEntityResponse.getRelationshipList().getRelationship() != null) { - List relationshipList = owningEntityResponse.getRelationshipList().getRelationship(); + private List convertRelationshipToSearchResult(AaiRelationResponse aaiRelationResponse, RoleValidator roleValidator, String owningEntityId) { + List serviceInstanceSearchResultList = new ArrayList<>(); + if (aaiRelationResponse.getRelationshipList().getRelationship() != null) { + List relationshipList = aaiRelationResponse.getRelationshipList().getRelationship(); for (Relationship relationship : relationshipList) { ServiceInstanceSearchResult serviceInstanceSearchResult = new ServiceInstanceSearchResult(); extractRelationshipData(relationship, serviceInstanceSearchResult, roleValidator); extractRelatedToProperty(relationship, serviceInstanceSearchResult); + serviceInstanceSearchResult.setOwningEntityId(owningEntityId); serviceInstanceSearchResultList.add(serviceInstanceSearchResult); } } 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 90261746e..4d6566f5b 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 @@ -300,11 +300,11 @@ public class AaiServiceTest { //then 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); + "af9d52f9-13b2-4657-a198-463677f82dc0", "256cddb4-3aa1-43cc-a08f-315bb50b275e", "MSO-dev-service-type", "xbghrftgr_shani", null, null, null, "43b8a85a-0421-4265-9069-117dd6526b8a", 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); + "49769492-5def-4c89-8e73-b236f958fa40", "e02fd6f2-7fc2-434b-a92d-15abdb24b68d", "JUST-another-service-type", "fghghfhgf", null, null, null, "43b8a85a-0421-4265-9069-117dd6526b8a", 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); + "1d8fd482-2f53-4d62-a7bd-20e4bab14c45", "256cddb4-3aa1-43cc-a08f-315bb50b275e", "MSO-dev-service-type", "Bryant", null, null, null, "26dcc4aa-725a-447d-8346-aa26dfaa4eb7", true); assertThat(result, jsonEquals(ImmutableList.of(expected1, expected2, expected3)).when(IGNORING_ARRAY_ORDER).whenIgnoringPaths("[*].subscriberName")); //ignore in array } -- cgit 1.2.3-korg