summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorromaingimbert <romain.gimbert@orange.com>2018-09-07 10:53:31 +0200
committerromaingimbert <romain.gimbert@orange.com>2018-09-07 10:53:31 +0200
commitbeb712f922ca903674844c3370424fc14330164e (patch)
tree909e0969e0940d8e8121e3cc7c3bc610c4183d2b
parent2ede3ffbcb422795d0d3a733dbe60228ad0ace0d (diff)
state attribute for ServiceInventory
-change jolt mapping to add field state -manage when no VNF found -add test Change-Id: I68d885678aab031176a130349b2fb73838fff683 Issue-ID: EXTAPI-134 Signed-off-by: romaingimbert <romain.gimbert@orange.com>
-rw-r--r--src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java11
-rw-r--r--src/main/resources/jolt/getServiceInventory.json1
-rw-r--r--src/test/java/org/onap/nbi/apis/ApiTest.java16
-rw-r--r--src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json52
4 files changed, 76 insertions, 4 deletions
diff --git a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
index a09917c..b9afe64 100644
--- a/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
+++ b/src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
@@ -81,10 +81,13 @@ public class AaiClient extends BaseClient {
public Map getVNF(String relatedLink) {
StringBuilder callURL = new StringBuilder().append(aaiHost).append(relatedLink);
-
- ResponseEntity<Object> response = callApiGet(callURL.toString(), buildRequestHeaderForAAI());
- return (LinkedHashMap) response.getBody();
-
+ try{
+ ResponseEntity<Object> response = callApiGet(callURL.toString(), buildRequestHeaderForAAI());
+ return (LinkedHashMap) response.getBody();
+ } catch (BackendFunctionalException e) {
+ LOGGER.error("error on calling {} , {}" , callURL.toString(), e);
+ return null;
+ }
}
public Map getServicesInAaiForCustomer(String customerId) {
diff --git a/src/main/resources/jolt/getServiceInventory.json b/src/main/resources/jolt/getServiceInventory.json
index df4f14c..cb75530 100644
--- a/src/main/resources/jolt/getServiceInventory.json
+++ b/src/main/resources/jolt/getServiceInventory.json
@@ -4,6 +4,7 @@
"spec": {
"service-instance-id": "id",
"service-instance-name": "name",
+ "orchestration-status": "state",
"model-version-id" : "serviceSpecification.id",
"model-invariant-id": "serviceSpecification.invariantUUID",
"vnfs" : {
diff --git a/src/test/java/org/onap/nbi/apis/ApiTest.java b/src/test/java/org/onap/nbi/apis/ApiTest.java
index ad4a956..4d24062 100644
--- a/src/test/java/org/onap/nbi/apis/ApiTest.java
+++ b/src/test/java/org/onap/nbi/apis/ApiTest.java
@@ -24,6 +24,7 @@ import com.github.tomakehurst.wiremock.stubbing.ListStubMappingsResult;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
import java.util.ArrayList;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;
import javax.validation.Validation;
@@ -208,6 +209,21 @@ public class ApiTest {
}
@Test
+ public void testServiceResourceGetInventoryWithStatus() throws Exception {
+
+ String serviceName = "AnsibleService";
+ String serviceId = "405c8c00-44b9-4303-9f27-6797d22ca096";
+ MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+ params.add("serviceSpecification.name", serviceName);
+ params.add("relatedParty.id", "6490");
+ ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params);
+ LinkedHashMap service = (LinkedHashMap) resource.getBody();
+ assertThat(service.get("state")).isEqualTo("Active");
+
+
+ }
+
+ @Test
public void testServiceResourceGetInventoryWithoutRelationShipList() throws Exception {
String serviceName = "vFW";
diff --git a/src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json b/src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json
new file mode 100644
index 0000000..10bcac8
--- /dev/null
+++ b/src/test/resources/mappings/aai_get_service-subscription-Ansible-service.json
@@ -0,0 +1,52 @@
+{
+ "request": {
+ "method": "GET",
+ "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/AnsibleService/service-instances/service-instance/405c8c00-44b9-4303-9f27-6797d22ca096"
+ },
+ "response": {
+ "status": 200,
+ "jsonBody": {
+ "service-instance-id": "405c8c00-44b9-4303-9f27-6797d22ca096",
+ "service-instance-name": "ansibleService-service-instance-065FYE",
+ "environment-context": "General_Revenue-Bearing",
+ "workload-context": "Production",
+ "model-invariant-id": "f3ec9092-5c98-41f1-9fea-96be80abd064",
+ "model-version-id": "0bf5f56a-4506-4e98-ab50-336d73ca4b07",
+ "resource-version": "1530200875713",
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "generic-vnf",
+ "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/3f73377f-d9be-4a33-b068-e3f35b5b770b",
+ "relationship-data": [
+ {
+ "relationship-key": "generic-vnf.vnf-id",
+ "relationship-value": "3f73377f-d9be-4a33-b068-e3f35b5b770b"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "generic-vnf.vnf-name",
+ "property-value": "ansibleService-vnf-instance-DebianVNF_0_065FYE"
+ }
+ ]
+ },
+ {
+ "related-to": "owning-entity",
+ "related-link": "/aai/v11/business/owning-entities/owning-entity/OE-generic",
+ "relationship-data": [
+ {
+ "relationship-key": "owning-entity.owning-entity-id",
+ "relationship-value": "OE-generic"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+} \ No newline at end of file