summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
authormichal.banka <michal.banka@nokia.com>2019-06-05 08:30:59 +0200
committermichal.banka <michal.banka@nokia.com>2019-06-10 10:51:12 +0200
commitf0ab6c540529dadd0318bb2eb9c012d0c3dcea16 (patch)
tree645d782126a1182b2a1b85b93ef4f4f341cce871 /vid-app-common/src
parentdd3ba9800ec14898f50858ecd67db0f9245ffc01 (diff)
Rewrite tests for AaiServiceImpl
Issue-ID: VID-386 Change-Id: I3cbcdada18f2813bc8a4cf442f54df297f5ec945 Signed-off-by: michal.banka <michal.banka@nokia.com>
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/AaiServiceImpl.java18
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java996
2 files changed, 761 insertions, 253 deletions
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 83832bfd0..d01f0f7ad 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
@@ -88,17 +88,13 @@ public class AaiServiceImpl implements AaiService {
private List<Service> convertModelToService(Model model) {
List<Service> services = new ArrayList<>();
- String category = "";
if(validateModel(model)){
- if(model.getModelType() != null) {
- category = model.getModelType();
- }
-
for (ModelVer modelVer: model.getModelVers().getModelVer()) {
- Service service = new Service.ServiceBuilder().setUuid(modelVer.getModelVersionId())
+ Service service = new Service.ServiceBuilder()
+ .setUuid(modelVer.getModelVersionId())
.setInvariantUUID(model.getModelInvariantId())
- .setCategory(category)
+ .setCategory(model.getModelType() != null ? model.getModelType() : "")
.setVersion(modelVer.getModelVersion())
.setName( modelVer.getModelName())
.setDistributionStatus(modelVer.getDistributionStatus())
@@ -357,7 +353,7 @@ public class AaiServiceImpl implements AaiService {
@Override
public AaiResponse<AaiGetVnfResponse> getVNFData(String globalSubscriberId, String serviceType) {
- AaiResponse response = aaiClient.getVNFData(globalSubscriberId, serviceType);
+ AaiResponse<AaiGetVnfResponse> response = aaiClient.getVNFData(globalSubscriberId, serviceType);
return filterChangeManagementVNFCandidatesResponse(response);
}
@@ -375,7 +371,7 @@ public class AaiServiceImpl implements AaiService {
return response;
}
- return new AaiResponse();
+ return new AaiResponse<>();
}
@Override
@@ -474,9 +470,9 @@ public class AaiServiceImpl implements AaiService {
public AaiResponse getInstanceGroupsByVnfInstanceId(String vnfInstanceId){
AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> aaiResponse = aaiClient.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
if(aaiResponse.getHttpCode() == HttpStatus.SC_OK){
- return new AaiResponse(convertGetInstanceGroupsResponseToSimpleResponse(aaiResponse.getT()), aaiResponse.getErrorMessage(), aaiResponse.getHttpCode());
+ return new AaiResponse<>(convertGetInstanceGroupsResponseToSimpleResponse(aaiResponse.getT()), aaiResponse.getErrorMessage(), aaiResponse.getHttpCode());
}
- return aaiClient.getInstanceGroupsByVnfInstanceId(vnfInstanceId);
+ return aaiResponse;
}
@Override
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 e9f94ca0e..068cc0053 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
@@ -21,258 +21,770 @@
package org.onap.vid.services;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import javax.ws.rs.core.Response;
-import org.jeasy.random.EasyRandom;
-import org.jeasy.random.EasyRandomParameters;
-import org.jeasy.random.randomizers.misc.BooleanRandomizer;
-import org.jeasy.random.randomizers.text.StringRandomizer;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.joshworks.restclient.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.jetbrains.annotations.NotNull;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.vid.aai.AaiClientInterface;
import org.onap.vid.aai.AaiGetVnfResponse;
import org.onap.vid.aai.AaiOverTLSClientInterface;
import org.onap.vid.aai.AaiResponse;
import org.onap.vid.aai.AaiResponseTranslator;
+import org.onap.vid.aai.ServiceInstancesSearchResults;
+import org.onap.vid.aai.ServiceSubscription;
+import org.onap.vid.aai.ServiceSubscriptions;
+import org.onap.vid.aai.Services;
+import org.onap.vid.aai.SubscriberFilteredResults;
+import org.onap.vid.aai.model.AaiGetInstanceGroupsByCloudRegion;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.AaiGetRelatedInstanceGroupsByVnfId;
+import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelatedToProperty;
+import org.onap.vid.aai.model.AaiGetOperationalEnvironments.OperationalEnvironmentList;
+import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
import org.onap.vid.aai.model.AaiGetServicesRequestModel.GetServicesAAIRespone;
import org.onap.vid.aai.model.AaiGetTenatns.GetTenantsResponse;
+import org.onap.vid.aai.model.GetServiceModelsByDistributionStatusResponse;
+import org.onap.vid.aai.model.InstanceGroupInfo;
+import org.onap.vid.aai.model.LogicalLinkResponse;
+import org.onap.vid.aai.model.Model;
+import org.onap.vid.aai.model.ModelVer;
+import org.onap.vid.aai.model.ModelVers;
+import org.onap.vid.aai.model.PortDetailsTranslator;
+import org.onap.vid.aai.model.Properties;
+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.Result;
+import org.onap.vid.aai.model.ServiceRelationships;
import org.onap.vid.aai.model.VnfResult;
+import org.onap.vid.asdc.beans.Service;
+import org.onap.vid.model.Subscriber;
+import org.onap.vid.model.SubscriberList;
+import org.onap.vid.model.aaiTree.AAITreeNode;
+import org.onap.vid.model.aaiTree.RelatedVnf;
+import org.onap.vid.model.aaiTree.ServiceInstance;
import org.onap.vid.roles.RoleValidator;
-import org.onap.vid.roles.RoleValidatorByRoles;
+import javax.ws.rs.core.Response;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
public class AaiServiceImplTest {
- private static final long STATIC_SEED = 5336L;
- private EasyRandomParameters parameters = new EasyRandomParameters()
- .randomize(String.class, new StringRandomizer(4, 4, STATIC_SEED))
- .randomize(Boolean.class, new BooleanRandomizer(STATIC_SEED));
- private EasyRandom modelGenerator = new EasyRandom(parameters);
-
- private AaiClientInterface aaiClient = mock(AaiClientInterface.class);
- private AaiOverTLSClientInterface aaiSslClient = mock(AaiOverTLSClientInterface.class);
- private AaiResponseTranslator aaiResponseTranslator = mock(AaiResponseTranslator.class);
- private AAITreeNodeBuilder aaiTreeNode = mock(AAITreeNodeBuilder.class);
- private AAIServiceTree aaiServiceTree = mock(AAIServiceTree.class);
-
- private AaiServiceImpl aaiService = new AaiServiceImpl(
- aaiClient, aaiSslClient, aaiResponseTranslator, aaiTreeNode, aaiServiceTree
- );
-
- @Test
- public void shouldRetrievePnf() {
- // given
- String globalCustomerId = "global_customer";
- String serviceType = "service_type";
- String modelVersionId = "model_version";
- String modelInvariantId = "model_invariant_id";
- String cloudRegion = "cloud_region";
- String equipVendor = "equip_vendor";
- String equipModel = "equip_model";
-
- AaiResponse response = mock(AaiResponse.class);
- when(aaiClient.getPNFData(
- globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel
- )).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getPNFData(
- globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor, equipModel
- );
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldRetrieveSpecificPnf() {
- // given
- String pnfId = "some_pnf_id";
-
- AaiResponse response = mock(AaiResponse.class);
- when(aaiClient.getSpecificPnf(pnfId)).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getSpecificPnf(pnfId);
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- public void shouldRetrieveTenantsByInvariantId() {
- // given
- List<String> modelInvariantId = new ArrayList<>();
-
- Response response = mock(Response.class);
- when(aaiClient.getVersionByInvariantId(modelInvariantId)).thenReturn(response);
-
- // when
- Response actual = aaiService.getVersionByInvariantId(modelInvariantId);
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldRetrieveTenants() {
- // given
- String globalCustomerId = "global_customer";
- String serviceType = "service_type";
-
- GetTenantsResponse permittedTenant = new GetTenantsResponse(
- "cloud_region", "cloud_owner", "permitted_tenant", "tenant_id", false
- );
- GetTenantsResponse unpermittedTenant = new GetTenantsResponse(
- "cloud_region", "cloud_owner", "unpermitted_tenant", "tenant_id", false
- );
-
- AaiResponse<GetTenantsResponse[]> response = mock(AaiResponse.class);
- when(response.getT()).thenReturn(new GetTenantsResponse[]{ permittedTenant, unpermittedTenant });
- when(aaiClient.getTenants(globalCustomerId, serviceType)).thenReturn(response);
-
- RoleValidator roleValidator = mock(RoleValidatorByRoles.class);
- when(roleValidator.isTenantPermitted(globalCustomerId, serviceType, "permitted_tenant")).thenReturn(true);
- when(roleValidator.isTenantPermitted(globalCustomerId, serviceType, "unpermitted_tenant")).thenReturn(false);
-
- // when
- AaiResponse actual = aaiService.getTenants(globalCustomerId, serviceType, roleValidator);
-
- // then
- assertThat(response).isEqualTo(actual);
- assertThat(permittedTenant.isPermitted).isTrue();
- assertThat(unpermittedTenant.isPermitted).isFalse();
- }
-
- @Test
- public void shouldRetrieveVNFs() {
- // given
- String globalSubscriber = "global_subscriber";
- String serviceType = "service_type";
- String serviceInstanceId = "service_instance";
-
- AaiResponse response = mock(AaiResponse.class);
- when(aaiClient.getVNFData(globalSubscriber, serviceType, serviceInstanceId)).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getVNFData(globalSubscriber, serviceType, serviceInstanceId);
-
- // then
- assertThat(response).isEqualTo(actual);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void shouldRetrieveAndFilterVNFsBySubscriberAndServiceType() {
- // given
- String globalSubscriber = "global_subscriber";
- String serviceType = "service_type";
-
- VnfResult genericVnf = new VnfResult();
- genericVnf.nodeType = "generic-vnf";
-
- VnfResult serviceInstance = new VnfResult();
- serviceInstance.nodeType = "service-instance";
-
- VnfResult someVnf = new VnfResult();
- someVnf.nodeType = "some-vnf";
-
- AaiResponse<AaiGetVnfResponse> response = mock(AaiResponse.class);
- AaiGetVnfResponse vnfs = new AaiGetVnfResponse();
- vnfs.results = Arrays.asList(genericVnf, serviceInstance, someVnf);
- when(response.getT()).thenReturn(vnfs);
-
- when(aaiClient.getVNFData(globalSubscriber, serviceType)).thenReturn(response);
-
- // when
- AaiResponse actual = aaiService.getVNFData(globalSubscriber, serviceType);
-
- // then
- assertThat(response).isEqualTo(actual);
- assertThat(response.getT().results).containsOnly(genericVnf, serviceInstance);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void getServicesShouldMarkAllServicesAsPermitted() {
- // given
- RoleValidator roleValidator = modelGenerator.nextObject(RoleValidatorByRoles.class);
-
- GetServicesAAIRespone inputPayload = modelGenerator.nextObject(GetServicesAAIRespone.class);
- assertThat(inputPayload.service.stream().allMatch(service -> service.isPermitted)).isFalse();
-
- when(aaiClient.getServices()).thenReturn(new AaiResponse<>(inputPayload, "", 200));
-
- // when
- AaiResponse<GetServicesAAIRespone> result = aaiService.getServices(roleValidator);
- GetServicesAAIRespone outputPayload = result.getT();
-
- // then
- assertThat(outputPayload.service.stream().allMatch(service -> service.isPermitted)).isTrue();
- }
-
- @Test
- public void shouldGetNodeTemplateInstances() {
- // given
- String globalCustomerId = "gcid";
- String serviceType = "st";
- String modelVersionId = "mvid";
- String modelInvariantId = "miid";
- String cloudRegion = "cr";
-
- // when
- aaiService
- .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
-
- // then
- verify(aaiClient)
- .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion);
- }
-
- @Test
- public void shouldGetNetworkCollectionDetails() {
- // given
- String serviceInstanceId = "siid";
-
- // when
- aaiService.getNetworkCollectionDetails(serviceInstanceId);
-
- // then
- verify(aaiClient).getNetworkCollectionDetails(serviceInstanceId);
- }
-
- @Test
- public void shouldGetInstanceGroupsByCloudRegion() {
- // given
- String cloudOwner = "co";
- String cloudRegionId = "crid";
- String networkFunction = "nf";
-
- // when
- aaiService.getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
-
- // then
- verify(aaiClient).getInstanceGroupsByCloudRegion(cloudOwner, cloudRegionId, networkFunction);
- }
-
- @Test
- public void getAAIServiceTree() {
- // given
- String globalCustomerId = "gcid";
- String serviceType = "st";
- String serviceInstanceId = "siid";
-
- // when
- aaiService.getAAIServiceTree(globalCustomerId, serviceType, serviceInstanceId);
-
- // then
- verify(aaiServiceTree).getServiceInstanceTopology(globalCustomerId, serviceType, serviceInstanceId);
- }
-} \ No newline at end of file
+ private static final String GLOBAL_CUSTOMER_ID = "GLOBAL_CUSTOMER_ID";
+ private static final String CLOUD_REGION_ID = "CLOUD_REGION_ID";
+ private static final String VNF_TYPE = "VNF_TYPE";
+ private static final String TENANT_ID = "TENANT_ID";
+ private static final String TENANT_NAME = "TENANT_NAME";
+ private static final String SERVICE_TYPE = "SERVICE_TYPE";
+ private static final String CORRECT_VALUE = "CORRECT_VALUE";
+ 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";
+ private static final String PARENT_ID = "PARENT_ID";
+ private static final String INVARIANT_ID = "INVARIANT_ID";
+ private static final String GROUP_TYPE_FAILING = "GROUP_TYPE_FAILING";
+ private static final String GROUP_ROLE_OK = "GROUP_ROLE_OK";
+ private static final String GROUP_ROLE_FAILING = "GROUP_ROLE_FAILING";
+ private static final String group_type_ok = "GROUP_TYPE_OK";
+ private static final String CLOUD_TYPE = "CLOUD_TYPE";
+
+ @Mock
+ private HttpResponse<SubscriberList> responseAllSubscribers;
+ @Mock
+ private AaiResponse<OperationalEnvironmentList> aaiResponseOpEnvList;
+ @Mock
+ private AaiResponse aaiResponse;
+ @Mock
+ private AaiResponse<JsonNode> aaiResponseJsonNode;
+ @Mock
+ private RoleValidator roleValidator;
+
+ @Mock
+ private AaiClientInterface aaiClient;
+ @Mock
+ private AaiOverTLSClientInterface aaiOverTLSClient;
+ @Mock
+ private AaiResponseTranslator aaiResponseTranslator;
+ @Mock
+ private AAIServiceTree aaiServiceTree;
+
+ @InjectMocks
+ private AaiServiceImpl aaiService;
+
+
+ @Test
+ public void shouldGetFullSubscriberListWithoutValidator() {
+ when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
+
+ HttpResponse<SubscriberList> actualResponse = aaiService.getFullSubscriberList();
+
+ assertThat(actualResponse).isEqualTo(responseAllSubscribers);
+ }
+
+ @Test
+ public void shouldGetFullSubscriberListWithValidator() {
+ Subscriber subscriber = createSubscriber();
+ SubscriberList subscriberList = new SubscriberList(Collections.singletonList(subscriber));
+
+ when(aaiOverTLSClient.getAllSubscribers()).thenReturn(responseAllSubscribers);
+ when(responseAllSubscribers.getBody()).thenReturn(subscriberList);
+ when(responseAllSubscribers.getStatusText()).thenReturn(STATUS_TEXT);
+ when(responseAllSubscribers.getStatus()).thenReturn(HttpStatus.SC_OK);
+ SubscriberFilteredResults expectedSubscribers = new SubscriberFilteredResults(roleValidator, subscriberList,
+ STATUS_TEXT, HttpStatus.SC_OK);
+
+ SubscriberFilteredResults actualSubscribers = aaiService.getFullSubscriberList(roleValidator);
+
+ assertThat(actualSubscribers.getHttpCode()).isEqualTo(expectedSubscribers.getHttpCode());
+ assertThat(actualSubscribers.getErrorMessage()).isEqualTo(expectedSubscribers.getErrorMessage());
+ }
+
+ @Test
+ public void shouldGetOperationalEnvironments() {
+ when(aaiClient.getOperationalEnvironments(anyString(), anyString()))
+ .thenReturn(aaiResponseOpEnvList);
+
+ AaiResponse<OperationalEnvironmentList> expectedEnvList =
+ aaiService.getOperationalEnvironments(anyString(), anyString());
+
+ assertThat(expectedEnvList).isEqualTo(aaiResponseOpEnvList);
+ }
+
+ @Test
+ public void shouldGetSubscriberData() {
+ Services services = createAaiResponseServices();
+ AaiResponse<Services> aaiResponseServices = new AaiResponse<>(services, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getSubscriberData(SUBSCRIBER_ID)).thenReturn(aaiResponseServices);
+ when(roleValidator.isServicePermitted(eq(GLOBAL_CUSTOMER_ID), anyString())).thenReturn(Boolean.TRUE);
+
+ AaiResponse actualResponse = aaiService.getSubscriberData(SUBSCRIBER_ID, roleValidator);
+ List<ServiceSubscription> actualServiceSubscriptions = ((AaiResponse<Services>) actualResponse)
+ .getT().serviceSubscriptions.serviceSubscription;
+
+ assertThat(actualResponse).isEqualTo(aaiResponseServices);
+ assertThat(actualServiceSubscriptions).allMatch(s -> s.isPermitted);
+ }
+
+ @Test
+ public void shouldGetServiceInstanceEmptySearchResults() {
+ ServiceInstancesSearchResults serviceInstancesSearchResults = new ServiceInstancesSearchResults();
+ AaiResponse<ServiceInstancesSearchResults> emptyResponse = new AaiResponse<>(serviceInstancesSearchResults,
+ null, HttpStatus.SC_OK);
+
+ AaiResponse actualResponse = aaiService.getServiceInstanceSearchResults(null, null,
+ null, null, null);
+
+ assertThat(actualResponse).isEqualToComparingFieldByFieldRecursively(emptyResponse);
+ }
+
+ @Test
+ public void shouldGetVersionByInvariantId() {
+ Response response = mock(Response.class);
+ when(aaiClient.getVersionByInvariantId(any())).thenReturn(response);
+
+ Response actualResponse = aaiService.getVersionByInvariantId(any());
+
+ assertThat(actualResponse).isEqualTo(response);
+ }
+
+ @Test
+ public void shouldGetSpecificPnf() {
+ AaiResponse<Pnf> expectedResponse = new AaiResponse<>(new Pnf(), null, HttpStatus.SC_OK);
+ when(aaiClient.getSpecificPnf(anyString())).thenReturn(expectedResponse);
+
+ AaiResponse<Pnf> actualResponse = aaiService.getSpecificPnf(anyString());
+
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetPnfData() {
+ when(aaiClient.getPNFData(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(),
+ anyString())).thenReturn(aaiResponse);
+
+ AaiResponse actualResponse = aaiService.getPNFData(anyString(), anyString(), anyString(), anyString(),
+ anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetServices() {
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s1 =
+ createService("ID1", "V1", "D1");
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service s2 =
+ createService("ID2", "V2", "D2");
+
+ GetServicesAAIRespone services = new GetServicesAAIRespone();
+ services.service = Arrays.asList(s1, s2);
+
+ AaiResponse<GetServicesAAIRespone> aaiResponseServices =
+ new AaiResponse<>(services, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServices()).thenReturn(aaiResponseServices);
+
+ Object actualObjectOfResponse = aaiService.getServices(roleValidator).getT();
+
+ assertThat(actualObjectOfResponse).isNotNull();
+ assertThat(((GetServicesAAIRespone) actualObjectOfResponse).service).allMatch(s -> s.isPermitted);
+ }
+
+ @Test
+ public void shouldGetTenants() {
+ GetTenantsResponse tenant1 = new GetTenantsResponse("REGION_ID1", "CLOUD_OWNER1",
+ "TENANT_NAME1", "TENANT_ID1", true);
+ GetTenantsResponse tenant2 = new GetTenantsResponse("REGION_ID2", "CLOUD_OWNER2",
+ "TENANT_NAME2", "TENANT_ID2", false);
+ GetTenantsResponse[] tenants = {tenant1, tenant2};
+ AaiResponse<GetTenantsResponse[]> aaiGetTenantsResponse = new AaiResponse<>(tenants,
+ null, HttpStatus.SC_OK);
+
+ when(aaiClient.getTenants(anyString(), anyString())).thenReturn(aaiGetTenantsResponse);
+ when(roleValidator.isTenantPermitted(anyString(), anyString(), anyString()))
+ .thenReturn(Boolean.TRUE);
+
+ GetTenantsResponse[] actualResponses = aaiService
+ .getTenants(anyString(), anyString(), roleValidator).getT();
+
+ assertThat(actualResponses).isNotNull();
+ assertThat(actualResponses.length).isEqualTo(2);
+ assertThat(actualResponses).allMatch(tenant -> tenant.isPermitted);
+ }
+
+ @Test
+ public void shouldGetVNFDataWithoutFiltering() {
+ when(aaiClient.getVNFData(anyString(), anyString(), anyString())).thenReturn(aaiResponse);
+
+ AaiResponse actualResponse = aaiService.getVNFData(anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetVNFDataWithFiltering() {
+ 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();
+
+ 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(actualResponseWithReturnedVnfs)
+ .isEqualToComparingFieldByFieldRecursively(expectedResponseWithReturnedVnfs);
+ assertThat(actualResponseWithoutReturnedVnfs)
+ .isEqualToComparingFieldByField(expectedResponseWithoutReturnedVnfs);
+ }
+
+ @Test
+ public void shouldGetAaiZones() {
+ when(aaiClient.getAllAicZones()).thenReturn(aaiResponse);
+
+ AaiResponse actualResponse = aaiService.getAaiZones();
+
+ assertThat(actualResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetAicZoneForPnf() {
+ ServiceRelationships relationsService = createServiceRelationships();
+ AaiResponse<ServiceRelationships> expectedServiceInstanceResp =
+ new AaiResponse<>(relationsService, null, HttpStatus.SC_OK);
+ AaiResponse<String> expectedResponse = new AaiResponse<>(CORRECT_VALUE, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
+ .thenReturn(expectedServiceInstanceResp);
+
+ AaiResponse actualResponse = aaiService.getAicZoneForPnf(anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetNodeTemplateInstances() {
+ when(aaiClient.getNodeTemplateInstances(anyString(), anyString(), anyString(),
+ anyString(), anyString())).thenReturn(aaiResponse);
+
+ AaiResponse expectedResponse = aaiService.getNodeTemplateInstances(anyString(), anyString(), anyString(),
+ anyString(), anyString());
+
+ assertThat(expectedResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetNetworkCollectionDetails() {
+ when(aaiClient.getNetworkCollectionDetails(anyString())).thenReturn(aaiResponse);
+
+ AaiResponse expectedResponse = aaiService.getNetworkCollectionDetails(anyString());
+
+ assertThat(expectedResponse).isEqualTo(aaiResponse);
+ }
+
+ @Test
+ public void shouldGetInstanceGroupsByCloudRegion() {
+ AaiGetInstanceGroupsByCloudRegion aaiGetInstanceGroupsByCloudRegion =
+ mock(AaiGetInstanceGroupsByCloudRegion.class);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> expectedResponse =
+ new AaiResponse<>(aaiGetInstanceGroupsByCloudRegion, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString()))
+ .thenReturn(expectedResponse);
+ AaiResponse<AaiGetInstanceGroupsByCloudRegion> actualResponse =
+ aaiService.getInstanceGroupsByCloudRegion(anyString(), anyString(), anyString());
+
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldGetServicesByDistributionStatus() {
+ Result resultWithModelType = createResult("MODEL_TYPE1", "1");
+ Result resultWithEmptyModelType = createResult(null, "2");
+ Result resultWithoutModel = new Result();
+ resultWithoutModel.setModel(null);
+ Result resultWithoutValidModel = createResultWithoutValidModel();
+ List<Result> results = Arrays.asList(resultWithModelType, resultWithEmptyModelType, resultWithoutModel,
+ resultWithoutValidModel);
+
+ GetServiceModelsByDistributionStatusResponse serviceModels = new GetServiceModelsByDistributionStatusResponse();
+ serviceModels.setResults(results);
+
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> serviceModelsByDistributionStatusResponse
+ = new AaiResponse<>(serviceModels, null, HttpStatus.SC_OK);
+
+ Service[] expectedServices = {
+ createService("MODEL_TYPE1", "1"),
+ createService("", "2")
+ };
+
+ when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(serviceModelsByDistributionStatusResponse);
+ Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+
+ assertThat(actualServices)
+ .hasSize(2)
+ .usingFieldByFieldElementComparator()
+ .containsExactly(expectedServices);
+ }
+
+ @Test
+ public void shouldReturnEmptyListOfServices() {
+ AaiResponse<GetServiceModelsByDistributionStatusResponse> emptyResponse
+ = new AaiResponse<>(null, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceModelsByDistributionStatus()).thenReturn(emptyResponse);
+ Collection<Service> actualServices = aaiService.getServicesByDistributionStatus();
+
+ assertThat(actualServices).isEqualTo(Collections.EMPTY_LIST);
+ }
+
+ @Test
+ public void shouldGetServiceInstanceAssociatedPnfs() {
+ ServiceRelationships relationsList = createServiceRelationships();
+ LogicalLinkResponse logicalLinkResponse = new LogicalLinkResponse();
+ logicalLinkResponse.setRelationshipList(relationsList.getRelationshipList());
+
+ AaiResponse<LogicalLinkResponse> aaiResponseLogicalLinkResponse =
+ new AaiResponse<>(logicalLinkResponse, null, HttpStatus.SC_OK);
+ AaiResponse<ServiceRelationships> aaiResponseServiceRelations =
+ new AaiResponse<>(relationsList, null, HttpStatus.SC_OK);
+
+ when(aaiClient.getServiceInstance(anyString(), anyString(), anyString()))
+ .thenReturn(aaiResponseServiceRelations);
+ when(aaiClient.getLogicalLink(anyString())).thenReturn(aaiResponseLogicalLinkResponse);
+
+
+ List<String> expectedPnfs = Collections.singletonList(CORRECT_VALUE);
+ List<String> actualPnfs = aaiService.getServiceInstanceAssociatedPnfs(anyString(), anyString(), anyString());
+
+ assertThat(actualPnfs).isEqualTo(expectedPnfs);
+ }
+
+ @Test
+ public void shouldGetPortMirroringConfigData() {
+ AaiResponseTranslator.PortMirroringConfigData expectedData
+ = mock(AaiResponseTranslator.PortMirroringConfigData.class);
+
+ when(aaiClient.getCloudRegionAndSourceByPortMirroringConfigurationId(anyString())).thenReturn(aaiResponseJsonNode);
+ when(aaiResponseTranslator.extractPortMirroringConfigData(aaiResponseJsonNode)).thenReturn(expectedData);
+
+ AaiResponseTranslator.PortMirroringConfigData actualData = aaiService.getPortMirroringConfigData(anyString());
+ assertThat(actualData).isEqualTo(expectedData);
+ }
+
+
+ @Test
+ public void shouldGetInstanceGroupsByVnfInstanceId() {
+ List<InstanceGroupInfo> instanceGroupInfo = Collections.singletonList(new InstanceGroupInfo(CORRECT_VALUE));
+ AaiGetRelatedInstanceGroupsByVnfId relatedInstanceGroups = new AaiGetRelatedInstanceGroupsByVnfId();
+ relatedInstanceGroups.setRelationshipList(createRelationshipList());
+
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> correctCodeResponse =
+ new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_OK);
+
+ AaiResponse<List<InstanceGroupInfo>> expectedCorrectCodeResponse =
+ new AaiResponse<>(instanceGroupInfo, null, HttpStatus.SC_OK);
+ AaiResponse<AaiGetRelatedInstanceGroupsByVnfId> expectedIncorrectCodeResponse =
+ new AaiResponse<>(relatedInstanceGroups, null, HttpStatus.SC_PAYMENT_REQUIRED);
+ List<InstanceGroupInfo> expectedCorrectResponseObject = expectedCorrectCodeResponse.getT();
+
+ when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK)).thenReturn(correctCodeResponse);
+ when(aaiClient.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL)).thenReturn(expectedIncorrectCodeResponse);
+
+ AaiResponse actualCorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_OK);
+ AaiResponse actualIncorrectCodeResponse = aaiService.getInstanceGroupsByVnfInstanceId(VNF_INSTANCE_ID_FAIL);
+
+ List<InstanceGroupInfo> actualCorrectResponseObject =
+ (List<InstanceGroupInfo>) actualCorrectCodeResponse.getT();
+
+ assertThat(actualCorrectResponseObject)
+ .usingFieldByFieldElementComparator()
+ .hasSameElementsAs(expectedCorrectResponseObject);
+
+ assertThat(actualIncorrectCodeResponse).isEqualTo(expectedIncorrectCodeResponse);
+ }
+
+ @Test
+ public void shouldGetHomingDataByVfModule() {
+ GetTenantsResponse expectedResponse = new GetTenantsResponse();
+ when(aaiClient.getHomingDataByVfModule(anyString(), anyString())).thenReturn(expectedResponse);
+
+ GetTenantsResponse actualResponse = aaiService.getHomingDataByVfModule(anyString(), anyString());
+ assertThat(actualResponse).isEqualTo(expectedResponse);
+ }
+
+ @Test
+ public void shouldSearchGroupMembers() {
+ Properties properties = createProperties();
+ Map<String, Properties> regionsAndTenants = createRegionsAndTenantsMap(properties);
+
+ AAITreeNode validTreeNode = new AAITreeNode();
+ addAdditionalPropertiesToAaiTreeNode(validTreeNode);
+ List<AAITreeNode> validNodes = Arrays.asList(validTreeNode, validTreeNode);
+
+ AAITreeNode validBranch = createTree(validNodes);
+ addAdditionalPropertiesToAaiTreeNode(validBranch);
+ List<AAITreeNode> testedBranches = Collections.singletonList(validBranch);
+
+ AAITreeNode testedTree = createTree(testedBranches);
+
+ RelatedVnf expectedVnf = createExpectedVnf(validBranch);
+ List<RelatedVnf> expectedResult = Collections.singletonList(expectedVnf);
+
+ when(aaiServiceTree.buildAAITree(anyString(), any())).thenReturn(Collections.singletonList(testedTree));
+ when(aaiClient.getCloudRegionAndTenantByVnfId(anyString())).thenReturn(regionsAndTenants);
+
+ List<RelatedVnf> actualGroupMembers = aaiService.searchGroupMembers(GLOBAL_CUSTOMER_ID, SERVICE_TYPE,
+ INVARIANT_ID, GROUP_TYPE_FAILING, GROUP_ROLE_FAILING);
+
+ assertThat(actualGroupMembers)
+ .usingFieldByFieldElementComparator()
+ .hasSameElementsAs(expectedResult);
+ }
+
+ @Test
+ public void shouldGetPortMirroringSourcePorts() {
+ PortDetailsTranslator.PortDetails details = mock(PortDetailsTranslator.PortDetails.class);
+ List<PortDetailsTranslator.PortDetails> expectedDetailsList = Arrays.asList(
+ details, details, details
+ );
+
+ when(aaiClient.getPortMirroringSourcePorts(anyString())).thenReturn(expectedDetailsList);
+ List<PortDetailsTranslator.PortDetails> actualDetails = aaiService.getPortMirroringSourcePorts(anyString());
+
+ assertThat(actualDetails).isEqualTo(expectedDetailsList);
+ }
+
+ @Test
+ public void shouldGetAAIServiceTree() throws JsonProcessingException {
+ ServiceInstance serviceInstance = mock(ServiceInstance.class);
+ String expectedResult = new ObjectMapper().writeValueAsString(serviceInstance);
+
+ when(aaiServiceTree.getServiceInstanceTopology(anyString(), anyString(), anyString()))
+ .thenReturn(serviceInstance);
+ String actualResult = aaiService.getAAIServiceTree(anyString(), anyString(), anyString());
+
+ assertThat(actualResult).isEqualTo(expectedResult);
+ }
+
+ @NotNull
+ private Map<String, Properties> createRegionsAndTenantsMap(Properties properties) {
+ Map<String, Properties> regionsAndTenants = new HashMap<>();
+ regionsAndTenants.put("tenant", properties);
+ regionsAndTenants.put("cloud-region", properties);
+ return regionsAndTenants;
+ }
+
+ private Properties createProperties() {
+ Properties properties = new Properties();
+ properties.setTenantId(TENANT_ID);
+ properties.setTenantName(TENANT_NAME);
+ properties.setCloudRegionId(CLOUD_REGION_ID);
+ return properties;
+ }
+
+ @NotNull
+ private RelatedVnf createExpectedVnf(AAITreeNode validBranch) {
+ RelatedVnf expectedVnf = RelatedVnf.from(validBranch);
+ expectedVnf.setTenantId(TENANT_ID);
+ expectedVnf.setTenantName(TENANT_NAME);
+ expectedVnf.setLcpCloudRegionId(CLOUD_REGION_ID);
+ expectedVnf.setServiceInstanceId(PARENT_ID);
+ expectedVnf.setServiceInstanceName(PARENT_NAME);
+ expectedVnf.setInstanceType(VNF_TYPE);
+
+ return expectedVnf;
+ }
+
+
+ private AAITreeNode createTree(List<AAITreeNode> children) {
+ AAITreeNode tree = new AAITreeNode();
+ tree.addChildren(children);
+ tree.setId(PARENT_ID);
+ tree.setName(PARENT_NAME);
+ return tree;
+ }
+
+ private void addAdditionalPropertiesToAaiTreeNode(AAITreeNode tree) {
+ Map<String, Object> additionalProperties = new HashMap<>();
+ additionalProperties.put("instance-group-role", GROUP_ROLE_OK);
+ additionalProperties.put("instance-group-type", group_type_ok);
+ additionalProperties.put("vnf-type", VNF_TYPE);
+ additionalProperties.put("cloud-region", CLOUD_TYPE);
+ tree.setAdditionalProperties(additionalProperties);
+ }
+
+ private org.onap.vid.asdc.beans.Service createService(String category, String suffix) {
+ return new Service.ServiceBuilder()
+ .setUuid("MODELVER_VERSION_ID" + suffix)
+ .setInvariantUUID("MODEL_INVARIANT_NAME" + suffix)
+ .setCategory(category)
+ .setVersion("MODELVER_VERSION" + suffix)
+ .setName("MODELVER_NAME" + suffix)
+ .setDistributionStatus("MODELVER_DIST_STATUS" + suffix)
+ .setToscaModelURL(null)
+ .setLifecycleState(null)
+ .setArtifacts(null)
+ .setResources(null)
+ .build();
+ }
+
+ @NotNull
+ private Result createResultWithoutValidModel() {
+ ModelVers modelVers = new ModelVers();
+ modelVers.setModelVer(Collections.singletonList(new ModelVer()));
+
+ Model model = new Model();
+ model.setModelVers(modelVers);
+
+ Result result1 = new Result();
+ result1.setModel(model);
+ return result1;
+ }
+
+ @NotNull
+ private Result createResult(String modelType, String suffix) {
+ ModelVer modelVer = new ModelVer();
+ modelVer.setModelVersionId("MODELVER_VERSION_ID" + suffix);
+ modelVer.setModelVersion("MODELVER_VERSION" + suffix);
+ modelVer.setModelName("MODELVER_NAME" + suffix);
+ modelVer.setDistributionStatus("MODELVER_DIST_STATUS" + suffix);
+
+ ModelVers modelVers = new ModelVers();
+ modelVers.setModelVer(Collections.singletonList(modelVer));
+
+ Model model = new Model();
+ model.setModelType(modelType);
+ model.setModelInvariantId("MODEL_INVARIANT_NAME" + suffix);
+ model.setModelVers(modelVers);
+
+ Result result = new Result();
+ result.setModel(model);
+ return result;
+ }
+
+ @NotNull
+ private ServiceRelationships createServiceRelationships() {
+ RelationshipList relationsList = createRelationshipList(CORRECT_VALUE);
+ ServiceRelationships relationsService = new ServiceRelationships();
+ relationsService.setRelationshipList(relationsList);
+ return relationsService;
+ }
+
+ @NotNull
+ private RelationshipList createRelationshipList(String expectedValue) {
+ List<RelationshipData> relationsDataList = createRelationshipDataList(expectedValue);
+ return createRelationshipList(relationsDataList);
+ }
+
+ @NotNull
+ private RelationshipList createRelationshipList(List<RelationshipData> relationsDataList) {
+ Relationship relation1 = crateRelationship("any", relationsDataList);
+ Relationship relation2 = crateRelationship("zone", relationsDataList);
+ Relationship relation3 = crateRelationship("logical-link", relationsDataList);
+ Relationship relation4 = crateRelationship("lag-interface", relationsDataList);
+ Relationship relation5 = crateRelationship("pnf", relationsDataList);
+
+ RelationshipList relationsList = new RelationshipList();
+ relationsList.setRelationship(Arrays.asList(relation1, relation2, relation3, relation4, relation5));
+ return relationsList;
+ }
+
+ @NotNull
+ private List<RelationshipData> createRelationshipDataList(String expectedValue) {
+ RelationshipData relationData1 = createRelationshipData("any-key", "incorrect_key");
+ RelationshipData relationData2 = createRelationshipData("zone.zone-id", expectedValue);
+ RelationshipData relationData3 = createRelationshipData("logical-link.link-name", expectedValue);
+ RelationshipData relationData4 = createRelationshipData("pnf.pnf-name", expectedValue);
+
+ return Arrays.asList(relationData1, relationData2, relationData3, relationData4);
+ }
+
+ @NotNull
+ private Relationship crateRelationship(String relatedTo, List<RelationshipData> relationsDataList) {
+ Relationship relation = new Relationship();
+ relation.setRelatedTo(relatedTo);
+ relation.setRelationDataList(relationsDataList);
+ return relation;
+ }
+
+ @NotNull
+ private RelationshipData createRelationshipData(String key, String value) {
+ RelationshipData relationData = new RelationshipData();
+ relationData.setRelationshipKey(key);
+ relationData.setRelationshipValue(value);
+ return relationData;
+ }
+
+ private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList createRelationshipList() {
+ RelatedToProperty property1 =
+ createRelatedToProperty("instance-group.instance-group-name", CORRECT_VALUE);
+ RelatedToProperty property2 =
+ createRelatedToProperty("anything-key", "anything-value");
+ List<RelatedToProperty> properties = Arrays.asList(property1, property2);
+
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
+ createRelationship("instance-group", properties);
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship2 =
+ createRelationship("any-key", properties);
+
+ List<org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship> relationships =
+ Arrays.asList(relationship1, relationship2);
+
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList relationshipList =
+ new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList();
+ relationshipList.setRelationship(relationships);
+
+ return relationshipList;
+ }
+
+ @NotNull
+ private org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship createRelationship(String relatedTo,
+ List<RelatedToProperty> relatedToPropertyList) {
+ org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship relationship1 =
+ new org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship();
+ relationship1.setRelatedTo(relatedTo);
+ relationship1.setRelatedToPropertyList(relatedToPropertyList);
+ return relationship1;
+ }
+
+ @NotNull
+ private RelatedToProperty createRelatedToProperty(String key, String value) {
+ RelatedToProperty prop = new RelatedToProperty();
+ prop.setPropertyKey(key);
+ prop.setPropertyValue(value);
+ return prop;
+ }
+
+ @NotNull
+ private AaiResponse<AaiGetVnfResponse> createAaiResponseVnfResponse(List<VnfResult> vnfResults) {
+ AaiGetVnfResponse vnfResponse = new AaiGetVnfResponse();
+ vnfResponse.setResults(vnfResults);
+ return new AaiResponse<>(vnfResponse, null, HttpStatus.SC_OK);
+ }
+
+ private VnfResult createVnfResult(String id, String nodeType) {
+ VnfResult result = new VnfResult();
+ result.setJsonId(id);
+ result.setJsonNodeType(nodeType);
+ return result;
+ }
+
+
+ private org.onap.vid.aai.model.AaiGetServicesRequestModel.Service createService(String serviceId,
+ String resourceVersion,
+ String serviceDescription) {
+ org.onap.vid.aai.model.AaiGetServicesRequestModel.Service service
+ = new org.onap.vid.aai.model.AaiGetServicesRequestModel.Service();
+ service.isPermitted = false;
+ service.resourceVersion = resourceVersion;
+ service.serviceDescription = serviceDescription;
+ service.serviceId = serviceId;
+ return service;
+ }
+
+ @NotNull
+ private Services createAaiResponseServices() {
+ ServiceSubscription sub1 = new ServiceSubscription();
+ sub1.isPermitted = false;
+ sub1.serviceType = "serviceSubsType1";
+
+ ServiceSubscription sub2 = new ServiceSubscription();
+ sub2.isPermitted = true;
+ sub2.serviceType = "serviceSubsType2";
+
+ ServiceSubscriptions serviceSubs = new ServiceSubscriptions();
+ serviceSubs.serviceSubscription = Collections.singletonList(sub2);
+
+ Services services = new Services();
+ services.globalCustomerId = GLOBAL_CUSTOMER_ID;
+ services.resourceVersion = "v-1";
+ services.subscriberName = "name-1";
+ services.subscriberType = "type-1";
+ services.serviceSubscriptions = serviceSubs;
+ return services;
+ }
+
+ @NotNull
+ private Subscriber createSubscriber() {
+ Subscriber subscriber = new Subscriber();
+ subscriber.globalCustomerId = "id-1";
+ subscriber.resourceVersion = "v-1";
+ subscriber.subscriberName = "name-1";
+ subscriber.subscriberType = "type-1";
+ return subscriber;
+ }
+}