diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-10-06 17:50:28 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-10-06 18:55:05 +0300 |
commit | 72ee71bd853417415cba5926a73faae092ee83b5 (patch) | |
tree | 24b78f52773c113c544d7388f1740e1b79680a52 /vid-app-common/src/test | |
parent | fccae62442353fea229184159a56e7a49ad3638c (diff) |
Dont filter get_vnf_data_by_globalid_and_service_type_response results
Filtering happen on AAI as part of FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG.
Issue-ID: VID-659
Change-Id: If43034cce545c90ac44d6d0e70bc0baa3d21283b
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java | 31 | ||||
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/services/AaiServiceTest.java | 21 |
2 files changed, 13 insertions, 39 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java index 2eae1864f..9df99faa6 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java @@ -103,7 +103,6 @@ public class AaiServiceImplTest { private static final String SUBSCRIBER_ID = "SUBSCRIBER_ID_EXPECTED"; private static final String STATUS_TEXT = "STATUS_TEXT"; private static final String GLOBAL_SUBSCRIBER_ID = "GLOBAL_SUBSCRIBER_ID"; - private static final String GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE = "ID_NULL"; private static final String VNF_INSTANCE_ID_OK = "VNF_INSTANCE_ID_OK"; private static final String VNF_INSTANCE_ID_FAIL = "VNF_INSTANCE_ID_FAIL"; private static final String PARENT_NAME = "PARENT_NAME"; @@ -277,7 +276,7 @@ public class AaiServiceImplTest { } @Test - public void shouldGetVNFDataWithoutFiltering() { + public void shouldGetVNFDataOfInstanceWithoutFiltering() { when(aaiClient.getVNFData(anyString(), anyString(), anyString())).thenReturn(aaiResponse); AaiResponse actualResponse = aaiService.getVNFData(anyString(), anyString(), anyString()); @@ -286,30 +285,26 @@ public class AaiServiceImplTest { } @Test - public void shouldGetVNFDataWithFiltering() { + public void shouldGetVNFDataOfServiceWithoutFiltering() { VnfResult vnfResult1 = createVnfResult("ID1", "generic-vnf"); VnfResult vnfResult2 = createVnfResult("ID2", "service-instance"); VnfResult vnfResult3 = createVnfResult("ID3", "anything-else"); - List<VnfResult> vnfResults = Arrays.asList(vnfResult1, vnfResult2, vnfResult3); - AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse(vnfResults); - - vnfResults = Arrays.asList(vnfResult1, vnfResult2); - AaiResponse<AaiGetVnfResponse> expectedResponseWithReturnedVnfs = createAaiResponseVnfResponse(vnfResults); - AaiResponse expectedResponseWithoutReturnedVnfs = new AaiResponse(); + AaiResponse<AaiGetVnfResponse> aaiResponseGetVnfResponse = createAaiResponseVnfResponse( + Arrays.asList(vnfResult1, vnfResult2, vnfResult3)); when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(aaiResponseGetVnfResponse); - when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE)).thenReturn(null); - AaiResponse<AaiGetVnfResponse> actualResponseWithReturnedVnfs = - aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE); - AaiResponse<AaiGetVnfResponse> actualResponseWithoutReturnedVnfs = - aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID_NULL_RESPONSE, SERVICE_TYPE); + assertThat(aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)) + .isEqualTo(aaiResponseGetVnfResponse); + } + + @Test + public void shouldGetNonNullVNFDataOfServiceWhenNoResult() { + when(aaiClient.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)).thenReturn(null); - assertThat(actualResponseWithReturnedVnfs) - .isEqualToComparingFieldByFieldRecursively(expectedResponseWithReturnedVnfs); - assertThat(actualResponseWithoutReturnedVnfs) - .isEqualToComparingFieldByField(expectedResponseWithoutReturnedVnfs); + assertThat(aaiService.getVNFData(GLOBAL_SUBSCRIBER_ID, SERVICE_TYPE)) + .isEqualToComparingFieldByField(new AaiResponse()); } @Test 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 92a55f0b8..6aa67051e 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 @@ -22,7 +22,6 @@ package org.onap.vid.services; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayWithSize; -import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -33,14 +32,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.vid.aai.AaiClientInterface; -import org.onap.vid.aai.AaiGetVnfResponse; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.model.AaiGetPnfResponse; import org.onap.vid.aai.model.AaiGetPnfs.Pnf; @@ -50,7 +46,6 @@ 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.aai.model.VnfResult; import org.onap.vid.model.aaiTree.AAITreeNode; import org.onap.vid.roles.Role; import org.onap.vid.roles.RoleValidator; @@ -211,20 +206,4 @@ public class AaiServiceTest { assertThat(anyMatch, equalTo(expectedMatch)); } - @Test - public void testFilterChangeManagementVNFCandidatesResponse() { - AaiGetVnfResponse aaiGetVnfResponse = new AaiGetVnfResponse(); - aaiGetVnfResponse.results = new ArrayList<>(); - Stream.of("genEric-vNf", "l3-interface-ipv6-address-list", "vserver", "pserver", "serviCe-inStance").forEach( - nodeType->{ - VnfResult vnfResult = new VnfResult(); - vnfResult.nodeType=nodeType; - aaiGetVnfResponse.results.add(vnfResult); - } - ); - - AaiResponse<AaiGetVnfResponse> result = aaiService.filterChangeManagementVNFCandidatesResponse(new AaiResponse<>(aaiGetVnfResponse, "", 200)); - assertEquals(2, result.getT().results.size()); - assertThat(result.getT().results.stream().map(x->x.nodeType).collect(Collectors.toList()), containsInAnyOrder("genEric-vNf","serviCe-inStance")); - } } |