adapt NBI to Beijing 07/56007/1
authorromaingimbert <romain.gimbert@orange.com>
Mon, 9 Jul 2018 09:46:10 +0000 (11:46 +0200)
committerromaingimbert <romain.gimbert@orange.com>
Mon, 9 Jul 2018 09:46:10 +0000 (11:46 +0200)
-change SO Url to "v6"
-add xtransactionid in AAI request header
-add fields Project and OwningEntity in SO request
-fix tests

Change-Id: I014e8731079134dae8754900b00f71f48dd530aa
Issue-ID: EXTAPI-117
Signed-off-by: romaingimbert <romain.gimbert@orange.com>
14 files changed:
src/main/java/org/onap/nbi/OnapComponentsUrlPaths.java
src/main/java/org/onap/nbi/apis/serviceinventory/AaiClient.java
src/main/java/org/onap/nbi/apis/serviceinventory/BaseClient.java
src/main/java/org/onap/nbi/apis/serviceorder/MultiClient.java
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/OwningEntity.java [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/Project.java [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestDetails.java
src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
src/main/resources/application.properties
src/test/java/org/onap/nbi/apis/ApiTest.java
src/test/resources/application.properties
src/test/resources/mappings/so_delete_service_instance.json
src/test/resources/mappings/so_get_.json
src/test/resources/mappings/so_post_create_service_instance.json

index 67c72e3..69cc5be 100644 (file)
@@ -42,7 +42,7 @@ public final class OnapComponentsUrlPaths {
             "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/";
 
     // MSO
-    public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstances/v4";
-    public static final String MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v4/";
-    public static final String MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/v4/";
+    public static final String MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstances/v6";
+    public static final String MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v6/";
+    public static final String MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/v6/";
 }
index 5cd4c35..a09917c 100644 (file)
@@ -41,9 +41,13 @@ public class AaiClient extends BaseClient {
     @Value("${aai.api.id}")
     private String aaiApiId;
 
+    @Value("${aai.header.transaction.id}")
+    private String aaiTransactionId;
+
     private static final String HEADER_AUTHORIZATION = "Authorization";
     private static final String X_FROM_APP_ID = "X-FromAppId";
     private static final Logger LOGGER = LoggerFactory.getLogger(AaiClient.class);
+    private static final String X_TRANSACTION_ID = "X-TransactionId";
 
     private HttpHeaders buildRequestHeaderForAAI() {
 
@@ -52,6 +56,8 @@ public class AaiClient extends BaseClient {
         httpHeaders.add(X_FROM_APP_ID, aaiApiId);
         httpHeaders.add("Accept", "application/json");
         httpHeaders.add("Content-Type", "application/json");
+        httpHeaders.add(X_TRANSACTION_ID, aaiTransactionId);
+
         return httpHeaders;
 
     }
index c973f32..68e4aea 100644 (file)
@@ -34,6 +34,10 @@ public abstract class BaseClient {
 
     protected ResponseEntity<Object> callApiGet(String callURL, HttpHeaders httpHeaders) {
 
+        if(LOGGER.isDebugEnabled()){
+            LOGGER.debug("log request : "+callURL+ " "+httpHeaders);
+        }
+
         ResponseEntity<Object> response = restTemplate.exchange(callURL, HttpMethod.GET,
                 new HttpEntity<>("parameters", httpHeaders), Object.class);
         LOGGER.debug("response body : " + response.getBody().toString());
index a7e3356..ccf6423 100644 (file)
@@ -61,6 +61,9 @@ public class MultiClient {
     @Value("${onap.cloudOwner}")
     private String cloudOwner;
 
+    @Value("${aai.header.transaction.id}")
+    private String aaiTransactionId;
+
     @Autowired
     private ServiceCatalogUrl serviceCatalogUrl;
 
@@ -70,6 +73,7 @@ public class MultiClient {
 
     private static final String HEADER_AUTHORIZATION = "Authorization";
     private static final String X_FROM_APP_ID = "X-FromAppId";
+    private static final String X_TRANSACTION_ID = "X-TransactionId";
 
     private static final Logger LOGGER = LoggerFactory.getLogger(MultiClient.class);
 
@@ -99,6 +103,8 @@ public class MultiClient {
         httpHeaders.add(X_FROM_APP_ID, aaiApiId);
         httpHeaders.add("Accept", "application/json");
         httpHeaders.add("Content-Type", "application/json");
+        httpHeaders.add(X_TRANSACTION_ID, aaiTransactionId);
+
         return httpHeaders;
     }
 
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/OwningEntity.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/OwningEntity.java
new file mode 100644 (file)
index 0000000..fb80d2d
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ *     Copyright (c) 2018 Orange
+ *
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ */
+package org.onap.nbi.apis.serviceorder.model.consumer;
+
+public class OwningEntity {
+
+    private String owningEntityId;
+    private String owningEntityName;
+
+    public String getOwningEntityId() {
+        return owningEntityId;
+    }
+
+    public void setOwningEntityId(String owningEntityId) {
+        this.owningEntityId = owningEntityId;
+    }
+
+    public String getOwningEntityName() {
+        return owningEntityName;
+    }
+
+    public void setOwningEntityName(String owningEntityName) {
+        this.owningEntityName = owningEntityName;
+    }
+}
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/Project.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/Project.java
new file mode 100644 (file)
index 0000000..fca5391
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ *     Copyright (c) 2018 Orange
+ *
+ *     Licensed under the Apache License, Version 2.0 (the "License");
+ *     you may not use this file except in compliance with the License.
+ *     You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ */
+package org.onap.nbi.apis.serviceorder.model.consumer;
+
+public class Project {
+
+    private String projectName;
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+}
index da5b1ad..2354b39 100644 (file)
@@ -27,6 +27,25 @@ public class RequestDetails {
 
     private CloudConfiguration cloudConfiguration;
 
+    private OwningEntity owningEntity;
+
+    private Project project;
+
+    public Project getProject() {
+        return project;
+    }
+
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    public OwningEntity getOwningEntity() {
+        return owningEntity;
+    }
+
+    public void setOwningEntity(OwningEntity owningEntity) {
+        this.owningEntity = owningEntity;
+    }
 
     public CloudConfiguration getCloudConfiguration() {
         return cloudConfiguration;
index 24e137b..dde740f 100644 (file)
@@ -48,6 +48,15 @@ public class SOTaskProcessor {
     @Value("${onap.tenantId}")
     private String tenantId;
 
+    @Value("${so.owning.entity.id}")
+    private String soOwningEntityId;
+
+    @Value("${so.owning.entity.name}")
+    private String soOwningEntityName;
+
+    @Value("${so.project.name}")
+    private String soProjectName;
+
     @Autowired
     private ServiceOrderRepository serviceOrderRepository;
 
@@ -275,6 +284,17 @@ public class SOTaskProcessor {
 
         CloudConfiguration cloudConfiguration = new CloudConfiguration(lcpCloudRegionId, tenantId);
         requestDetails.setCloudConfiguration(cloudConfiguration);
+
+        OwningEntity owningEntity = new OwningEntity();
+        owningEntity.setOwningEntityId(soOwningEntityId);
+        owningEntity.setOwningEntityName(soOwningEntityName);
+        requestDetails.setOwningEntity(owningEntity);
+
+        Project project = new Project();
+        project.setProjectName(soProjectName);
+
+        requestDetails.setProject(project);
+
         return requestDetails;
     }
 
index 4e45084..7c9975f 100644 (file)
@@ -38,12 +38,16 @@ sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2Y
 # AAI
 aai.host=https://10.0.1.1:8443
 aai.header.authorization=Basic QUFJOkFBSQ==
-aai.api.id=AAI
+aai.api.id=NBI
+aai.header.transaction.id=808b54e3-e563-4144-a1b9-e24e2ed93d4f
 
 # SO
 so.host=http://10.0.5.1:8080
 so.header.authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
 so.api.id=SO
+so.owning.entity.id=6b5b6b70-4e9a-4f6f-8b7b-cbd7cf990c6e
+so.owning.entity.name=OE-generic
+so.project.name=Project-generic
 
 # MONGO
 spring.data.mongodb.host=localhost
index a650ab5..20cdb96 100644 (file)
@@ -674,7 +674,7 @@ public class ApiTest {
         ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
             executionTaskRepository, ActionType.ADD);
 
-        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v4/requestId");
+        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v6/requestId");
 
 
         SoTaskProcessor.processOrderItem(executionTaskA);
@@ -716,7 +716,7 @@ public class ApiTest {
         ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
              executionTaskRepository, ActionType.ADD);
 
-        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v4");
+        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v6");
 
 
         SoTaskProcessor.processOrderItem(executionTaskA);
@@ -738,8 +738,8 @@ public class ApiTest {
         ExecutionTask executionTaskA = ServiceOrderAssertions.setUpBddForExecutionTaskSucess(serviceOrderRepository,
             executionTaskRepository, ActionType.ADD);
 
-        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v4");
-        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v4/requestId");
+        removeWireMockMapping("/ecomp/mso/infra/serviceInstances/v6");
+        removeWireMockMapping("/ecomp/mso/infra/orchestrationRequests/v6/requestId");
 
 
         SoTaskProcessor.processOrderItem(executionTaskA);
index f6df654..1361d42 100644 (file)
@@ -39,11 +39,15 @@ sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2Y
 aai.host=http://127.0.0.1:8091
 aai.header.authorization=Basic QUFJOkFBSQ==
 aai.api.id=AAI
+aai.header.transaction.id=808b54e3-e563-4144-a1b9-e24e2ed93d4f
 
 # SO
 so.host=http://127.0.0.1:8091
 so.header.authorization=
 so.api.id=SO
+so.owning.entity.id=6b5b6b70-4e9a-4f6f-8b7b-cbd7cf990c6e
+so.owning.entity.name=OE-generic
+so.project.name=Project-generic
 
 # H2
 spring.datasource.url=jdbc:h2:mem:~/db;DB_CLOSE_ON_EXIT=false
index b294d0b..141b877 100644 (file)
@@ -1,7 +1,7 @@
 {
     "request": {
         "method": "DELETE",
-        "url": "/ecomp/mso/infra/serviceInstances/v4/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"
+        "url": "/ecomp/mso/infra/serviceInstances/v6/e4688e5f-61a0-4f8b-ae02-a2fbde623bcb"
     },
     "response": {
         "status": 202,
index 5d4148f..6fc9c9c 100644 (file)
@@ -1,7 +1,7 @@
 {
     "request": {
         "method": "GET",
-        "url": "/ecomp/mso/infra/orchestrationRequests/v4/requestId"
+        "url": "/ecomp/mso/infra/orchestrationRequests/v6/requestId"
     },
     "response": {
         "status": 200,
index f5aaa90..7724860 100644 (file)
@@ -1,7 +1,7 @@
 {
     "request": {
         "method": "POST",
-        "url": "/ecomp/mso/infra/serviceInstances/v4"
+        "url": "/ecomp/mso/infra/serviceInstances/v6"
     },
     "response": {
         "status": 201,