From 9ac6c3cc7e3f4aec9ba69e7a5bb0800471c4e8dc Mon Sep 17 00:00:00 2001 From: MatthieuGeerebaert Date: Wed, 28 Mar 2018 17:12:51 +0200 Subject: Add service inventory - Add service inventory operations get and find - Consumes AAI - Add tests Change-Id: If04ada259b7a172c1dbaac3649047cdb2d9dd5bc Issue-ID: EXTAPI-39 Signed-off-by: MatthieuGeerebaert --- .../java/org/onap/nbi/OnapComponentsUrlPaths.java | 2 +- .../onap/nbi/apis/servicecatalog/SdcClient.java | 5 +- .../onap/nbi/apis/serviceinventory/AaiClient.java | 82 ++++++++++ .../onap/nbi/apis/serviceinventory/BaseClient.java | 33 ++++ .../onap/nbi/apis/serviceinventory/NbiClient.java | 20 +++ .../serviceinventory/ServiceInventoryResource.java | 45 ++++++ .../serviceinventory/ServiceInventoryService.java | 149 ++++++++++++++++++ .../jolt/FindServiceInventoryJsonTransformer.java | 35 +++++ .../jolt/GetServiceInventoryJsonTransformer.java | 36 +++++ .../resources/application-localhost.properties | 16 ++ src/main/resources/jolt/findServiceInventory.json | 24 +++ src/main/resources/jolt/getServiceInventory.json | 44 ++++++ .../java/org/onap/nbi/apis/resources/ApiTest.java | 74 ++++++++- .../apis/resources/ServiceInventoryAssertions.java | 88 +++++++++++ src/test/resources/application.properties | 15 +- .../aai_get_6490_service-subscriptions.json | 24 +++ .../resources/mappings/aai_get_customer_6490.json | 18 +++ .../mappings/aai_get_customer_generic.json | 18 +++ .../aai_get_generic_service-subscriptions.json | 20 +++ .../mappings/aai_get_service-subscription.json | 55 +++++++ .../mappings/aai_get_service-subscription_vnf.json | 58 +++++++ .../mappings/aai_get_service-subscriptionsVFW.json | 43 ++++++ ...service-subscriptionsvFW-service-2VF-based.json | 43 ++++++ src/test/resources/mappings/aai_get_tenants.json | 167 +++++++++++++++++++++ src/test/resources/mappings/aai_put_customer.json | 12 ++ .../mappings/aai_put_customer_service.json | 12 ++ 26 files changed, 1132 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java create mode 100644 src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java create mode 100644 src/main/resources/jolt/findServiceInventory.json create mode 100644 src/main/resources/jolt/getServiceInventory.json create mode 100644 src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java create mode 100644 src/test/resources/mappings/aai_get_6490_service-subscriptions.json create mode 100644 src/test/resources/mappings/aai_get_customer_6490.json create mode 100644 src/test/resources/mappings/aai_get_customer_generic.json create mode 100644 src/test/resources/mappings/aai_get_generic_service-subscriptions.json create mode 100644 src/test/resources/mappings/aai_get_service-subscription.json create mode 100644 src/test/resources/mappings/aai_get_service-subscription_vnf.json create mode 100644 src/test/resources/mappings/aai_get_service-subscriptionsVFW.json create mode 100644 src/test/resources/mappings/aai_get_service-subscriptionsvFW-service-2VF-based.json create mode 100644 src/test/resources/mappings/aai_get_tenants.json create mode 100644 src/test/resources/mappings/aai_put_customer.json create mode 100644 src/test/resources/mappings/aai_put_customer_service.json (limited to 'src') diff --git a/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java b/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java index 5ee6528..797fde8 100644 --- a/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java +++ b/src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java @@ -15,7 +15,7 @@ public final class OnapComponentsUrlPaths { // AAI public static final String AAI_GET_TENANTS_PATH = - "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/$cloudOwner/$lcpCloudRegionId/tenants"; + "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/$onap.cloudOwner/$onap.lcpCloudRegionId/tenants"; public static final String AAI_GET_CUSTOMER_PATH = "/aai/v11/business/customers/customer/"; public static final String AAI_GET_SERVICES_FOR_CUSTOMER_PATH = "/aai/v11/business/customers/customer/$customerId/service-subscriptions"; diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java index abc8bda..5bab982 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/SdcClient.java @@ -50,8 +50,8 @@ public class SdcClient { public LinkedHashMap callGet(String id) { - StringBuilder callURL = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL).append(id) - .append(OnapComponentsUrlPaths.SDC_GET_PATH); + StringBuilder callURL = new StringBuilder().append(sdcHost).append(OnapComponentsUrlPaths.SDC_ROOT_URL) + .append(id).append(OnapComponentsUrlPaths.SDC_GET_PATH); ResponseEntity response = callSdc(callURL.toString()); return (LinkedHashMap) response.getBody(); @@ -134,7 +134,6 @@ public class SdcClient { } catch (BackendFunctionalException e) { LOGGER.error(HTTP_CALL_SDC_ON + callURL.toString() + " error " + e); - return null; } } diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java new file mode 100644 index 0000000..1f5f74d --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java @@ -0,0 +1,82 @@ +package org.onap.nbi.apis.serviceinventory; + +import java.util.LinkedHashMap; +import org.onap.nbi.OnapComponentsUrlPaths; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +@Service +public class AaiClient extends BaseClient { + + public static final String CUSTOMER_ID = "$customerId"; + + @Value("${aai.host}") + private String aaiHost; + + @Value("${aai.header.authorization}") + private String aaiHeaderAuthorization; + + @Value("${aai.api.id}") + private String aaiApiId; + + private static final String HEADER_AUTHORIZATION = "Authorization"; + private static final String X_FROM_APP_ID = "X-FromAppId"; + + private HttpHeaders buildRequestHeaderForAAI() { + + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.add(HEADER_AUTHORIZATION, aaiHeaderAuthorization); + httpHeaders.add(X_FROM_APP_ID, aaiApiId); + httpHeaders.add("Accept", "application/json"); + httpHeaders.add("Content-Type", "application/json"); + return httpHeaders; + + } + + public LinkedHashMap getCatalogService(String customerId, String serviceSpecName, String serviceId) { + + StringBuilder callURL = + new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_FOR_CUSTOMER_PATH); + String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId); + callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceSpecName); + callUrlFormated = callUrlFormated.replace("$serviceId", serviceId); + + ResponseEntity response = callApiGet(callUrlFormated, buildRequestHeaderForAAI()); + if (response != null && response.getStatusCode().equals(HttpStatus.OK)) { + return (LinkedHashMap) response.getBody(); + } + return null; + } + + + public LinkedHashMap getVNF(String relatedLink) { + + StringBuilder callURL = new StringBuilder().append(aaiHost).append(relatedLink); + + ResponseEntity response = callApiGet(callURL.toString(), buildRequestHeaderForAAI()); + return (LinkedHashMap) response.getBody(); + + } + + public LinkedHashMap getServicesInAaiForCustomer(String customerId) { + StringBuilder callURL = + new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICES_FOR_CUSTOMER_PATH); + String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId); + + ResponseEntity response = callApiGet(callUrlFormated, buildRequestHeaderForAAI()); + return (LinkedHashMap) response.getBody(); + } + + public LinkedHashMap getServiceInstancesInAaiForCustomer(String customerId, String serviceType) { + StringBuilder callURL = + new StringBuilder().append(aaiHost).append(OnapComponentsUrlPaths.AAI_GET_SERVICE_INSTANCES_PATH); + String callUrlFormated = callURL.toString().replace(CUSTOMER_ID, customerId); + callUrlFormated = callUrlFormated.replace("$serviceSpecName", serviceType); + + ResponseEntity response = callApiGet(callUrlFormated, buildRequestHeaderForAAI()); + return (LinkedHashMap) response.getBody(); + } +} diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java new file mode 100644 index 0000000..b9a93d0 --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java @@ -0,0 +1,33 @@ +package org.onap.nbi.apis.serviceinventory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +public abstract class BaseClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(BaseClient.class); + + @Autowired + private RestTemplate restTemplate; + + protected ResponseEntity callApiGet(String callURL, HttpHeaders httpHeaders) { + + ResponseEntity response = restTemplate.exchange(callURL, HttpMethod.GET, + new HttpEntity<>("parameters", httpHeaders), Object.class); + LOGGER.debug("response body : " + response.getBody().toString()); + LOGGER.info("response status : " + response.getStatusCodeValue()); + if (!response.getStatusCode().equals(HttpStatus.OK)) { + LOGGER.warn("HTTP call on " + callURL + " returns " + response.getStatusCodeValue() + ", " + + response.getBody().toString()); + } + return response; + } + +} diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java new file mode 100644 index 0000000..cbbd88d --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/NbiClient.java @@ -0,0 +1,20 @@ +package org.onap.nbi.apis.serviceinventory; + +import java.util.LinkedHashMap; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +@Service +public class NbiClient extends BaseClient { + + @Value("${nbi.url}") + private String nbiUrl; + + public LinkedHashMap getServiceSpecification(String id) { + StringBuilder callURL = new StringBuilder().append(nbiUrl).append("/serviceSpecification/").append(id); + ResponseEntity response = callApiGet(callURL.toString(), new HttpHeaders()); + return (LinkedHashMap) response.getBody(); + } +} diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java new file mode 100644 index 0000000..9092381 --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryResource.java @@ -0,0 +1,45 @@ +package org.onap.nbi.apis.serviceinventory; + +import java.util.LinkedHashMap; +import java.util.List; +import org.onap.nbi.commons.JsonRepresentation; +import org.onap.nbi.commons.ResourceManagement; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/service") +public class ServiceInventoryResource extends ResourceManagement { + + @Autowired + ServiceInventoryService serviceInventoryService; + + @GetMapping(value = "/{serviceId}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getServiceInventory(@PathVariable String serviceId, + @RequestParam MultiValueMap params) { + + LinkedHashMap response = serviceInventoryService.get(serviceId, params); + + JsonRepresentation filter = new JsonRepresentation(params); + return this.getResponse(response, filter); + + } + + @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findServiceInventory(@RequestParam MultiValueMap params) { + + List response = serviceInventoryService.find(params); + JsonRepresentation filter = new JsonRepresentation(params); + return this.findResponse(response, filter, null); + + } + + +} diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java new file mode 100644 index 0000000..886a464 --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java @@ -0,0 +1,149 @@ +package org.onap.nbi.apis.serviceinventory; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import org.onap.nbi.apis.serviceinventory.jolt.FindServiceInventoryJsonTransformer; +import org.onap.nbi.apis.serviceinventory.jolt.GetServiceInventoryJsonTransformer; +import org.onap.nbi.exceptions.BackendFunctionalException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.util.MultiValueMap; +import org.springframework.util.StringUtils; + +@Service +public class ServiceInventoryService { + + @Autowired + NbiClient nbiClient; + + @Autowired + AaiClient aaiClient; + + @Autowired + GetServiceInventoryJsonTransformer getServiceInventoryJsonTransformer; + + @Autowired + FindServiceInventoryJsonTransformer findServiceInventoryJsonTransformer; + + public LinkedHashMap get(String serviceId, MultiValueMap params) { + + String clientId = params.getFirst("relatedParty.id"); + String serviceSpecId = params.getFirst("serviceSpecification.id"); + String serviceSpecName = params.getFirst("serviceSpecification.name"); + + if (StringUtils.isEmpty(serviceSpecId) && StringUtils.isEmpty(serviceSpecName)) { + throw new BackendFunctionalException(HttpStatus.NOT_FOUND, + "serviceSpecName or serviceSpecId must be provided"); + } + + String customerId = getCustomerId(clientId); + String serviceName = getServiceName(serviceSpecName, serviceSpecId); + LinkedHashMap serviceResponse = aaiClient.getCatalogService(customerId, serviceName, serviceId); + + if (serviceResponse != null) { + addVnfsToResponse(serviceResponse); + LinkedHashMap serviceInventoryResponse = + (LinkedHashMap) getServiceInventoryJsonTransformer.transform(serviceResponse); + addRelatedPartyId(customerId, serviceInventoryResponse); + return serviceInventoryResponse; + } else { + throw new BackendFunctionalException(HttpStatus.NOT_FOUND, "no catalog service found"); + } + + } + + + private String getCustomerId(String clientId) { + + if (StringUtils.isEmpty(clientId)) { + return "generic"; + } else { + return clientId; + } + + } + + private String getServiceName(String serviceSpecificationName, String serviceSpecificationId) { + + if (StringUtils.isEmpty(serviceSpecificationName)) { + LinkedHashMap serviceSpecification = nbiClient.getServiceSpecification(serviceSpecificationId); + return (String) serviceSpecification.get("name"); + } else { + return serviceSpecificationName; + } + + } + + private void addRelatedPartyId(String customerId, LinkedHashMap serviceInventoryResponse) { + + LinkedHashMap relatedParty = (LinkedHashMap) serviceInventoryResponse.get("relatedParty"); + relatedParty.put("id", customerId); + + } + + private void addVnfsToResponse(LinkedHashMap serviceResponse) { + + List vnfs = new ArrayList<>(); + LinkedHashMap relationShip = (LinkedHashMap) serviceResponse.get("relationship-list"); + List relationsList = (List) relationShip.get("relationship"); + for (LinkedHashMap relation : relationsList) { + String relatedLink = (String) relation.get("related-link"); + LinkedHashMap vnf = aaiClient.getVNF(relatedLink); + if (vnf != null) { + vnfs.add(vnf); + } + } + serviceResponse.put("vnfs", vnfs); + + } + + + public List find(MultiValueMap params) { + + String clientId = params.getFirst("relatedParty.id"); + String serviceSpecId = params.getFirst("serviceSpecification.id"); + String serviceSpecName = params.getFirst("serviceSpecification.name"); + String customerId = getCustomerId(clientId); + String serviceName; + List serviceInstances = new ArrayList<>(); + if (StringUtils.isEmpty(serviceSpecId) && StringUtils.isEmpty(serviceSpecName)) { + LinkedHashMap servicesInAaiForCustomer = aaiClient.getServicesInAaiForCustomer(customerId); + List servicesInAAI = + (List) servicesInAaiForCustomer.get("service-subscription"); + for (LinkedHashMap service : servicesInAAI) { + String serviceType = (String) service.get("service-type"); + buildServiceInstances(serviceInstances, customerId, serviceType); + } + } else { + serviceName = getServiceName(serviceSpecName, serviceSpecId); + buildServiceInstances(serviceInstances, customerId, serviceName); + } + + List serviceInventoryResponse = + (List) findServiceInventoryJsonTransformer.transform(serviceInstances); + for (LinkedHashMap serviceInventory : serviceInventoryResponse) { + LinkedHashMap party = (LinkedHashMap) serviceInventory.get("relatedParty"); + party.put("id", customerId); + } + return serviceInventoryResponse; + + } + + private void buildServiceInstances(List serviceInstances, String customerId, String serviceType) { + + LinkedHashMap serviceInstancesInAaiForCustomer = + aaiClient.getServiceInstancesInAaiForCustomer(customerId, serviceType); + List serviceInstancesForServiceType = + (List) serviceInstancesInAaiForCustomer.get("service-instance"); + + // add service type for jolt + for (LinkedHashMap serviceInstanceForServiceType : serviceInstancesForServiceType) { + serviceInstanceForServiceType.put("service-type", serviceType); + } + serviceInstances.addAll(serviceInstancesForServiceType); + + } + +} diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java new file mode 100644 index 0000000..8173215 --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/FindServiceInventoryJsonTransformer.java @@ -0,0 +1,35 @@ +package org.onap.nbi.apis.serviceinventory.jolt; + +import java.util.List; +import org.onap.nbi.exceptions.TechnicalException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import com.bazaarvoice.jolt.Chainr; +import com.bazaarvoice.jolt.JsonUtils; +import com.bazaarvoice.jolt.exception.JoltException; + +@Service +public class FindServiceInventoryJsonTransformer { + + private Chainr chainr; + + private static final Logger LOGGER = LoggerFactory.getLogger(FindServiceInventoryJsonTransformer.class); + + public FindServiceInventoryJsonTransformer() { + List specs = JsonUtils.classpathToList("/jolt/findServiceInventory.json"); + this.chainr = Chainr.fromSpec(specs); + } + + public Object transform(Object serviceSpec) { + Object output = null; + try { + output = chainr.transform(serviceSpec); + } catch (JoltException joE) { + LOGGER.error("Unable to transform SDC response with JOLT Transformer : " + joE.getMessage()); + throw new TechnicalException("Error while parsing ONAP response"); + } + return output; + } + +} diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java new file mode 100644 index 0000000..f82c696 --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceinventory/jolt/GetServiceInventoryJsonTransformer.java @@ -0,0 +1,36 @@ +package org.onap.nbi.apis.serviceinventory.jolt; + +import java.util.List; +import org.onap.nbi.exceptions.TechnicalException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import com.bazaarvoice.jolt.Chainr; +import com.bazaarvoice.jolt.JsonUtils; +import com.bazaarvoice.jolt.exception.JoltException; + +@Service +public class GetServiceInventoryJsonTransformer { + + private Chainr chainr; + + private static final Logger LOGGER = LoggerFactory.getLogger(GetServiceInventoryJsonTransformer.class); + + + public GetServiceInventoryJsonTransformer() { + List specs = JsonUtils.classpathToList("/jolt/getServiceInventory.json"); + this.chainr = Chainr.fromSpec(specs); + } + + public Object transform(Object serviceSpec) { + Object output = null; + try { + output = chainr.transform(serviceSpec); + } catch (JoltException joE) { + LOGGER.error("Unable to transform SDC response with JOLT Transformer : " + joE.getMessage()); + throw new TechnicalException("Error while parsing ONAP response"); + } + return output; + } + +} diff --git a/src/main/resources/application-localhost.properties b/src/main/resources/application-localhost.properties index 58b13f6..e753488 100644 --- a/src/main/resources/application-localhost.properties +++ b/src/main/resources/application-localhost.properties @@ -1,7 +1,23 @@ # LOGGING logging.level.org.onap.nbi=DEBUG +# ONAP +onap.lcpCloudRegionId=RegionOne +onap.tenantId=31047205ce114b60833b23e400d6a535 +onap.cloudOwner=CloudOwner + +# NBI +nbi.url=http://127.0.0.1:8080/nbi/api/v1 + # SDC sdc.host=http://127.0.0.1:8090 sdc.header.ecompInstanceId=Rene sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU= + +# AAI +aai.host=http://127.0.0.1:8090 +aai.header.authorization=Basic QUFJOkFBSQ== +aai.api.id=AAI + + + diff --git a/src/main/resources/jolt/findServiceInventory.json b/src/main/resources/jolt/findServiceInventory.json new file mode 100644 index 0000000..7188edc --- /dev/null +++ b/src/main/resources/jolt/findServiceInventory.json @@ -0,0 +1,24 @@ +[ + { + "operation": "shift", + "spec": { + "*": { + "service-instance-id": "[&1].id", + "service-instance-name": "[&1].name", + "service-type": "[&1].serviceSpecification.name", + "model-version-id": "[&1].serviceSpecification.id" + } + } + }, + { + "operation": "default", + "spec": { + "*": { + "relatedParty": { + + "role": "ONAPcustomer" + } + } + } + } +] \ No newline at end of file diff --git a/src/main/resources/jolt/getServiceInventory.json b/src/main/resources/jolt/getServiceInventory.json new file mode 100644 index 0000000..df4f14c --- /dev/null +++ b/src/main/resources/jolt/getServiceInventory.json @@ -0,0 +1,44 @@ +[ + { + "operation": "shift", + "spec": { + "service-instance-id": "id", + "service-instance-name": "name", + "model-version-id" : "serviceSpecification.id", + "model-invariant-id": "serviceSpecification.invariantUUID", + "vnfs" : { + "*": { + "vnf-id": "supportingResource[&1].id", + "related-link": "supportingResource[&1].href", + "vnf-name": "supportingResource[&1].name", + "prov-status": "supportingResource[&1].status", + "model-invariant-id": "supportingResource[&1].modelInvariantId", + "model-version-id": "supportingResource[&1].modelVersionId", + "model-customisation-id": "supportingResource[&1].status" + + } + } + } + }, + { + "operation": "default", + "spec": { + "type": "service-instance", + "hasStarted": "yes", + "@type": "serviceONAP", + "serviceSpecification" : { + "@type" :"ONAPservice" + }, + "supportingResource[]" : { + "*": { + "@referredType": "ONAP resource" + } + + }, + "relatedParty" : { + "role" :"ONAPcustomer" + } + + } + } +] \ No newline at end of file diff --git a/src/test/java/org/onap/nbi/apis/resources/ApiTest.java b/src/test/java/org/onap/nbi/apis/resources/ApiTest.java index 05d332c..df2fb24 100644 --- a/src/test/java/org/onap/nbi/apis/resources/ApiTest.java +++ b/src/test/java/org/onap/nbi/apis/resources/ApiTest.java @@ -8,6 +8,7 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.nbi.apis.servicecatalog.ServiceSpecificationResource; +import org.onap.nbi.apis.serviceinventory.ServiceInventoryResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; @@ -26,12 +27,14 @@ public class ApiTest { String realServerPort; - static public WireMockServer wireMockServer = new WireMockServer(8091); @Autowired ServiceSpecificationResource serviceSpecificationResource; + @Autowired + ServiceInventoryResource serviceInventoryResource; + @BeforeClass public static void setUp() throws Exception { wireMockServer.start(); @@ -48,6 +51,8 @@ public class ApiTest { wireMockServer.resetToDefaultMappings(); } + // serviceCatalog + @Test @Ignore public void testServiceResourceGetCatalog() throws Exception { @@ -86,4 +91,71 @@ public class ApiTest { } + // serviceInventory + + @Test + public void testServiceResourceGetInventory() throws Exception { + + String serviceName = "vFW"; + String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"; + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("serviceSpecification.name", serviceName); + params.add("relatedParty.id", "6490"); + ResponseEntity resource = serviceInventoryResource.getServiceInventory(serviceId, params); + ServiceInventoryAssertions.assertServiceInventoryGet(resource); + + } + + + @Test + public void testServiceResourceGetInventoryWithServiceSpecId() throws Exception { + + String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"; + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("serviceSpecification.id", "1e3feeb0-8e36-46c6-862c-236d9c626439"); + params.add("relatedParty.id", "6490"); + ResponseEntity resource = serviceInventoryResource.getServiceInventory(serviceId, params); + ServiceInventoryAssertions.assertServiceInventoryGet(resource); + + } + + + @Test + public void testServiceInventoryFind() throws Exception { + + MultiValueMap params = new LinkedMultiValueMap<>(); + String serviceName = "vFW"; + params.add("serviceSpecification.name", serviceName); + params.add("relatedParty.id", "6490"); + + ResponseEntity resource = serviceInventoryResource.findServiceInventory(params); + ServiceInventoryAssertions.assertServiceInventoryFind(resource); + + } + + + @Test + public void testServiceInventoryFindWithServiceSpecId() throws Exception { + + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("serviceSpecification.id", "1e3feeb0-8e36-46c6-862c-236d9c626439"); + params.add("relatedParty.id", "6490"); + + ResponseEntity resource = serviceInventoryResource.findServiceInventory(params); + ServiceInventoryAssertions.assertServiceInventoryFind(resource); + + } + + + @Test + public void testServiceInventoryFindWithoutParameter() throws Exception { + + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("relatedParty.id", "6490"); + + ResponseEntity resource = serviceInventoryResource.findServiceInventory(params); + ServiceInventoryAssertions.assertServiceInventoryFindWithoutParameter(resource); + + } + } diff --git a/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java b/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java new file mode 100644 index 0000000..e8afc9c --- /dev/null +++ b/src/test/java/org/onap/nbi/apis/resources/ServiceInventoryAssertions.java @@ -0,0 +1,88 @@ +package org.onap.nbi.apis.resources; + + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.ArrayList; +import java.util.LinkedHashMap; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ServiceInventoryAssertions { + + + + + public static void assertServiceInventoryGet(ResponseEntity resource) { + assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK); + LinkedHashMap service = (LinkedHashMap)resource.getBody(); + assertThat(service.get("id")).isEqualTo("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"); + assertThat(service.get("name")).isEqualTo("NewFreeRadius-service-instance-01"); + assertThat(service.get("hasStarted")).isEqualTo("yes"); + assertThat(service.get("type")).isEqualTo("service-instance"); + assertThat(service.get("@type")).isEqualTo("serviceONAP"); + LinkedHashMap relatedParty = (LinkedHashMap) service.get("relatedParty"); + assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer"); + assertThat(relatedParty.get("id")).isEqualTo("6490"); + LinkedHashMap serviceSpecification = (LinkedHashMap)service.get("serviceSpecification"); + assertThat(serviceSpecification.get("id")).isEqualTo("98d95267-5e0f-4531-abf8-f14b90031dc5"); + assertThat(serviceSpecification.get("invariantUUID")).isEqualTo("709d157b-52fb-4250-976e-7133dff5c347"); + assertThat(serviceSpecification.get("@type")).isEqualTo("ONAPservice"); + + + assertThat(((ArrayList)service.get("supportingResource")).size()).isEqualTo(2); + LinkedHashMap resource1 = (LinkedHashMap) ((ArrayList) service.get("supportingResource")).get(0); + assertThat(resource1.get("id")).isEqualTo("cb80fbb6-9aa7-4ac5-9541-e14f45de533e"); + assertThat(resource1.get("name")).isEqualTo("NewFreeRadius-VNF-instance-01"); + assertThat(resource1.get("status")).isEqualTo("PREPROV"); + assertThat(resource1.get("modelInvariantId")).isEqualTo("f5993703-977f-4346-a1c9-c1884f8cfd8d"); + assertThat(resource1.get("modelVersionId")).isEqualTo("902438f7-1e4c-492d-b7cc-8650e13b8aeb"); + assertThat(resource1.get("@referredType")).isEqualTo("ONAP resource"); + } + + + public static void assertServiceInventoryFind(ResponseEntity resource) { + assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK); + ArrayList body = (ArrayList)resource.getBody(); + assertThat(body.size()).isEqualTo(1); + LinkedHashMap service1 = (LinkedHashMap)body.get(0); + assertThat(service1.get("id")).isEqualTo("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"); + assertThat(service1.get("name")).isEqualTo("NewFreeRadius-service-instance-01"); + LinkedHashMap relatedParty = (LinkedHashMap) service1.get("relatedParty"); + assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer"); + assertThat(relatedParty.get("id")).isEqualTo("6490"); + LinkedHashMap serviceSpecification = (LinkedHashMap) service1.get("serviceSpecification"); + assertThat(serviceSpecification.get("name")).isEqualTo("vFW"); + assertThat(serviceSpecification.get("id")).isEqualTo("98d95267-5e0f-4531-abf8-f14b90031dc5"); + } + + + public static void assertServiceInventoryFindWithoutParameter(ResponseEntity resource) { + assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK); + ArrayList body = (ArrayList)resource.getBody(); + assertThat(body.size()).isEqualTo(2); + LinkedHashMap service1 = (LinkedHashMap)body.get(0); + assertThat(service1.get("id")).isEqualTo("vfw-service-id"); + assertThat(service1.get("name")).isEqualTo("vfw-service-name"); + LinkedHashMap relatedParty = (LinkedHashMap) service1.get("relatedParty"); + assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer"); + assertThat(relatedParty.get("id")).isEqualTo("6490"); + LinkedHashMap serviceSpecification = (LinkedHashMap) service1.get("serviceSpecification"); + assertThat(serviceSpecification.get("name")).isEqualTo("vFW-service-2VF-based"); + assertThat(serviceSpecification.get("id")).isEqualTo("9vfw-service-modek-version-id"); + + + LinkedHashMap service2 = (LinkedHashMap)body.get(1); + assertThat(service2.get("id")).isEqualTo("e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"); + assertThat(service2.get("name")).isEqualTo("NewFreeRadius-service-instance-01"); + relatedParty = (LinkedHashMap) service1.get("relatedParty"); + assertThat(relatedParty.get("role")).isEqualTo("ONAPcustomer"); + assertThat(relatedParty.get("id")).isEqualTo("6490"); + serviceSpecification = (LinkedHashMap) service2.get("serviceSpecification"); + assertThat(serviceSpecification.get("name")).isEqualTo("vFW"); + assertThat(serviceSpecification.get("id")).isEqualTo("98d95267-5e0f-4531-abf8-f14b90031dc5"); + + } + +} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 5d18ec8..f778b8a 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -4,10 +4,23 @@ server.port = 8080 # LOGGING logging.level.org.onap.nbi=DEBUG -logging.level.org.springframework.cloud.contract.wiremock=DEBUG + +# ONAP +onap.lcpCloudRegionId=RegionOne +onap.tenantId=31047205ce114b60833b23e400d6a535 +onap.cloudOwner=CloudOwner + +# NBI +nbi.url=http://127.0.0.1:8080/nbi/api/v1 # SDC sdc.host=http://127.0.0.1:8091 sdc.header.ecompInstanceId=Rene sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU= +# AAI +aai.host=http://127.0.0.1:8091 +aai.header.authorization=Basic QUFJOkFBSQ== +aai.api.id=AAI + + diff --git a/src/test/resources/mappings/aai_get_6490_service-subscriptions.json b/src/test/resources/mappings/aai_get_6490_service-subscriptions.json new file mode 100644 index 0000000..5582990 --- /dev/null +++ b/src/test/resources/mappings/aai_get_6490_service-subscriptions.json @@ -0,0 +1,24 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/6490/service-subscriptions" + }, + "response": { + "status": 200, + "jsonBody": { + "service-subscription": [ + { + "service-type": "vFW-service-2VF-based", + "resource-version": "1519809287769" + }, + { + "service-type": "vFW", + "resource-version": "1519660513613" + } + ] + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_customer_6490.json b/src/test/resources/mappings/aai_get_customer_6490.json new file mode 100644 index 0000000..eaf5a4b --- /dev/null +++ b/src/test/resources/mappings/aai_get_customer_6490.json @@ -0,0 +1,18 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/6490" + }, + "response": { + "status": 200, + "jsonBody": { + "global-customer-id": "6490", + "subscriber-name": "Jean Pontus", + "subscriber-type": "BSS", + "resource-version": "1518595364087" + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_customer_generic.json b/src/test/resources/mappings/aai_get_customer_generic.json new file mode 100644 index 0000000..250f5d6 --- /dev/null +++ b/src/test/resources/mappings/aai_get_customer_generic.json @@ -0,0 +1,18 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/generic" + }, + "response": { + "status": 200, + "jsonBody": { + "global-customer-id": "generic", + "subscriber-name": "generic", + "subscriber-type": "BSS", + "resource-version": "1518595364087" + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_generic_service-subscriptions.json b/src/test/resources/mappings/aai_get_generic_service-subscriptions.json new file mode 100644 index 0000000..5cf9ddd --- /dev/null +++ b/src/test/resources/mappings/aai_get_generic_service-subscriptions.json @@ -0,0 +1,20 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/generic/service-subscriptions" + }, + "response": { + "status": 200, + "jsonBody": { + "service-subscription": [ + { + "service-type": "vFW", + "resource-version": "1519660513613" + } + ] + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_service-subscription.json b/src/test/resources/mappings/aai_get_service-subscription.json new file mode 100644 index 0000000..03558a9 --- /dev/null +++ b/src/test/resources/mappings/aai_get_service-subscription.json @@ -0,0 +1,55 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/vFW/service-instances/service-instance/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb" + }, + "response": { + "status": 200, + "jsonBody": { + "service-instance-id": "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb", + "service-instance-name": "NewFreeRadius-service-instance-01", + "model-invariant-id": "709d157b-52fb-4250-976e-7133dff5c347", + "model-version-id": "98d95267-5e0f-4531-abf8-f14b90031dc5", + "resource-version": "1518508381261", + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/cb80fbb6-9aa7-4ac5-9541-e14f45de533e", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "cb80fbb6-9aa7-4ac5-9541-e14f45de533e" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "NewFreeRadius-VNF-instance-01" + } + ] + }, + { + "related-to": "generic-vnf", + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/cb80fbb6-9aa7-4ac5-9541-e14f45de533e", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "cb80fbb6-9aa7-4ac5-9541-e14f45de533e" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "NewFreeRadius-VNF-instance-01" + } + ] + } + ] + } + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_service-subscription_vnf.json b/src/test/resources/mappings/aai_get_service-subscription_vnf.json new file mode 100644 index 0000000..7c33979 --- /dev/null +++ b/src/test/resources/mappings/aai_get_service-subscription_vnf.json @@ -0,0 +1,58 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/network/generic-vnfs/generic-vnf/cb80fbb6-9aa7-4ac5-9541-e14f45de533e" + }, + "response": { + "status": 200, + "jsonBody": { + "vnf-id": "cb80fbb6-9aa7-4ac5-9541-e14f45de533e", + "vnf-name": "NewFreeRadius-VNF-instance-01", + "vnf-type": "NewFreeRadius-service/New-FreeRadius 0", + "service-id": "709d157b-52fb-4250-976e-7133dff5c347", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1516871905399", + "model-invariant-id": "f5993703-977f-4346-a1c9-c1884f8cfd8d", + "model-version-id": "902438f7-1e4c-492d-b7cc-8650e13b8aeb", + "model-customization-id": "a2def5c8-ab15-482b-a2cd-2af0b987300f", + "nf-type": "", + "nf-function": "", + "nf-role": "", + "nf-naming-code": "", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/Sina/service-subscriptions/service-subscription/NewFreeRadius-service/service-instances/service-instance/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Sina" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "NewFreeRadius-service" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "NewFreeRadius-service-instance-01" + } + ] + } + ] + } + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_service-subscriptionsVFW.json b/src/test/resources/mappings/aai_get_service-subscriptionsVFW.json new file mode 100644 index 0000000..093dd96 --- /dev/null +++ b/src/test/resources/mappings/aai_get_service-subscriptionsVFW.json @@ -0,0 +1,43 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/vFW/service-instances/" + }, + "response": { + "status": 200, + "jsonBody": { + "service-instance": [ + { + "service-instance-id": "e4688e5f-61a0-4f8b-ae02-a2fbde623bcb", + "service-instance-name": "NewFreeRadius-service-instance-01", + "model-invariant-id": "709d157b-52fb-4250-976e-7133dff5c347", + "model-version-id": "98d95267-5e0f-4531-abf8-f14b90031dc5", + "resource-version": "1518508381261", + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/cb80fbb6-9aa7-4ac5-9541-e14f45de533e", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "cb80fbb6-9aa7-4ac5-9541-e14f45de533e" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "NewFreeRadius-VNF-instance-01" + } + ] + } + ] + } + } + ] + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_service-subscriptionsvFW-service-2VF-based.json b/src/test/resources/mappings/aai_get_service-subscriptionsvFW-service-2VF-based.json new file mode 100644 index 0000000..444e3cd --- /dev/null +++ b/src/test/resources/mappings/aai_get_service-subscriptionsvFW-service-2VF-based.json @@ -0,0 +1,43 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/vFW-service-2VF-based/service-instances/" + }, + "response": { + "status": 200, + "jsonBody": { + "service-instance": [ + { + "service-instance-id": "vfw-service-id", + "service-instance-name": "vfw-service-name", + "model-invariant-id": "vfw-service-invariant-id", + "model-version-id": "9vfw-service-modek-version-id", + "resource-version": "1518508381261", + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/cb80fbb6-9aa7-4ac5-9541-e14f45de533e", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "cb80fbb6-9aa7-4ac5-9541-e14f45de533e" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "NewFreeRadius-VNF-instance-01" + } + ] + } + ] + } + } + ] + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_get_tenants.json b/src/test/resources/mappings/aai_get_tenants.json new file mode 100644 index 0000000..7581a91 --- /dev/null +++ b/src/test/resources/mappings/aai_get_tenants.json @@ -0,0 +1,167 @@ +{ + "request": { + "method": "GET", + "url": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants" + }, + "response": { + "status": 200, + "jsonBody": { + + "tenant": [ + { + "tenant-id": "31047205ce114b60833b23e400d6a535", + "tenant-name": "onap-vnfs", + "resource-version": "1516022902124", + "relationship-list": { + "relationship": [ + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/OPL-User/service-subscriptions/service-subscription/OPL_FWtest1_service_type", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "OPL-User" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "OPL_FWtest1_service_type" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/Sina/service-subscriptions/service-subscription/NewFreeRadius-service", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Sina" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "NewFreeRadius-service" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/Sina/service-subscriptions/service-subscription/vMRFaaS3", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Sina" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vMRFaaS3" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/Sina/service-subscriptions/service-subscription/FreeRadius-service", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Sina" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "FreeRadius-service" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/6401/service-subscriptions/service-subscription/vFW-service-model", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "6401" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFW-service-model" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/Sina/service-subscriptions/service-subscription/vFW-service-model", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Sina" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFW-service-model" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/6404/service-subscriptions/service-subscription/vFW-service-model", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "6404" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFW-service-model" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/6405/service-subscriptions/service-subscription/vFW-service-model", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "6405" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFW-service-model" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/6406/service-subscriptions/service-subscription/vFW-service-model", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "6406" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFW-service-model" + } + ] + }, + { + "related-to": "service-subscription", + "related-link": "/aai/v11/business/customers/customer/Sina/service-subscriptions/service-subscription/serviceFRDBS", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Sina" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "serviceFRDBS" + } + ] + } + ] + } + } + ] + + }, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_put_customer.json b/src/test/resources/mappings/aai_put_customer.json new file mode 100644 index 0000000..ec28b72 --- /dev/null +++ b/src/test/resources/mappings/aai_put_customer.json @@ -0,0 +1,12 @@ +{ + "request": { + "method": "PUT", + "url": "/aai/v11/business/customers/customer/new" + }, + "response": { + "status": 201, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file diff --git a/src/test/resources/mappings/aai_put_customer_service.json b/src/test/resources/mappings/aai_put_customer_service.json new file mode 100644 index 0000000..889627a --- /dev/null +++ b/src/test/resources/mappings/aai_put_customer_service.json @@ -0,0 +1,12 @@ +{ + "request": { + "method": "PUT", + "url": "/aai/v11/business/customers/customer/new/service-subscriptions/service-subscription/vFW" + }, + "response": { + "status": 201, + "headers": { + "Content-Type": "application/json" + } + } +} \ No newline at end of file -- cgit 1.2.3-korg