Merge "fix NPE SO Response"
authorMatthieu Geerebaert <matthieu.geerebaert@orange.com>
Mon, 23 Apr 2018 14:48:49 +0000 (14:48 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 23 Apr 2018 14:48:49 +0000 (14:48 +0000)
18 files changed:
docs/administration/administration.rst [new file with mode: 0644]
docs/architecture/architecture.rst [new file with mode: 0644]
docs/configuration/configuration.rst [new file with mode: 0644]
docs/consumedapis/consumedapis.rst [new file with mode: 0644]
docs/delivery/delivery.rst [new file with mode: 0644]
docs/humaninterfaces/humaninterfaces.rst [new file with mode: 0644]
docs/index.rst
docs/installation/installation.rst [new file with mode: 0644]
docs/logging/logging.rst [new file with mode: 0644]
docs/offeredapis/offeredapis.rst [new file with mode: 0644]
docs/releasenotes/releasenotes.rst [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java [new file with mode: 0644]
src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/RequestInfo.java
src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java
src/test/java/org/onap/nbi/apis/ApiTest.java
src/test/java/org/onap/nbi/apis/assertions/ServiceInventoryAssertions.java
src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json [new file with mode: 0644]

diff --git a/docs/administration/administration.rst b/docs/administration/administration.rst
new file mode 100644 (file)
index 0000000..7abffd2
--- /dev/null
@@ -0,0 +1,17 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Administration
+==============
+
+no specific administration defined in the current release
+
+Processes
+---------
+
+
+Actions
+-------
+
diff --git a/docs/architecture/architecture.rst b/docs/architecture/architecture.rst
new file mode 100644 (file)
index 0000000..b777f0f
--- /dev/null
@@ -0,0 +1,34 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Architecture
+============
+
+***************
+Introduction
+***************
+
+
+NBI stands for NorthBound Interface. It brings to ONAP a set of API that can be used by external systems as BSS for example. These API are based on **TMF API**.
+
+
+***************
+Global NBI architecture for Beijing release
+***************
+
+Following illustration provides a global view about nbi architecture,integration with other ONAP components and API resource/operation provided.
+
+.. image:: images/ONAP_External_ID_Beijing.jpg
+   :width: 800px
+
+
+***************
+Developer Guide
+***************
+
+Technical information about NBI (dependancies, configuration, running & testing) could be found here: :doc:`NBI_R1_Developer_Guide <../NBI_R1_Developer_Guide>`
+
+API Flow illustration (with example messages) is described in this document: :download:`nbicallflow.pdf <pdf/nbicallflow.pdf>`
+
diff --git a/docs/configuration/configuration.rst b/docs/configuration/configuration.rst
new file mode 100644 (file)
index 0000000..ba586aa
--- /dev/null
@@ -0,0 +1,84 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Configuration
+=============
+
+A configuration file, *src/main/resources/application-localhost.properties* list all the component interface that can be configured depending on the environment were the app is deployed.
+By default, the application runs with an embedded both MongoDB and MariaDB local instance.
+This file also list configurations of all the REST interface maid from NBI to other ONAP component such as SDC, AA&I and SO.
+
+
+Default values
+==============
+
+**SERVER**
+
+server.contextPath=/nbi/api/v1
+server.port = 8080
+
+**LOGGING**
+
+logging.level.=INFO
+
+**ONAP**
+
+onap.lcpCloudRegionId=RegionOne
+onap.tenantId=6e97a2bd51d74f6db5671d8dc1517d82
+onap.cloudOwner=CloudOwner
+
+**NBI**
+
+nbi.url=http://localhost:8080/nbi/api/v1
+nbi.callForVNF=false
+
+**SDC**
+
+sdc.host=http://10.0.3.1:8080
+sdc.header.ecompInstanceId=demo
+sdc.header.authorization=Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU=
+
+**AAI**
+
+aai.host=https://10.0.1.1:8443
+aai.header.authorization=Basic QUFJOkFBSQ==
+aai.api.id=AAI
+
+**SO**
+
+so.host=http://10.0.5.1:8080
+so.header.authorization=Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
+so.api.id=SO
+
+**MONGO**
+
+spring.data.mongodb.host=localhost
+spring.data.mongodb.port=27017
+spring.data.mongodb.database=ServiceOrderDB
+
+**MYSQL**
+
+spring.datasource.url=jdbc:mariadb://localhost:3306/nbi
+spring.datasource.username=root
+spring.datasource.password=secret
+spring.datasource.testWhileIdle=true
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
+spring.jpa.show-sql=false
+spring.jpa.hibernate.ddl-auto=update
+spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
+
+
+Changing values
+===============
+
+To adapt application parameters to your context, you need to set up some environment attributes. For example :
+
+
+      SPRING_DATASOURCE_PASSWORD: your own value here
+      SPRING_DATASOURCE_USERNAME: your own value here
+      SDC_HOST: http://${SDC_IP}:8080
+      AAI_HOST: https://${AAI_IP}:8443
+      SO_HOST: http://${SO_IP}:8080
diff --git a/docs/consumedapis/consumedapis.rst b/docs/consumedapis/consumedapis.rst
new file mode 100644 (file)
index 0000000..6962e02
--- /dev/null
@@ -0,0 +1,51 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Consumed APIs
+=============
+
+
+NBI application is interacting with 3 ONAP APIs
+
+***************
+SDC API
+***************
+
+this API is used to provide Service Catalog information
+Information are retrieved in SDC (and in Tosca "service template" file) - Only GET operation is provided - this API DID NOT UPDATE SDC
+
+    SDC_ROOT_URL = "/sdc/v1/catalog/services/";
+    SDC_GET_PATH = "/metadata";
+    SDC_TOSCA_PATH = "/toscaModel";
+
+***************
+AAI API
+***************
+
+this API is used to provide Service Inventory information
+This API retrieves service(s) in the AAI inventory. Only following attributes will be retrieve in service inventory: id, name and type (no state or startDate available )
+
+    AAI_GET_TENANTS_PATH = "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/$onap.cloudOwner/$onap.lcpCloudRegionId/tenants";
+    AAI_GET_CUSTOMER_PATH = "/aai/v11/business/customers/customer/";
+    AAI_GET_SERVICES_FOR_CUSTOMER_PATH =
+            "/aai/v11/business/customers/customer/$customerId/service-subscriptions";
+    AAI_PUT_SERVICE_FOR_CUSTOMER_PATH =
+            "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/";
+    AAI_GET_SERVICE_FOR_CUSTOMER_PATH =
+            "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/service-instance/$serviceId";
+    AAI_GET_SERVICE_INSTANCES_PATH =
+            "/aai/v11/business/customers/customer/$customerId/service-subscriptions/service-subscription/$serviceSpecName/service-instances/";
+
+
+***************
+SO API
+***************
+
+this API is used to perform Service Order and thus instantiate a service
+
+
+    MSO_CREATE_SERVICE_INSTANCE_PATH = "/ecomp/mso/infra/serviceInstance/v4";
+    MSO_GET_REQUEST_STATUS_PATH = "/ecomp/mso/infra/orchestrationRequests/v4/";
+    MSO_DELETE_REQUEST_STATUS_PATH = "/ecomp/mso/infra/serviceInstances/";
diff --git a/docs/delivery/delivery.rst b/docs/delivery/delivery.rst
new file mode 100644 (file)
index 0000000..7ef857a
--- /dev/null
@@ -0,0 +1,9 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Delivery
+========
+
+
diff --git a/docs/humaninterfaces/humaninterfaces.rst b/docs/humaninterfaces/humaninterfaces.rst
new file mode 100644 (file)
index 0000000..16f1835
--- /dev/null
@@ -0,0 +1,11 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Human Interfaces
+================
+
+no Human Interface (pure Rest API project)
+
+Any "Rest Client" application may be used (Postman, ...) to interact with NBI application.
index e39fb0d..2315c73 100644 (file)
@@ -8,4 +8,13 @@ ONAP ExternalAPI / NBI
 .. toctree::
    :maxdepth: 1
 
-   offeredapis/NBI_R1_interface.rst
+   architecture/architecture.rst
+   offeredapis/offeredapis.rst
+   consumedapis/consumedapis.rst
+   delivery/delivery.rst
+   logging/logging.rst
+   installation/installation.rst
+   configuration/configuration.rst
+   administation/administration.rst
+   humaninterfaces/humaninterfaces.rst
+   releasenotes/releasenotes.rst
diff --git a/docs/installation/installation.rst b/docs/installation/installation.rst
new file mode 100644 (file)
index 0000000..bb392d3
--- /dev/null
@@ -0,0 +1,45 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Installation
+============
+
+
+
+Environment
+-----------
+
+**Locally**
+
+Ensure that you have a MongoDB and MariaDB instance running and properly configured in *application.properties* file.
+Run *Application.java* class in your favorite IDE
+
+Or through a terminal, ensure that your maven installation is works and run *mvn spring-boot:run* command to start the appication.
+
+
+**Docker**
+
+Requirements: `Docker engine <https://docs.docker.com/engine/>`_ and `docker-compose <https://docs.docker.com/compose/>`_.
+
+To start the application:
+    1. Generate the application .jar file: `$ mvn clean package`
+    2. Configure the **.env** file
+    3. Start the *MariaDB* and *MongoDB* services: `$ docker-compose up -d mongo mariadb`
+    4. Build and start the *NBI* service: `$ docker-compose up --build -d nbi`
+
+You can view the log output of the application with the following command:
+
+`$ docker-compose logs -f nbi`
+
+
+Steps
+-----
+
+**Testing**
+When the app is running, you can access the API at http://yourhostname:8080/nbi/api/v1/ and fill the url with the name of the resources you asking for (/serviceSpecification, /service, /serviceOrder or /status)
+You can run a test by using `VisualStudio RestClient plugin <https://github.com/Huachao/vscode-restclient>`_
+See the *restclient* package at root level to find *.vscode/settings.json* configuration file and */json/* package with samples requests that can be run.
+You can also trigger these endpoints with any RESTful client or automation framework.
+
diff --git a/docs/logging/logging.rst b/docs/logging/logging.rst
new file mode 100644 (file)
index 0000000..724df74
--- /dev/null
@@ -0,0 +1,19 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Logging
+=======
+
+NBI application is using MongoDB and MariaDB databases.
+
+
+Where to Access Information
+---------------------------
+
+mongodb and Mariadb are accessible inside there respective docker container
+
+
+Error / Warning Messages
+------------------------
diff --git a/docs/offeredapis/offeredapis.rst b/docs/offeredapis/offeredapis.rst
new file mode 100644 (file)
index 0000000..9a264ff
--- /dev/null
@@ -0,0 +1,194 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Offered APIs
+============
+***************
+Introduction
+***************
+
+NBI stands for NorthBound Interface. It brings to ONAP a set of API that can be used by external systems as BSS for example. These API are based on **TMF API**.
+
+***************
+Global NBI architecture for Beijing release
+***************
+
+Following illustration provides a global view about nbi architecture,integration with other ONAP components and API resource/operation provided.
+
+.. image:: images/ONAP_External_ID_Beijing.jpg
+   :width: 800px
+
+***************
+API Version
+***************
+
+APIs are described with a  state version with “v” following the API Name, e.g.:  nbi/api/v1/productOrder.
+The schema associated with a REST API must have its version number aligned with that of the REST API.
+
+The version number has major, minor and revision numbers. E.g. v1.0.0
+The version number (without the revision number) is held in the URI.
+
+The major version number is incremented for an incompatible change.
+The minor version number is incremented for a compatible change.
+For minor modifications of the API, version numbering must not be updated, provided the following  backward compatibility rules are respected:
+
+- New elements in a data type must be optional (minOccurs=0)
+- Changes in the cardinality of an attribute in a data type must be from mandatory to optional or from lower to greater
+- New attributes defined in an element must be optional (absence of use=”required”).
+- If new enumerated values are included, the former ones and its meaning must be kept.
+- If new operations are added, the existing operations must be kept
+- New parameters added to existing operations must be optional and existing parameters
+must be kept
+
+For major modifications of the API, not backward compatible and forcing client implementations to be changed, the version number must be updated.
+
+***************
+API Table
+***************
+
+.. |pdf-icon| image:: images/pdf.png
+              :width: 40px
+
+.. |swagger-icon| image:: images/swagger.png
+                  :width: 40px
+
+
+.. |swaggerUI-icon| image:: images/swaggerUI.png
+                    :width: 40px
+
+.. |html-icon| image:: images/html.png
+               :width: 40px
+
+.. |plantuml-icon| image:: images/uml.jpg
+                  :width: 40px
+
+.. |postman-icon| image:: images/postman.png
+                  :width: 40px
+
+.. csv-table::
+   :header: "API", "|swagger-icon|", "|html-icon|", "|plantuml-icon|", "|swagger-icon|", "|postman-icon|", "|pdf-icon|"
+   :widths: 10,5,5,5,5,5,5
+
+   " ", "json file", "html doc", "plantUML doc", "Swagger Editor", "Postman Collection", "pdf doc"
+   "serviceCatalog", ":download:`link <swaggers/serviceCatalog_1_0_0.json>`", ":download:`link <serviceCatalog/documentation.html>`", ":download:`link <serviceCatalog/apiServiceCatalog.plantuml>`", "`link <http://editor2.swagger.io/?url=http://onap.readthedocs.io/en/latest/_downloads/serviceCatalog_1_0_0.json>`_", "coming", "coming"
+   "serviceInventory", ":download:`link <swaggers/serviceInventory_1_0_0.json>`", ":download:`link <serviceInventory/documentation.html>`", ":download:`link <serviceInventory/apiServiceInventory.plantuml>`", "`link <http://editor2.swagger.io/?url=http://onap.readthedocs.io/en/latest/_downloads/serviceInventory_1_0_0.json>`_", "coming", "coming"
+   "serviceOrder", ":download:`link <swaggers/serviceOrder_1_0_0.json>`", ":download:`link <serviceOrder/documentation.html>`", ":download:`link <serviceOrder/apiServiceOrder.plantuml>`", "`link <http://editor2.swagger.io/?url=http://onap.readthedocs.io/en/latest/_downloads/serviceOrder_1_0_0.json>`_", ":download:`link <postman/ONAPBeijingServiceOrderDoc.postman_collection.json>`", "coming"
+
+
+***************
+API Description
+***************
+
+**serviceCatalog:**
+
+From TMF633 serviceCatalog
+
+API at a glance:
+Only high level information are provided - swagger is documented.
+
+Only serviceSpecification resource is provided.
+Information are retrieved in SDC (and in Tosca file) - Only GET operation is provided - this API DID NOT UPDATE SDC
+
+Only characteristics at service level will be retrieved in ONAP Tosca file. For example if an ONAP service is composed of VNF and the VF module, the serviceSpecification resource will only feature characteristic describe in the ONAP service tosca model and not attributes in the tosca files for VNF or VF module.
+
+Only ‘basic’ service characteristics will be managed in this release. By ‘basic’ we mean string, boolean, integer parameter type and we do not manage ‘map’ or ‘list parameter type
+
+
+GET serviceSpecification(list)
+
+(example: GET /nbi/api/v1/serviceSpecification/?category=NetworkService&distributionStatus =DISTRIBUTED)
+
+It is possible to retrieve a list of serviceSpecification (get by list).
+
+Only attributes category and distributionStatus are available for serviceSpecification filtering. It is possible to select retrieved attributes using fields attribute.
+
+if no serviceSpecification matches, an empty list is send back.
+
+GET service Specification (id)
+
+(example: GET /nbi/api/v1/serviceSpecification/{uuid})
+
+It is use to retrieve one serviceSpecification - all available information are retieved (see swagger for description)
+
+
+**serviceInventory:**
+
+From TMF638 serviceInventory
+
+API at a glance:
+Only high level information are provided - swagger is documented.
+
+This API retrieves service(s) in the AAI inventory. Only following attributes will be retrieve in service inventory: id, name and type (no state or startDate available )
+
+GET Service Inventory (list):
+
+(example: GET /nbi/api/v1/service/?relatedParty.id=Pontus
+)
+
+GET (by list) allows to request with following criteria (all optional) :
+
+*   id (id of the service instance) - id of the service instance (inventory)
+*   serviceSpecification.id - id of the service specification (catalog)
+*   serviceSpecification.name - name of the service specification (catalog)
+*   relatedParty.id - id of the (aai) customer - if not filled we use ‘generic’ customer
+
+if no service matches, an empty list is send back.
+
+1.     If a request is send without any parameter, we’ll retrieve the list of service-instance for the ‘generic’ customer
+2.     If only customer parameter is filled (relatedParty.id + role= relatedParty’ONAPcustomer’) we’ll retrieve the list of service-instance for this customer
+3.     If serviceSpecification.id or name is filled we’ll retrieve the list of Service instance (from this service specification) – We’ll use the customer id if provided (with Role=’ONAPcustomer) or generic if no customer id provided
+
+
+GET Service Inventory (id):
+
+(example: GET /nbi/api/v1/service/{uuid} but customerId & serviceSpecification.id must passed in requested parameters)
+
+
+Because of AAI capability, additionally to the service id, customer id and [serviceSpecification.id or serviceSpecification.name] must be supplied. If the customer id is not supplied, External API will use ‘generic’ customer
+
+**serviceOrder:**
+
+
+From TMF641 serviceOrder
+
+API at a glance:
+Only high level information are provided - swagger is documented.
+
+It is possible to use POST operation to create new serviceOrder in nbi and triggers service provisioning. GET operation is also available to retrieve one service order by providing id or a list of service order. For this release, only a subset of criteria is available:
+
+•    externalId
+•    state
+•    description
+•    orderDate.gt (orderDate must be greater – after -than)
+•    orderDate.lt (orderDate must be lower-before - than)
+•    fields – attribute used to filter retrieved attributes (if needed) and also for sorted SO
+•    offset and limit are used for pagination purpose
+
+
+
+ServiceOrder will manage only ‘add’ and ‘delete’ operation (no change).
+
+prerequisites & assumptions :
+
+•    Cloud & tenant information MUST BE defined in the external API property file
+•    Management of ONAP customer for add service action:
+With the current version of APIs used from SO and AAI we need to manage a ‘customer’. This customer concept is confusing with Customer BSS concept. We took the following rules to manage the ‘customer’ information:
+
+•    It could be provided through a serviceOrder in the service Order a relatedParty with role ‘ONAPcustomer’ should be provided in the serviceOrder header (we will not consider in this release the party at item level); External API component will check if this customer exists and create it in AAI if not.
+•    If no relatedParty are provided the service will be affected to ‘generic’ customer (dummy customer) – we assume this ‘generic’ customer always exists.
+
+•    Additionally nbi will create in AAI the service-type if it did not exists for the customer
+
+•    Integration is done at service-level: nbi will trigger only SO request at serviceInstance level -->  ONAP prerequisite: SO must be able to find a BPMN to process service fulfillment (integrate vnf, vnf activation in SDNC, VF module
+
+•    State management: States are only managed by ServiceOrder component and could not be updated from north side via API. Accordingly to service order item fulfillment progress, order item state are updated. Order state is automatically updated based on item state.
+
+
+***************
+API flow
+***************
+
+API Flow illustration (with example messages) is described in this document: :download:`nbicallflow.pdf <pdf/nbicallflow.pdf>`
+
diff --git a/docs/releasenotes/releasenotes.rst b/docs/releasenotes/releasenotes.rst
new file mode 100644 (file)
index 0000000..a4ef6fb
--- /dev/null
@@ -0,0 +1,33 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright 2018 ORANGE
+
+
+Release Notes
+=============
+
+
+Version:
+--------------
+
+
+:Release Date:
+
+
+**New Features**
+
+**Bug Fixes**
+
+**Known Issues**
+
+**Security Issues**
+
+**Upgrade Notes**
+
+**Deprecation Notes**
+
+**Other**
+
+===========
+
+End of Release Notes
index c3e41f4..5f10d63 100644 (file)
@@ -18,17 +18,13 @@ package org.onap.nbi.apis.serviceorder;
 import org.onap.nbi.OnapComponentsUrlPaths;
 import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceResponse;
 import org.onap.nbi.apis.serviceorder.model.consumer.GetRequestStatusResponse;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestDetails;
+import org.onap.nbi.apis.serviceorder.model.consumer.MSOPayload;
 import org.onap.nbi.exceptions.BackendFunctionalException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-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.http.*;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
@@ -57,15 +53,15 @@ public class SoClient {
     private static final Logger LOGGER = LoggerFactory.getLogger(SoClient.class);
 
 
-    public ResponseEntity<CreateServiceInstanceResponse> callCreateServiceInstance(RequestDetails requestDetails) {
+    public ResponseEntity<CreateServiceInstanceResponse> callCreateServiceInstance(MSOPayload msoPayload) {
 
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("Calling SO CreateServiceInstance with requestDetails : " + requestDetails.toString());
+            LOGGER.debug("Calling SO CreateServiceInstance with msoPayload : " + msoPayload.toString());
         }
 
         String url = soHostname + OnapComponentsUrlPaths.MSO_CREATE_SERVICE_INSTANCE_PATH;
 
-        HttpEntity<RequestDetails> requestDetailEntity = new HttpEntity<>(requestDetails, buildRequestHeader());
+        HttpEntity<MSOPayload> requestDetailEntity = new HttpEntity<>(msoPayload, buildRequestHeader());
 
         try {
             ResponseEntity<CreateServiceInstanceResponse> response = restTemplate.exchange(url, HttpMethod.POST,
@@ -80,16 +76,16 @@ public class SoClient {
         }
     }
 
-    public ResponseEntity<CreateServiceInstanceResponse> callDeleteServiceInstance(RequestDetails requestDetails,
+    public ResponseEntity<CreateServiceInstanceResponse> callDeleteServiceInstance(MSOPayload msoPayload,
             String serviceId) {
 
         if (LOGGER.isDebugEnabled()) {
-            LOGGER.debug("Calling SO DeleteServiceInstance with requestDetails : " + requestDetails.toString());
+            LOGGER.debug("Calling SO DeleteServiceInstance with msoPayload : " + msoPayload.toString());
         }
 
         String url = soHostname + OnapComponentsUrlPaths.MSO_DELETE_REQUEST_STATUS_PATH + serviceId;
 
-        HttpEntity<RequestDetails> requestDetailEntity = new HttpEntity<>(requestDetails, buildRequestHeader());
+        HttpEntity<MSOPayload> requestDetailEntity = new HttpEntity<>(msoPayload, buildRequestHeader());
 
         try {
             ResponseEntity<CreateServiceInstanceResponse> response = restTemplate.exchange(url, HttpMethod.DELETE,
diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java
new file mode 100644 (file)
index 0000000..76415c3
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ *     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 MSOPayload {
+
+    private RequestDetails requestDetails;
+
+    public MSOPayload(RequestDetails requestDetails) {
+        this.requestDetails = requestDetails;
+    }
+
+    public RequestDetails getRequestDetails() {
+        return requestDetails;
+    }
+
+    public void setRequestDetails(RequestDetails requestDetails) {
+        this.requestDetails = requestDetails;
+    }
+
+    @Override
+    public String toString() {
+        return "MSOPayload{" +
+                "requestDetails=" + requestDetails +
+                '}';
+    }
+}
index 6d3d5d5..a80b1ee 100644 (file)
@@ -25,6 +25,8 @@ public class RequestInfo {
 
     private boolean suppressRollback;
 
+    private String requestorId;
+
     public String getInstanceName() {
         return instanceName;
     }
@@ -57,9 +59,22 @@ public class RequestInfo {
         this.suppressRollback = suppressRollback;
     }
 
+    public String getRequestorId() {
+        return requestorId;
+    }
+
+    public void setRequestorId(String requestorId) {
+        this.requestorId = requestorId;
+    }
+
     @Override
     public String toString() {
-        return "RequestInfo{" + "instanceName='" + instanceName + '\'' + ", productFamilyId='" + productFamilyId + '\''
-                + ", source='" + source + '\'' + ", suppressRollback=" + suppressRollback + '}';
+        return "RequestInfo{" +
+            "instanceName='" + instanceName + '\'' +
+            ", productFamilyId='" + productFamilyId + '\'' +
+            ", source='" + source + '\'' +
+            ", suppressRollback=" + suppressRollback +
+            ", requestorId='" + requestorId + '\'' +
+            '}';
     }
 }
index f39ad1f..1d1ef36 100644 (file)
  */
 package org.onap.nbi.apis.serviceorder.workflow;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
 import org.onap.nbi.apis.serviceorder.SoClient;
 import org.onap.nbi.apis.serviceorder.model.ServiceCharacteristic;
 import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
 import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
 import org.onap.nbi.apis.serviceorder.model.StateType;
-import org.onap.nbi.apis.serviceorder.model.consumer.CloudConfiguration;
-import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceResponse;
-import org.onap.nbi.apis.serviceorder.model.consumer.GetRequestStatusResponse;
-import org.onap.nbi.apis.serviceorder.model.consumer.ModelInfo;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestDetails;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestInfo;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestParameters;
-import org.onap.nbi.apis.serviceorder.model.consumer.RequestState;
-import org.onap.nbi.apis.serviceorder.model.consumer.SubscriberInfo;
-import org.onap.nbi.apis.serviceorder.model.consumer.UserParams;
+import org.onap.nbi.apis.serviceorder.model.consumer.*;
 import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
 import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo;
 import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfoJson;
@@ -49,6 +34,9 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.io.IOException;
+import java.util.*;
+
 @Service
 public class SOTaskProcessor {
 
@@ -147,14 +135,15 @@ public class SOTaskProcessor {
         RequestDetails requestDetails = buildSoRequest(serviceOrderItem,
                 serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()).getCatalogResponse(),
                 serviceOrderInfo.getSubscriberInfo());
+        MSOPayload msoPayload = new MSOPayload(requestDetails);
         ResponseEntity<CreateServiceInstanceResponse> response = null;
 
         switch (serviceOrderItem.getAction()) {
             case ADD:
-                response = soClient.callCreateServiceInstance(requestDetails);
+                response = soClient.callCreateServiceInstance(msoPayload);
                 break;
             case DELETE:
-                response = soClient.callDeleteServiceInstance(requestDetails, serviceOrderItem.getService().getId());
+                response = soClient.callDeleteServiceInstance(msoPayload, serviceOrderItem.getService().getId());
                 break;
             default:
                 break;
@@ -265,6 +254,7 @@ public class SOTaskProcessor {
         requestInfo.setInstanceName(orderItem.getService().getName());
         requestInfo.setSource("VID");
         requestInfo.setSuppressRollback(false);
+        requestInfo.setRequestorId("NBI");
         requestDetails.setRequestInfo(requestInfo);
 
         RequestParameters requestParameters = new RequestParameters();
index c65f60b..937f417 100644 (file)
@@ -180,6 +180,19 @@ public class ApiTest {
 
     }
 
+    @Test
+    public void testServiceResourceGetInventoryWithoutRelationShipList() throws Exception {
+
+        String serviceName = "vFW";
+        String serviceId = "e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList";
+        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
+        params.add("serviceSpecification.name", serviceName);
+        params.add("relatedParty.id", "6490");
+        ResponseEntity<Object> resource = serviceInventoryResource.getServiceInventory(serviceId, params);
+        ServiceInventoryAssertions.assertServiceInventoryGetWithoutList(resource);
+
+    }
+
 
     @Test
     public void testServiceResourceGetInventoryWithServiceSpecId() throws Exception {
@@ -276,6 +289,24 @@ public class ApiTest {
 
     }
 
+
+    @Test
+    public void testCheckServiceOrderWithoutRelatedParty() throws Exception {
+
+        ServiceOrder testServiceOrder = ServiceOrderAssertions.createTestServiceOrder(ActionType.ADD);
+        testServiceOrder.setRelatedParty(null);
+        testServiceOrder.setState(StateType.ACKNOWLEDGED);
+        testServiceOrder.setId("test");
+        serviceOrderRepository.save(testServiceOrder);
+
+        serviceOrderResource.scheduleCheckServiceOrders();
+
+        ServiceOrder serviceOrderChecked = serviceOrderRepository.findOne("test");
+        assertThat(serviceOrderChecked.getState()).isEqualTo(StateType.ACKNOWLEDGED);
+
+
+    }
+
     @Test
     public void testCheckServiceOrderWithUnKnonwCustomer() throws Exception {
 
index 56a6180..f68b82f 100644 (file)
@@ -54,6 +54,28 @@ public class ServiceInventoryAssertions {
     }
 
 
+    public static void assertServiceInventoryGetWithoutList(ResponseEntity<Object> 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(0);
+
+    }
+
+
+
     public static void assertServiceInventoryFind(ResponseEntity<Object> resource) {
         assertThat(resource.getStatusCode()).isEqualTo(HttpStatus.OK);
         ArrayList body = (ArrayList) resource.getBody();
diff --git a/src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json b/src/test/resources/mappings/aai_get_service-subscriptionWithoutList.json
new file mode 100644 (file)
index 0000000..2765c77
--- /dev/null
@@ -0,0 +1,19 @@
+{
+  "request": {
+    "method": "GET",
+    "url": "/aai/v11/business/customers/customer/6490/service-subscriptions/service-subscription/vFW/service-instances/service-instance/e4688e5f-61a0-4f8b-ae02-a2fbde623bcbWithoutList"
+  },
+  "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"
+    },
+    "headers": {
+      "Content-Type": "application/json"
+    }
+  }
+}
\ No newline at end of file