summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/_static/cps-r9-ncmp-dmi-plugin-interface-diagram.pngbin0 -> 24561 bytes
-rw-r--r--docs/admin-guide.rst12
-rw-r--r--docs/architecture.rst39
-rw-r--r--docs/design.rst24
-rw-r--r--docs/index.rst17
-rw-r--r--docs/modeling.rst10
-rw-r--r--docs/openapi/components.yml79
-rw-r--r--docs/openapi/openapi.yml22
-rw-r--r--pom.xml131
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java79
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java28
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java41
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/model/CmHandleOperation.java (renamed from src/main/java/org/onap/cps/ncmp/dmi/model/CmHandleOperation.java)4
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/model/CreatedCmHandle.java (renamed from src/main/java/org/onap/cps/ncmp/dmi/model/CreatedCmHandle.java)4
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleReference.java (renamed from src/main/java/org/onap/cps/ncmp/dmi/model/ModuleReference.java)2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemaList.java (renamed from src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemaList.java)2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemaProperties.java (renamed from src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemaProperties.java)2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemas.java (renamed from src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java)2
-rw-r--r--src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java47
-rw-r--r--src/main/resources/application.yml2
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy66
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiPluginConfigSpec.groovy52
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/model/ModuleSchemaPropertiesSpec.groovy41
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy43
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy58
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy35
-rw-r--r--src/test/resources/GetModules.json3
-rw-r--r--src/test/resources/application.yml12
28 files changed, 485 insertions, 372 deletions
diff --git a/docs/_static/cps-r9-ncmp-dmi-plugin-interface-diagram.png b/docs/_static/cps-r9-ncmp-dmi-plugin-interface-diagram.png
new file mode 100644
index 00000000..6c5903d2
--- /dev/null
+++ b/docs/_static/cps-r9-ncmp-dmi-plugin-interface-diagram.png
Binary files differ
diff --git a/docs/admin-guide.rst b/docs/admin-guide.rst
new file mode 100644
index 00000000..787e931b
--- /dev/null
+++ b/docs/admin-guide.rst
@@ -0,0 +1,12 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright (C) 2021 Nordix Foundation
+
+.. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING
+.. _adminGuide:
+
+
+DMI-Plugin Admin Guide
+######################
+
+For DMI-Plugin Admin Guide, please refer to the `CPS Admin Guide. <https://docs.onap.org/projects/onap-cps/en/latest/admin-guide.html>`_ \ No newline at end of file
diff --git a/docs/architecture.rst b/docs/architecture.rst
index 65125764..65e10d45 100644
--- a/docs/architecture.rst
+++ b/docs/architecture.rst
@@ -6,8 +6,6 @@
DMI Plugin Architecture
#######################
-.. warning:: draft
-
.. toctree::
:maxdepth: 1
@@ -15,14 +13,9 @@ DMI Plugin Architecture
High Level Component Definition and Architectural Relationships
===============================================================
-The DMI plugin provides a gateway for registration of CM Handles within CPS
-
-Project implementation proposal page describing scope is here:
-`CPS-390 Spike: Define and Agree DMI Plugin REST Interface <https://wiki.onap.org/display/DW/CPS-390+Spike%3A+Define+and+Agree+DMI+Plugin+REST+Interface>`_
+The DMI plugin provides a gateway for registration and syncing of CM Handles within CPS.
-This page reflects the state for Istanbul-R9 release.
-
-.. image:: _static/dmi-plugin-r9-arch-diagram.PNG
+.. image:: _static/cps-r9-ncmp-dmi-plugin-interface-diagram.png
API definitions
===============
@@ -30,11 +23,33 @@ API definitions
The DMI plugin provides following interfaces.
.. list-table::
- :header-rows: 0
+ :header-rows: 1
* - Interface name
- Interface definition
- Interface capabilities
- Protocol
-
-The DMI plugin Basic Concepts are described in :doc:`modeling`.
+ * - CPS-E-05
+ - Provides external clients with xNF data access and module information
+ - - Create data
+ - Delete data
+ - Update data
+ - Read data
+ - Query data
+ - Query module references
+ - REST
+ * - CPS-NCMP-I-01
+ - DMI Plugin Inventory
+ - - Register Plug-in CM-Handles
+ - REST
+ * - DMI-I-01
+ - Provides NCMP with xNF data access and module information
+ - - Create data
+ - Delete data
+ - Update data
+ - Read data
+ - Query data
+ - Query module references
+ - REST
+
+More details on the CPS interface CPS-E-05 which is responsible for the DMI Plugin can be found on the `CPS Architecture Page <https://docs.onap.org/projects/onap-cps/en/latest/architecture.html>`_. \ No newline at end of file
diff --git a/docs/design.rst b/docs/design.rst
index e65c5aed..708feeb3 100644
--- a/docs/design.rst
+++ b/docs/design.rst
@@ -9,8 +9,6 @@
DMI Plugin Design
#################
-.. warning:: draft
-
.. toctree::
:maxdepth: 1
@@ -19,10 +17,10 @@ Offered APIs
The DMI Plugin supports the public APIs listed in the link below:
-:download:`DMI Rest OpenApi Specification <openapi/openapi.yml>`
+:download:`DMI Rest OpenApi Specification <openapi/openapi.yaml>`
-Exposed API
------------
+View Offered APIs
+-----------------
The standard for API definition in the RESTful API world is the OpenAPI Specification (OAS).
The OAS 3, which is based on the original "Swagger Specification", is being widely used in API developments.
@@ -31,10 +29,16 @@ Specification can be accessed using following URI:
.. code-block:: bash
- “http://<hostname>:<port>/v3/api-docs?group=dmi-plugin-docket”
+ http://<hostname>:<port>/v3/api-docs?group=dmi-plugin-docket
+
+Additionally, the Swagger User Interface can be found at the following URI. The component may be changed between CPS-Core
+and CPS-NCMP using the drop down table in the top right:
+
+.. code-block:: bash
+
+ http://<hostname>:<port>/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
-DMI Plugin CM Handles
-=====================
+Consumed APIs
+=============
-Several DMI Plugin APIs use the cm-handle parameter.
-The DMI Plugin CM Handles are described in detail in :doc:`dmi-plugin-cm-handle`.
+- SDNC: REST based interface exposed by the SDNC client. This is used to retrieve the yang resources and modules for CPS.
diff --git a/docs/index.rst b/docs/index.rst
index 54da6148..7d1fcf37 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -8,34 +8,27 @@
.. THIS IS USED INTERNALLY IN CPS ONLY
.. _dmi-framework-doc:
-DMI Plugin Documentation for the Istanbul-R9 Release
+DMI-Plugin Documentation for the Istanbul-R9 Release
----------------------------------------------------
-.. warning:: draft
-
.. toctree::
:maxdepth: 1
overview.rst
architecture.rst
+ admin-guide.rst
design.rst
modeling.rst
deployment.rst
release-notes.rst
-CPS-Core Documentation for the Istanbul-R9 Release
+CPS-NCMP Documentation for the Istanbul-R9 Release
---------------------------------------------------------
-.. toctree::
- :maxdepth: 3
-
-* `CPS Core(placeholder) `_
+* `CPS-NCMP <https://docs.onap.org/projects/onap-cps/en/latest/index.html>`_
CPS-Temporal Documentation for the Istanbul-R9 Release
------------------------------------------------------
-.. toctree::
- :maxdepth: 1
-
-* `CPS Temporal(placeholder) `_ \ No newline at end of file
+* `CPS-Temporal <https://docs.onap.org/projects/onap-cps-cps-temporal/en/latest/index.html>`_
diff --git a/docs/modeling.rst b/docs/modeling.rst
index 63f25b7c..fdfcef06 100644
--- a/docs/modeling.rst
+++ b/docs/modeling.rst
@@ -6,13 +6,9 @@
DMI Plugin Modeling
###################
-.. warning:: draft
-
.. toctree::
:maxdepth: 1
-Basic Concepts
-==============
-
-.. image:: _static/dmi-plugin-modeling-concepts.png
- :alt: Basic entities relationship
+The DMI Plugin acts as a proxy and as such does not have its own data model. For more information on the data which
+is passed through the DMI Plugin, please refer to the `NCMP Modeling Section <https://docs.onap.org/projects/onap-cps/en/latest/modeling.html#ncmp-modeling>`_
+of the `CPS Modeling Page <https://docs.onap.org/projects/onap-cps/en/latest/modeling.html>`_.
diff --git a/docs/openapi/components.yml b/docs/openapi/components.yml
index 9cce52de..30e5987f 100644
--- a/docs/openapi/components.yml
+++ b/docs/openapi/components.yml
@@ -19,14 +19,15 @@ components:
items:
type: string
- DmiModuleReadRequestBody:
+ ModuleReferencesRequest:
+ type: object
+ properties:
+ cmHandleProperties:
+ $ref: '#/components/schemas/cmHandleProperties'
+
+ ModuleResourcesReadRequest:
type: object
properties:
- operation:
- type: string
- enum: [read]
- dataType:
- type: string
data:
type: object
properties:
@@ -36,14 +37,11 @@ components:
type: object
properties:
name:
- type: string
+ $ref: '#/components/schemas/name'
revision:
- type: string
+ $ref: '#/components/schemas/revision'
cmHandleProperties:
- type: object
- additionalProperties:
- type: string
- example: system-001
+ $ref: '#/components/schemas/cmHandleProperties'
ModuleSet:
type: object
@@ -56,7 +54,7 @@ components:
moduleName:
type: string
revision:
- type: string
+ $ref: '#/components/schemas/revision'
namespace:
type: string
@@ -73,7 +71,7 @@ components:
moduleName:
type: string
revision:
- type: string
+ $ref: '#/components/schemas/revision'
DataAccessReadRequest:
type: object
@@ -82,9 +80,7 @@ components:
type: string
enum: [ read ]
cmHandleProperties:
- type: object
- additionalProperties:
- type: string
+ $ref: '#/components/schemas/cmHandleProperties'
DataAccessWriteRequest:
type: object
@@ -97,9 +93,21 @@ components:
data:
type: string
cmHandleProperties:
- type: object
- additionalProperties:
- type: string
+ $ref: '#/components/schemas/cmHandleProperties'
+
+ cmHandleProperties:
+ type: object
+ additionalProperties:
+ type: string
+ example: {"prop1":"value1","prop2":"value2"}
+
+ name:
+ type: string
+ example: someName
+
+ revision:
+ type: string
+ example: someRevision
responses:
NotFound:
@@ -157,11 +165,12 @@ components:
schema:
type: string
- resourceIdentifierInPath:
+ resourceIdentifierInQuery:
name: resourceIdentifier
- in: path
+ in: query
description: Resource identifier to get/set the resource data
required: true
+ allowReserved: true
schema:
type: string
@@ -173,19 +182,21 @@ components:
type: string
enum: [ application/json, application/yang-data+json ]
- fieldsParamInQuery:
- name: fields
+ optionsParamInQuery:
+ name: options
in: query
- description: Fields parameter to filter resource
+ description: options parameter in query, it is mandatory to wrap key(s)=value(s) in parenthesis'()'.
required: false
schema:
type: string
-
- depthParamInQuery:
- name: depth
- in: query
- description: Depth parameter for response
- required: false
- schema:
- type: integer
- minimum: 1 \ No newline at end of file
+ allowReserved: true
+ examples:
+ sample1:
+ value:
+ options: (key1=value1,key2=value2)
+ sample2:
+ value:
+ options: (key1=value1,key2=value1/value2)
+ sample3:
+ value:
+ options: (key1=10,key2=value2,key3=[val31,val32]) \ No newline at end of file
diff --git a/docs/openapi/openapi.yml b/docs/openapi/openapi.yml
index f66897a2..83c05abb 100644
--- a/docs/openapi/openapi.yml
+++ b/docs/openapi/openapi.yml
@@ -37,7 +37,7 @@ paths:
- dmi-plugin
summary: Get all modules for cm handle
description: Get all modules for given cm handle
- operationId: getModulesForCmHandle
+ operationId: getModuleReferences
parameters:
- name: cmHandle
in: path
@@ -50,7 +50,7 @@ paths:
content:
application/json:
schema:
- $ref: 'components.yml#/components/schemas/DataAccessReadRequest'
+ $ref: 'components.yml#/components/schemas/ModuleReferencesRequest'
responses:
'200':
description: OK
@@ -113,7 +113,7 @@ paths:
content:
application/json:
schema:
- $ref: 'components.yml#/components/schemas/DmiModuleReadRequestBody'
+ $ref: 'components.yml#/components/schemas/ModuleResourcesReadRequest'
responses:
'200':
description: OK
@@ -128,7 +128,7 @@ paths:
'403':
$ref: 'components.yml#/components/responses/Forbidden'
- /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-operational/{resourceIdentifier}:
+ /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-operational:
put:
tags:
- dmi-plugin
@@ -137,10 +137,9 @@ paths:
operationId: getResourceDataOperationalForCmHandle
parameters:
- $ref: 'components.yml#/components/parameters/cmHandleInPath'
- - $ref: 'components.yml#/components/parameters/resourceIdentifierInPath'
+ - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery'
- $ref: 'components.yml#/components/parameters/acceptParamInHeader'
- - $ref: 'components.yml#/components/parameters/fieldsParamInQuery'
- - $ref: 'components.yml#/components/parameters/depthParamInQuery'
+ - $ref: 'components.yml#/components/parameters/optionsParamInQuery'
requestBody:
description: Operational body
content:
@@ -157,7 +156,7 @@ paths:
'403':
$ref: 'components.yml#/components/responses/Forbidden'
- /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-running/{resourceIdentifier}:
+ /v1/ch/{cmHandle}/data/ds/ncmp-datastore:passthrough-running:
put:
tags:
- dmi-plugin
@@ -166,10 +165,9 @@ paths:
operationId: getResourceDataPassthroughRunningForCmHandle
parameters:
- $ref: 'components.yml#/components/parameters/cmHandleInPath'
- - $ref: 'components.yml#/components/parameters/resourceIdentifierInPath'
+ - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery'
- $ref: 'components.yml#/components/parameters/acceptParamInHeader'
- - $ref: 'components.yml#/components/parameters/fieldsParamInQuery'
- - $ref: 'components.yml#/components/parameters/depthParamInQuery'
+ - $ref: 'components.yml#/components/parameters/optionsParamInQuery'
requestBody:
description: Operational body
content:
@@ -194,7 +192,7 @@ paths:
operationId: writeDataByPassthroughRunningForCmHandle
parameters:
- $ref: 'components.yml#/components/parameters/cmHandleInPath'
- - $ref: 'components.yml#/components/parameters/resourceIdentifierInPath'
+ - $ref: 'components.yml#/components/parameters/resourceIdentifierInQuery'
requestBody:
required: true
content:
diff --git a/pom.xml b/pom.xml
index 2eca0b26..03344dbc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,108 +17,7 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
---><!DOCTYPE project [
- <!ELEMENT project (modelVersion|parent|organization|groupId|artifactId|version|name|description|properties|dependencyManagement|dependencies|build|pluginManagement)*>
- <!ATTLIST project
- xmlns CDATA #REQUIRED
- xmlns:xsi CDATA #REQUIRED
- xsi:schemaLocation CDATA #REQUIRED>
- <!ELEMENT modelVersion (#PCDATA)>
- <!ELEMENT parent (groupId|artifactId|version|relativePath)*>
- <!ELEMENT groupId (#PCDATA)>
- <!ELEMENT artifactId (#PCDATA)>
- <!ELEMENT version (#PCDATA)>
- <!ELEMENT relativePath (#PCDATA)>
- <!ELEMENT organization (name|url)*>
- <!ELEMENT name (#PCDATA)>
- <!ELEMENT url (#PCDATA)>
- <!ELEMENT description (#PCDATA)>
- <!ELEMENT properties (app|base.image|cps.version|image.tag|jacoco.minimum.coverage|maven.build.timestamp.format|project.build.sourceEncoding|image.name)*>
- <!ELEMENT app (#PCDATA)>
- <!ELEMENT base.image (#PCDATA)>
- <!ELEMENT cps.version (#PCDATA)>
- <!ELEMENT image.tag (#PCDATA)>
- <!ELEMENT jacoco.minimum.coverage (#PCDATA)>
- <!ELEMENT maven.build.timestamp.format (#PCDATA)>
- <!ELEMENT project.build.sourceEncoding (#PCDATA)>
- <!ELEMENT dependencyManagement (dependencies)*>
- <!ELEMENT dependencies (dependency)*>
- <!ELEMENT dependency (groupId|artifactId|version|type|scope|exclusions)*>
- <!ELEMENT type (#PCDATA)>
- <!ELEMENT scope (#PCDATA)>
- <!ELEMENT exclusions (exclusion)*>
- <!ELEMENT exclusion (groupId|artifactId)*>
- <!ELEMENT build (resources|plugins|plugin)*>
- <!ELEMENT resources (resource)*>
- <!ELEMENT resource (directory|filtering|includes|targetPath)*>
- <!ELEMENT directory (#PCDATA)>
- <!ELEMENT filtering (#PCDATA)>
- <!ELEMENT includes (include)*>
- <!ELEMENT include (#PCDATA)>
- <!ELEMENT targetPath (#PCDATA)>
- <!ELEMENT plugins (plugin)*>
- <!ELEMENT plugin (groupId|artifactId|version|executions|configuration|dependencies)*>
- <!ELEMENT executions (execution)*>
- <!ELEMENT execution (goals|configuration|id|phase)*>
- <!ELEMENT goals (goal)*>
- <!ELEMENT goal (#PCDATA)>
- <!ELEMENT configuration (inputSpec|language|generateSupportingFiles|apiPackage|modelPackage|configOptions|argLine|includes|excludes|configLocation|includeResources|includeTestSourceDirectory|includeTestResources|sourceDirectories|consoleOutput|violationSeverity|failOnViolation|plugins|effort|threshold|failOnError|excludeFilterFile|xmlOutput|xmlOutputDirectory|dataFile|rules|dataFileIncludes|container|from|to)*>
- <!ELEMENT inputSpec (#PCDATA)>
- <!ELEMENT language (#PCDATA)>
- <!ELEMENT generateSupportingFiles (#PCDATA)>
- <!ELEMENT apiPackage (#PCDATA)>
- <!ELEMENT modelPackage (#PCDATA)>
- <!ELEMENT configOptions (sourceFolder|dateLibrary|interfaceOnly|useTags)*>
- <!ELEMENT sourceFolder (#PCDATA)>
- <!ELEMENT dateLibrary (#PCDATA)>
- <!ELEMENT interfaceOnly (#PCDATA)>
- <!ELEMENT useTags (#PCDATA)>
- <!ELEMENT id (#PCDATA)>
- <!ELEMENT phase (#PCDATA)>
- <!ELEMENT argLine (#PCDATA)>
- <!ELEMENT excludes (exclude)*>
- <!ELEMENT exclude (#PCDATA)>
- <!ELEMENT configLocation (#PCDATA)>
- <!ELEMENT includeResources (#PCDATA)>
- <!ELEMENT includeTestSourceDirectory (#PCDATA)>
- <!ELEMENT includeTestResources (#PCDATA)>
- <!ELEMENT sourceDirectories (sourceDirectory)*>
- <!ELEMENT sourceDirectory (#PCDATA)>
- <!ELEMENT consoleOutput (#PCDATA)>
- <!ELEMENT violationSeverity (#PCDATA)>
- <!ELEMENT failOnViolation (#PCDATA)>
- <!ELEMENT effort (#PCDATA)>
- <!ELEMENT threshold (#PCDATA)>
- <!ELEMENT failOnError (#PCDATA)>
- <!ELEMENT excludeFilterFile (#PCDATA)>
- <!ELEMENT xmlOutput (#PCDATA)>
- <!ELEMENT xmlOutputDirectory (#PCDATA)>
- <!ELEMENT dataFile (#PCDATA)>
- <!ELEMENT rules (rule)*>
- <!ELEMENT rule (element|limits)*>
- <!ELEMENT element (#PCDATA)>
- <!ELEMENT limits (limit)*>
- <!ELEMENT limit (counter|value|minimum)*>
- <!ELEMENT counter (#PCDATA)>
- <!ELEMENT value (#PCDATA)>
- <!ELEMENT minimum (#PCDATA)>
- <!ELEMENT dataFileIncludes (fileInclude)*>
- <!ELEMENT fileInclude (#PCDATA)>
- <!ELEMENT pluginManagement (plugins)*>
- <!ELEMENT container (mainClass|creationTime)*>
- <!ELEMENT mainClass (#PCDATA)>
- <!ELEMENT creationTime (#PCDATA)>
- <!ELEMENT from (image)*>
- <!ELEMENT image (#PCDATA)>
- <!ELEMENT to (tags|image)*>
- <!ELEMENT tags (tag)*>
- <!ELEMENT tag (#PCDATA)>
- <!ELEMENT profiles (profile)*>
- <!ELEMENT profile (id|activation|properties|build)*>
- <!ELEMENT activation (activeByDefault)*>
- <!ELEMENT activeByDefault (#PCDATA)>
- <!ELEMENT image.name (#PCDATA)>
- ]>
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -143,7 +42,7 @@
<base.image>${docker.pull.registry}/onap/integration-java11:8.0.0</base.image>
<cps.version>2.0.0</cps.version>
<image.tag>${project.version}-${maven.build.timestamp}</image.tag>
- <jacoco.minimum.coverage>0.7</jacoco.minimum.coverage>
+ <jacoco.minimum.coverage>0.98</jacoco.minimum.coverage>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -443,7 +342,6 @@
<configuration>
<excludes>
<exclude>org/onap/cps/ncmp/dmi/model/*</exclude>
- <exclude>org/onap/cps/ncmp/dmi/config/*</exclude>
</excludes>
</configuration>
<executions>
@@ -494,7 +392,7 @@
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
- <version>2.8.0</version>
+ <version>3.1.4</version>
<configuration>
<container>
<mainClass>${app}</mainClass>
@@ -527,29 +425,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-resources</id>
- <phase>compile</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.basedir}/docs/openapi/</outputDirectory>
- <resources>
- <resource>
- <directory>${project.basedir}/target/generated-sources/swagger/</directory>
- <includes>
- <include>openapi.yaml</include>
- </includes>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</pluginManagement>
</build>
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
index ff3cefcd..b17280ae 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/rest/controller/DmiRestController.java
@@ -24,18 +24,18 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
import javax.validation.Valid;
-import javax.validation.constraints.Min;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.dmi.model.CmHandles;
import org.onap.cps.ncmp.dmi.model.DataAccessReadRequest;
import org.onap.cps.ncmp.dmi.model.DataAccessWriteRequest;
-import org.onap.cps.ncmp.dmi.model.DmiModuleReadRequestBody;
-import org.onap.cps.ncmp.dmi.model.ModuleReference;
+import org.onap.cps.ncmp.dmi.model.ModuleReferencesRequest;
+import org.onap.cps.ncmp.dmi.model.ModuleResourcesReadRequest;
import org.onap.cps.ncmp.dmi.model.ModuleSet;
import org.onap.cps.ncmp.dmi.model.YangResources;
import org.onap.cps.ncmp.dmi.rest.api.DmiPluginApi;
import org.onap.cps.ncmp.dmi.rest.api.DmiPluginInternalApi;
import org.onap.cps.ncmp.dmi.service.DmiService;
+import org.onap.cps.ncmp.dmi.service.model.ModuleReference;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -57,8 +57,8 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
}
@Override
- public ResponseEntity<ModuleSet> getModulesForCmHandle(final String cmHandle,
- final @Valid DataAccessReadRequest body) {
+ public ResponseEntity<ModuleSet> getModuleReferences(final String cmHandle,
+ final @Valid ModuleReferencesRequest body) {
// For onap-dmi-plugin we don't need cmHandleProperties, so DataAccessReadRequest is not used.
final var moduleSet = dmiService.getModulesForCmHandle(cmHandle);
return ResponseEntity.ok(moduleSet);
@@ -66,28 +66,25 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
@Override
public ResponseEntity<YangResources> retrieveModuleResources(
- final @Valid DmiModuleReadRequestBody dmiModuleReadRequestBody,
- final String cmHandle) {
- if (dmiModuleReadRequestBody.getOperation().toString().equals("read")) {
- final var moduleReferenceList = convertRestObjectToJavaApiObject(dmiModuleReadRequestBody);
- final var response = dmiService.getModuleResources(cmHandle, moduleReferenceList);
- return new ResponseEntity<>(response, HttpStatus.OK);
- }
- return new ResponseEntity<>(HttpStatus.CONFLICT);
+ final @Valid ModuleResourcesReadRequest moduleResourcesReadRequest,
+ final String cmHandle) {
+ final List<ModuleReference> moduleReferences = convertRestObjectToJavaApiObject(moduleResourcesReadRequest);
+ final YangResources yangResources = dmiService.getModuleResources(cmHandle, moduleReferences);
+ return new ResponseEntity<>(yangResources, HttpStatus.OK);
}
/**
* Write data using passthrough for the given cmHandle.
*
* @param dataAccessWriteRequest pass through request
- * @param cmHandle cmHandle
* @param resourceIdentifier resource identifier
+ * @param cmHandle cmHandle
* @return (@ code ResponseEntity) response entity
*/
@Override
public ResponseEntity<String> writeDataByPassthroughRunningForCmHandle(
final DataAccessWriteRequest dataAccessWriteRequest,
- final String cmHandle, final String resourceIdentifier) {
+ final String resourceIdentifier, final String cmHandle) {
final String response = dmiService.writeResourceDataPassthroughForCmHandle(cmHandle,
resourceIdentifier,
MediaType.APPLICATION_JSON_VALUE,
@@ -112,64 +109,58 @@ public class DmiRestController implements DmiPluginApi, DmiPluginInternalApi {
/**
* This method fetches the resource for given cm handle using pass through operational. It filters the response on
- * the basis of depth and field query parameters and returns response.
+ * the basis of options query parameters and returns response.
*
- * @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier to fetch data
+ * @param cmHandle cm handle identifier
* @param dataAccessReadRequest data Access Read Request
- * @param accept accept header parameter
- * @param fields fields to filter the response data
- * @param depth depth parameter for the response
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @return {@code ResponseEntity} response entity
*/
@Override
- public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle,
- final String resourceIdentifier,
+ public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String resourceIdentifier,
+ final String cmHandle,
final @Valid DataAccessReadRequest dataAccessReadRequest,
- final String accept,
- final @Valid String fields,
- final @Min(1) @Valid Integer depth) {
+ final String acceptParamInHeader,
+ final @Valid String optionsParamInQuery) {
final var modulesListAsJson = dmiService.getResourceDataOperationalForCmHandle(cmHandle,
resourceIdentifier,
- accept,
- fields,
- depth,
+ acceptParamInHeader,
+ optionsParamInQuery,
dataAccessReadRequest.getCmHandleProperties());
return ResponseEntity.ok(modulesListAsJson);
}
/**
* This method fetches the resource for given cm handle using pass through running. It filters the response on the
- * basis of depth and field query parameters and returns response.
+ * basis of options query parameters and returns response.
*
- * @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier to fetch data
+ * @param cmHandle cm handle identifier
* @param dataAccessReadRequest data Access Read Request
- * @param accept accept header parameter
- * @param fields fields to filter the response data
- * @param depth depth parameter for the response
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @return {@code ResponseEntity} response entity
*/
@Override
- public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String cmHandle,
- final String resourceIdentifier,
+ public ResponseEntity<Object> getResourceDataPassthroughRunningForCmHandle(final String resourceIdentifier,
+ final String cmHandle,
final @Valid DataAccessReadRequest dataAccessReadRequest,
- final String accept,
- final @Valid String fields,
- final @Min(1) @Valid Integer depth) {
+ final String acceptParamInHeader,
+ final @Valid String optionsParamInQuery) {
final var modulesListAsJson = dmiService.getResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier,
- accept,
- fields,
- depth,
+ acceptParamInHeader,
+ optionsParamInQuery,
dataAccessReadRequest.getCmHandleProperties());
return ResponseEntity.ok(modulesListAsJson);
}
private List<ModuleReference> convertRestObjectToJavaApiObject(
- final DmiModuleReadRequestBody dmiModuleSchemaReadRequestBody) {
+ final ModuleResourcesReadRequest moduleResourcesReadRequest) {
return objectMapper
- .convertValue(dmiModuleSchemaReadRequestBody.getData().getModules(),
+ .convertValue(moduleResourcesReadRequest.getData().getModules(),
new TypeReference<List<ModuleReference>>() {});
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
index bd0dc600..c6910399 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiService.java
@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
import org.onap.cps.ncmp.dmi.exception.DmiException;
-import org.onap.cps.ncmp.dmi.model.ModuleReference;
import org.onap.cps.ncmp.dmi.model.ModuleSet;
import org.onap.cps.ncmp.dmi.model.YangResources;
+import org.onap.cps.ncmp.dmi.service.model.ModuleReference;
/**
* Interface for handling Dmi plugin Data.
@@ -61,40 +61,36 @@ public interface DmiService {
/**
* This method use to fetch the resource data from cm handle for datastore pass-through operational and resource
- * Identifier. Fields and depths query parameter are used to filter the response from network resource.
+ * Identifier. Options query parameter are used to filter the response from network resource.
*
* @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier
- * @param acceptParam accept header parameter
- * @param fieldsQuery fields query parameter
- * @param depthQuery depth query parameter
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @param cmHandlePropertyMap cm handle properties
* @return {@code Object} response from network function
*/
Object getResourceDataOperationalForCmHandle(@NotNull String cmHandle,
@NotNull String resourceIdentifier,
- String acceptParam,
- String fieldsQuery,
- Integer depthQuery,
+ String acceptParamInHeader,
+ String optionsParamInQuery,
Map<String, String> cmHandlePropertyMap);
/**
* This method use to fetch the resource data from cm handle for datastore pass-through running and resource
- * Identifier. Fields and depths query parameter are used to filter the response from network resource.
+ * Identifier. Options query parameter are used to filter the response from network resource.
*
* @param cmHandle cm handle identifier
* @param resourceIdentifier resource identifier
- * @param acceptParam accept header parameter
- * @param fieldsQuery fields query parameter
- * @param depthQuery depth query parameter
+ * @param acceptParamInHeader accept header parameter
+ * @param optionsParamInQuery options query parameter
* @param cmHandlePropertyMap cm handle properties
* @return {@code Object} response from network function
*/
Object getResourceDataPassThroughRunningForCmHandle(@NotNull String cmHandle,
@NotNull String resourceIdentifier,
- String acceptParam,
- String fieldsQuery,
- Integer depthQuery,
+ String acceptParamInHeader,
+ String optionsParamInQuery,
Map<String, String> cmHandlePropertyMap);
/**
@@ -108,4 +104,4 @@ public interface DmiService {
*/
String writeResourceDataPassthroughForCmHandle(String cmHandle, String resourceIdentifier, String dataType,
String data);
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
index 182bdd84..b66e5c1b 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/DmiServiceImpl.java
@@ -37,16 +37,16 @@ import org.onap.cps.ncmp.dmi.exception.DmiException;
import org.onap.cps.ncmp.dmi.exception.ModuleResourceNotFoundException;
import org.onap.cps.ncmp.dmi.exception.ModulesNotFoundException;
import org.onap.cps.ncmp.dmi.exception.ResourceDataNotFound;
-import org.onap.cps.ncmp.dmi.model.CmHandleOperation;
-import org.onap.cps.ncmp.dmi.model.CreatedCmHandle;
-import org.onap.cps.ncmp.dmi.model.ModuleReference;
-import org.onap.cps.ncmp.dmi.model.ModuleSchemaProperties;
-import org.onap.cps.ncmp.dmi.model.ModuleSchemas;
import org.onap.cps.ncmp.dmi.model.ModuleSet;
import org.onap.cps.ncmp.dmi.model.ModuleSetSchemas;
import org.onap.cps.ncmp.dmi.model.YangResource;
import org.onap.cps.ncmp.dmi.model.YangResources;
import org.onap.cps.ncmp.dmi.service.client.NcmpRestClient;
+import org.onap.cps.ncmp.dmi.service.model.CmHandleOperation;
+import org.onap.cps.ncmp.dmi.service.model.CreatedCmHandle;
+import org.onap.cps.ncmp.dmi.service.model.ModuleReference;
+import org.onap.cps.ncmp.dmi.service.model.ModuleSchemaProperties;
+import org.onap.cps.ncmp.dmi.service.model.ModuleSchemas;
import org.onap.cps.ncmp.dmi.service.operation.SdncOperations;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -60,13 +60,12 @@ public class DmiServiceImpl implements DmiService {
private NcmpRestClient ncmpRestClient;
private ObjectMapper objectMapper;
private DmiPluginProperties dmiPluginProperties;
- private static final String CONTENT_QUERY_PASSTHROUGH_OPERATIONAL = "content=all";
- private static final String CONTENT_QUERY_PASSTHROUGH_RUNNING = "content=config";
+ private static final String RESTCONF_CONTENT_PASSTHROUGH_OPERATIONAL_QUERY_PARAM = "content=all";
+ private static final String REST_CONF_CONTENT_PASSTHROUGH_RUNNING_QUERY_PARAM = "content=config";
private static final String RESPONSE_CODE = "response code : ";
private static final String MESSAGE = " message : ";
private static final String IETF_NETCONF_MONITORING_OUTPUT = "ietf-netconf-monitoring:output";
-
/**
* Constructor.
*
@@ -178,34 +177,30 @@ public class DmiServiceImpl implements DmiService {
@Override
public Object getResourceDataOperationalForCmHandle(final @NotNull String cmHandle,
final @NotNull String resourceIdentifier,
- final String acceptParam,
- final String fieldsQuery,
- final Integer depthQuery,
+ final String acceptParamInHeader,
+ final String optionsParamInQuery,
final Map<String, String> cmHandlePropertyMap) {
// not using cmHandlePropertyMap of onap dmi impl , other dmi impl might use this.
final ResponseEntity<String> responseEntity = sdncOperations.getResouceDataForOperationalAndRunning(cmHandle,
resourceIdentifier,
- fieldsQuery,
- depthQuery,
- acceptParam,
- CONTENT_QUERY_PASSTHROUGH_OPERATIONAL);
+ optionsParamInQuery,
+ acceptParamInHeader,
+ RESTCONF_CONTENT_PASSTHROUGH_OPERATIONAL_QUERY_PARAM);
return prepareAndSendResponse(responseEntity, cmHandle);
}
@Override
public Object getResourceDataPassThroughRunningForCmHandle(final @NotNull String cmHandle,
final @NotNull String resourceIdentifier,
- final String acceptParam,
- final String fieldsQuery,
- final Integer depthQuery,
+ final String acceptParamInHeader,
+ final String optionsParamInQuery,
final Map<String, String> cmHandlePropertyMap) {
// not using cmHandlePropertyMap of onap dmi impl , other dmi impl might use this.
final ResponseEntity<String> responseEntity = sdncOperations.getResouceDataForOperationalAndRunning(cmHandle,
resourceIdentifier,
- fieldsQuery,
- depthQuery,
- acceptParam,
- CONTENT_QUERY_PASSTHROUGH_RUNNING);
+ optionsParamInQuery,
+ acceptParamInHeader,
+ REST_CONF_CONTENT_PASSTHROUGH_RUNNING_QUERY_PARAM);
return prepareAndSendResponse(responseEntity, cmHandle);
}
@@ -269,4 +264,4 @@ public class DmiServiceImpl implements DmiService {
return responseBodyAsJsonObject.getAsJsonObject(IETF_NETCONF_MONITORING_OUTPUT).getAsJsonPrimitive("data")
.toString();
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/CmHandleOperation.java b/src/main/java/org/onap/cps/ncmp/dmi/service/model/CmHandleOperation.java
index 8ddd42f8..82eac92a 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/CmHandleOperation.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/model/CmHandleOperation.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.dmi.model;
+package org.onap.cps.ncmp.dmi.service.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
@@ -32,4 +32,4 @@ public class CmHandleOperation {
private String dmiPlugin;
private List<CreatedCmHandle> createdCmHandles;
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/CreatedCmHandle.java b/src/main/java/org/onap/cps/ncmp/dmi/service/model/CreatedCmHandle.java
index 9198d7da..6ab6a01e 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/CreatedCmHandle.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/model/CreatedCmHandle.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.dmi.model;
+package org.onap.cps.ncmp.dmi.service.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Map;
@@ -33,4 +33,4 @@ public class CreatedCmHandle {
private String cmHandle;
private Map<String, String> cmHandleProperties;
-} \ No newline at end of file
+}
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleReference.java b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleReference.java
index cb9b7cbb..75c37dff 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleReference.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleReference.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.dmi.model;
+package org.onap.cps.ncmp.dmi.service.model;
import lombok.EqualsAndHashCode;
import lombok.Getter;
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemaList.java b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemaList.java
index 1e7dcb0a..a4af1761 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemaList.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemaList.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.dmi.model;
+package org.onap.cps.ncmp.dmi.service.model;
import java.util.List;
import lombok.Getter;
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemaProperties.java b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemaProperties.java
index 507758ad..6de7d131 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemaProperties.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemaProperties.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.dmi.model;
+package org.onap.cps.ncmp.dmi.service.model;
import java.util.List;
import lombok.Getter;
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemas.java
index 5945168b..a7b2430d 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/model/ModuleSchemas.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/model/ModuleSchemas.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.dmi.model;
+package org.onap.cps.ncmp.dmi.service.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
diff --git a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
index 73503d23..98371bf9 100644
--- a/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
+++ b/src/main/java/org/onap/cps/ncmp/dmi/service/operation/SdncOperations.java
@@ -20,6 +20,7 @@
package org.onap.cps.ncmp.dmi.service.operation;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.groovy.parser.antlr4.util.StringUtils;
@@ -92,23 +93,22 @@ public class SdncOperations {
*
* @param nodeId network resource identifier
* @param resourceId resource identifier
- * @param fieldsValue fields query
- * @param depthValue depth query
- * @param acceptParam accept parameter
+ * @param optionsParamInQuery fields query
+ * @param acceptParamInHeader accept parameter
+ * @param restconfContentQueryParam restconf content query param
* @return {@code ResponseEntity} response entity
*/
public ResponseEntity<String> getResouceDataForOperationalAndRunning(final String nodeId,
final String resourceId,
- final String fieldsValue,
- final Integer depthValue,
- final String acceptParam,
- final String contentQuery) {
+ final String optionsParamInQuery,
+ final String acceptParamInHeader,
+ final String restconfContentQueryParam) {
final String getResourceDataUrl = prepareResourceDataUrl(nodeId,
resourceId,
- getQueryList(fieldsValue, depthValue, contentQuery));
+ buildQueryParamList(optionsParamInQuery, restconfContentQueryParam));
final HttpHeaders httpHeaders = new HttpHeaders();
- if (!StringUtils.isEmpty(acceptParam)) {
- httpHeaders.set(HttpHeaders.ACCEPT, acceptParam);
+ if (!StringUtils.isEmpty(acceptParamInHeader)) {
+ httpHeaders.set(HttpHeaders.ACCEPT, acceptParamInHeader);
}
return sdncRestconfClient.getOperation(getResourceDataUrl, httpHeaders);
}
@@ -131,20 +131,25 @@ public class SdncOperations {
}
@NotNull
- private List<String> getQueryList(final String fieldsValue, final Integer depthValue, final String contentQuery) {
- final List<String> queryList = new LinkedList<>();
- if (!StringUtils.isEmpty(fieldsValue)) {
- queryList.add("fields=" + fieldsValue);
- }
- if (depthValue != null) {
- queryList.add("depth=" + depthValue);
- }
- if (!StringUtils.isEmpty(contentQuery)) {
- queryList.add(contentQuery);
+ private List<String> buildQueryParamList(final String optionsParamInQuery, final String restconfContentQueryParam) {
+ final List<String> queryParamAsList = getOptionsParamAsList(optionsParamInQuery);
+ queryParamAsList.add(restconfContentQueryParam);
+ return queryParamAsList;
+ }
+
+ private List<String> getOptionsParamAsList(final String optionsParamInQuery) {
+ final List<String> queryParamAsList = new LinkedList<>();
+ if (!StringUtils.isEmpty(optionsParamInQuery)) {
+ final String tempQuery = stripParenthesisFromOptionsQuery(optionsParamInQuery);
+ queryParamAsList.addAll(Arrays.asList(tempQuery.split(",")));
}
- return queryList;
+ return queryParamAsList;
}
+ @NotNull
+ private String stripParenthesisFromOptionsQuery(final String optionsParamInQuery) {
+ return optionsParamInQuery.substring(1, optionsParamInQuery.length() - 1);
+ }
@NotNull
private String prepareGetSchemaUrl(final String nodeId) {
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 0ea666e1..1a3b843f 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -54,7 +54,7 @@ management:
cps-core:
baseUrl: http://${CPS_CORE_HOST}:${CPS_CORE_PORT}
- dmiRegistrationUrl : /ncmp/v1/ch
+ dmiRegistrationUrl : /ncmpInventory/v1/ch
auth:
username: ${CPS_CORE_USERNAME}
password: ${CPS_CORE_PASSWORD}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy
new file mode 100644
index 00000000..1798c9f2
--- /dev/null
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy
@@ -0,0 +1,66 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.config
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.boot.web.client.RestTemplateBuilder
+import org.springframework.test.context.ContextConfiguration
+import spock.lang.Specification
+
+@SpringBootTest
+@ContextConfiguration(classes = [DmiConfiguration.CpsProperties, DmiConfiguration.SdncProperties])
+class DmiConfigurationSpec extends Specification {
+
+ @Autowired
+ DmiConfiguration.CpsProperties cpsProperties
+
+ @Autowired
+ DmiConfiguration.SdncProperties sdncProperties
+
+ def 'CPS properties configuration.'() {
+ expect: 'CPS properties are set to values in test configuration yaml file'
+ cpsProperties.baseUrl == 'some url for cps'
+ cpsProperties.dmiRegistrationUrl == 'some registration url'
+ cpsProperties.authUsername == 'some cps core user'
+ cpsProperties.authPassword == 'some cps core password'
+ }
+
+ def 'SDNC properties configuration.'() {
+ expect: 'SDNC properties are set to values in test configuration yaml file'
+ sdncProperties.authUsername == 'test'
+ sdncProperties.authPassword == 'test'
+ sdncProperties.baseUrl == 'http://test'
+ sdncProperties.topologyId == 'test-topology'
+ }
+
+ def 'Rest template building.'() {
+ given: 'a DMI configuration'
+ DmiConfiguration objectUnderTest = new DmiConfiguration()
+ and: 'a rest template builder'
+ RestTemplateBuilder mockRestTemplateBuilder = Mock(RestTemplateBuilder)
+ when: 'rest template method is invoked'
+ objectUnderTest.restTemplate(mockRestTemplateBuilder)
+ then: 'DMI configuration uses the build method on the template builder'
+ 1 * mockRestTemplateBuilder.build()
+ }
+
+}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiPluginConfigSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiPluginConfigSpec.groovy
new file mode 100644
index 00000000..64b82329
--- /dev/null
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiPluginConfigSpec.groovy
@@ -0,0 +1,52 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.config
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import spock.lang.Specification
+import springfox.documentation.spring.web.plugins.Docket
+
+@SpringBootTest
+@ContextConfiguration(classes = [DmiPluginConfig.DmiPluginProperties])
+class DmiPluginConfigSpec extends Specification {
+
+ @Autowired
+ DmiPluginConfig.DmiPluginProperties dmiPluginProperties
+
+ def 'DMI plugin properties configuration.'() {
+ expect: 'DMI plugin properties are set to values in test configuration yaml file'
+ dmiPluginProperties.dmiServiceUrl == 'some url for the dmi service'
+ }
+
+ def 'DMI plugin docket creation.'() {
+ given: 'a DMI plugin configuration'
+ DmiPluginConfig objectUnderTest = new DmiPluginConfig()
+ when: 'the api method is invoked'
+ def result = objectUnderTest.api()
+ then: 'a spring web plugin docket is returned'
+ result instanceof Docket
+ and: 'it is named "dmi-plugin-docket"'
+ result.groupName == 'dmi-plugin-docket'
+ }
+
+}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/model/ModuleSchemaPropertiesSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/model/ModuleSchemaPropertiesSpec.groovy
new file mode 100644
index 00000000..51dddc7d
--- /dev/null
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/model/ModuleSchemaPropertiesSpec.groovy
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.dmi.model
+
+import org.onap.cps.ncmp.dmi.service.model.ModuleSchemaProperties
+import spock.lang.Specification
+
+class ModuleSchemaPropertiesSpec extends Specification {
+ def objectUnderTest = new ModuleSchemaProperties(identifier:'some id',
+ version:'some version',
+ format:'some format',
+ namespace:'some namespace',
+ location: ['some','locations'])
+
+ def 'Reading all properties.'() {
+ expect: 'all properties return the expected values'
+ objectUnderTest.identifier == 'some id'
+ objectUnderTest.version == 'some version'
+ objectUnderTest.format == 'some format'
+ objectUnderTest.namespace == 'some namespace'
+ objectUnderTest.location == ['some','locations']
+ }
+}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
index 9c27dc1b..ac78928d 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
@@ -20,14 +20,13 @@
package org.onap.cps.ncmp.dmi.rest.controller
-
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.dmi.TestUtils
import org.onap.cps.ncmp.dmi.exception.DmiException
import org.onap.cps.ncmp.dmi.exception.ModuleResourceNotFoundException
import org.onap.cps.ncmp.dmi.exception.ModulesNotFoundException
-import org.onap.cps.ncmp.dmi.model.ModuleReference
-import org.onap.cps.ncmp.dmi.model.ModuleSchemaList
+import org.onap.cps.ncmp.dmi.service.model.ModuleReference
+import org.onap.cps.ncmp.dmi.service.model.ModuleSchemaList
import org.onap.cps.ncmp.dmi.model.ModuleSet
import org.onap.cps.ncmp.dmi.model.ModuleSetSchemas
import org.onap.cps.ncmp.dmi.model.YangResource
@@ -66,7 +65,7 @@ class DmiRestControllerSpec extends Specification {
given: 'REST endpoint for getting all modules'
def getModuleUrl = "$basePathV1/ch/node1/modules"
and: 'get modules for cm-handle returns a json'
- def json = '{"operation" : "read", "cmHandleProperties" : {}}'
+ def json = '{"cmHandleProperties" : {}}'
def moduleSetSchema = new ModuleSetSchemas(namespace:'some-namespace',
moduleName:'some-moduleName',
revision:'some-revision')
@@ -102,7 +101,7 @@ class DmiRestControllerSpec extends Specification {
given: 'REST endpoint for getting all modules'
def getModuleUrl = "$basePathV1/ch/node1/modules"
and: 'given request body and get modules for cm-handle throws #exceptionClass'
- def json = '{"operation" : "read", "cmHandleProperties" : {}}'
+ def json = '{"cmHandleProperties" : {}}'
mockDmiService.getModulesForCmHandle('node1') >> { throw Mock(exceptionClass) }
when: 'post is invoked'
def response = mvc.perform( post(getModuleUrl)
@@ -151,7 +150,7 @@ class DmiRestControllerSpec extends Specification {
def 'Retrieve module resources.'() {
given: 'an endpoint and json data'
def getModulesEndpoint = "$basePathV1/ch/some-cm-handle/moduleResources"
- def jsonData = TestUtils.getResourceFileContent('GetModules.json')
+ String jsonData = TestUtils.getResourceFileContent('GetModules.json')
and: 'the DMI service returns the yang resources'
ModuleReference moduleReference1 = new ModuleReference(name: 'ietf-yang-library', revision: '2016-06-21')
ModuleReference moduleReference2 = new ModuleReference(name: 'nc-notifications', revision: '2008-07-14')
@@ -173,7 +172,7 @@ class DmiRestControllerSpec extends Specification {
def 'Retrieve module resources with exception handling.'() {
given: 'an endpoint and json data'
def getModulesEndpoint = "$basePathV1/ch/some-cm-handle/moduleResources"
- def jsonData = TestUtils.getResourceFileContent('GetModules.json')
+ String jsonData = TestUtils.getResourceFileContent('GetModules.json')
and: 'the service method is invoked to get module resources and throws an exception'
mockDmiService.getModuleResources('some-cm-handle', _) >> { throw Mock(ModuleResourceNotFoundException.class) }
when: 'get module resource api is invoked'
@@ -187,7 +186,7 @@ class DmiRestControllerSpec extends Specification {
def 'Get resource data for pass-through operational from cm handle.'() {
given: 'Get resource data url'
def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-operational" +
- "/resourceIdentifier?fields=myfields&depth=5"
+ "?resourceIdentifier=parent/child&options=(fields=myfields,depth=5)"
def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}'
when: 'get resource data PUT api is invoked'
def response = mvc.perform(
@@ -198,16 +197,16 @@ class DmiRestControllerSpec extends Specification {
response.status == HttpStatus.OK.value()
and: 'dmi service called with get resource data for cm handle'
1 * mockDmiService.getResourceDataOperationalForCmHandle('some-cmHandle',
- 'resourceIdentifier',
+ 'parent/child',
'application/json',
- 'myfields',
- 5,
+ '(fields=myfields,depth=5)',
['prop1': 'value1', 'prop2': 'value2'])
}
def 'Write data using passthrough running for a cm handle using #scenario.'() {
given: 'write data for cmHandle url and jsonData'
- def writeDataforCmHandlePassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running/some-resourceIdentifier"
+ def writeDataforCmHandlePassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ "?resourceIdentifier=some-resourceIdentifier"
def jsonData = TestUtils.getResourceFileContent(requestBodyFile)
and: 'dmi service is called'
mockDmiService.writeResourceDataPassthroughForCmHandle('some-cmHandle',
@@ -228,10 +227,10 @@ class DmiRestControllerSpec extends Specification {
'data with special chars' | 'dataWithSpecialChar.json'|| 'data with quote \" and new line \n'
}
- def 'Get resource data for pass-through running from cm handle.'() {
+ def 'Get resource data for pass-through running from cm handle with #scenario value in resource identifier param.'() {
given: 'Get resource data url'
def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" +
- "/testResourceIdentifier?fields=testFields&depth=5"
+ "?resourceIdentifier="+resourceIdentifier+"&options=(fields=myfields,depth=5)"
def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}'
when: 'get resource data PUT api is invoked'
def response = mvc.perform(
@@ -242,10 +241,18 @@ class DmiRestControllerSpec extends Specification {
response.status == HttpStatus.OK.value()
and: 'dmi service called with get resource data for cm handle'
1 * mockDmiService.getResourceDataPassThroughRunningForCmHandle('some-cmHandle',
- 'testResourceIdentifier',
+ resourceIdentifier,
'application/json',
- 'testFields',
- 5,
+ '(fields=myfields,depth=5)',
['prop1':'value1', 'prop2':'value2'])
+ where: 'tokens are used in the resource identifier parameter'
+ scenario | resourceIdentifier
+ '/' | 'id/with/slashes'
+ '?' | 'idWith?'
+ ',' | 'idWith,'
+ '=' | 'idWith='
+ '[]' | 'idWith[]'
+ '? needs to be encoded as %3F' | 'idWith%3F'
+
}
-} \ No newline at end of file
+}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
index 93bc641e..9325d59b 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
@@ -22,6 +22,7 @@ package org.onap.cps.ncmp.dmi.service
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.ObjectWriter
import org.onap.cps.ncmp.dmi.TestUtils
import org.onap.cps.ncmp.dmi.config.DmiPluginConfig
import org.onap.cps.ncmp.dmi.exception.CmHandleRegistrationException
@@ -29,7 +30,7 @@ import org.onap.cps.ncmp.dmi.exception.DmiException
import org.onap.cps.ncmp.dmi.exception.ModuleResourceNotFoundException
import org.onap.cps.ncmp.dmi.exception.ModulesNotFoundException
import org.onap.cps.ncmp.dmi.exception.ResourceDataNotFound
-import org.onap.cps.ncmp.dmi.model.ModuleReference
+import org.onap.cps.ncmp.dmi.service.model.ModuleReference
import org.onap.cps.ncmp.dmi.model.YangResource
import org.onap.cps.ncmp.dmi.model.YangResources
import org.onap.cps.ncmp.dmi.service.client.NcmpRestClient
@@ -43,10 +44,10 @@ class DmiServiceImplSpec extends Specification {
def mockNcmpRestClient = Mock(NcmpRestClient)
def mockDmiPluginProperties = Mock(DmiPluginConfig.DmiPluginProperties)
- def objectMapper = new ObjectMapper()
+ def spyObjectMapper = Spy(ObjectMapper)
def mockObjectMapper = Mock(ObjectMapper)
def mockSdncOperations = Mock(SdncOperations)
- def objectUnderTest = new DmiServiceImpl(mockDmiPluginProperties, mockNcmpRestClient, mockSdncOperations, objectMapper)
+ def objectUnderTest = new DmiServiceImpl(mockDmiPluginProperties, mockNcmpRestClient, mockSdncOperations, spyObjectMapper)
def 'Call get modules for cm-handle on dmi Service.'() {
given: 'cm handle id'
@@ -175,31 +176,48 @@ class DmiServiceImplSpec extends Specification {
def 'Get module resources when sdnc returns #scenario response.'() {
given: 'get module schema is invoked and returns a response from sdnc'
- mockSdncOperations.getModuleResource(_ as String, _ as String) >> new ResponseEntity<String>('some-response-body', httpResponse)
+ mockSdncOperations.getModuleResource(_ as String, _ as String) >> new ResponseEntity<String>('some-response-body', httpStatus)
when: 'get module resources is invoked with the given cm handle and a module list'
objectUnderTest.getModuleResources('some-cmHandle', [new ModuleReference()] as LinkedList<ModuleReference>)
- then: 'ModuleResourceNotFoundException is thrown'
- thrown(exception)
+ then: '#expectedException is thrown'
+ thrown(expectedException)
where: 'the following values are returned'
- scenario | httpResponse || exception
+ scenario | httpStatus || expectedException
'not found' | HttpStatus.NOT_FOUND || ModuleResourceNotFoundException
'a internal server' | HttpStatus.INTERNAL_SERVER_ERROR || DmiException
}
+ def 'Get module resources with JSON processing exception.'() {
+ given: 'a json processing exception during conversion'
+ def mockObjectWriter = Mock(ObjectWriter)
+ spyObjectMapper.writer() >> mockObjectWriter
+ mockObjectWriter.withRootName(_) >> mockObjectWriter
+ def jsonProcessingException = new JsonProcessingException('')
+ mockObjectWriter.writeValueAsString(_) >> { throw jsonProcessingException }
+ when: 'get module resources is invoked with the given cm handle and a module list'
+ objectUnderTest.getModuleResources('some-cmHandle', [new ModuleReference()] as LinkedList<ModuleReference>)
+ then: 'a DMI exception is thrown'
+ def thrownException = thrown(DmiException.class)
+ and: 'the exception has the expected message and details'
+ thrownException.message == 'Unable to process JSON.'
+ thrownException.details == 'JSON exception occurred when creating the module request.'
+ and: 'the cause is the original json processing exception'
+ thrownException.cause == jsonProcessingException
+ }
+
def 'Get resource data for pass through operational from cm handle.'() {
given: 'cm-handle, pass through parameter, resourceId, accept header, fields, depth'
def cmHandle = 'testCmHandle'
def resourceId = 'testResourceId'
def acceptHeaderParam = 'testAcceptParam'
- def fieldsParam = 'testFields'
- def depthParam = 10
+ def optionsParam = '(fields=x/y/z,depth=10,test=abc)'
def contentQuery = 'content=all'
and: 'sdnc operation returns OK response'
- mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, fieldsParam, depthParam, acceptHeaderParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam, acceptHeaderParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
when: 'get resource data from cm handles service method invoked'
def response = objectUnderTest.getResourceDataOperationalForCmHandle(cmHandle,
resourceId, acceptHeaderParam,
- fieldsParam, depthParam, null)
+ optionsParam, null)
then: 'response have expected json'
response == 'response json'
}
@@ -209,14 +227,13 @@ class DmiServiceImplSpec extends Specification {
def cmHandle = 'testCmHandle'
def resourceId = 'testResourceId'
def acceptHeaderParam = 'testAcceptParam'
- def fieldsParam = 'testFields'
- def depthParam = 10
+ def optionsParam = '(fields=x/y/z,depth=10,test=abc)'
and: 'sdnc operation returns "NOT_FOUND" response'
- mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, fieldsParam, depthParam, acceptHeaderParam, _ as String) >> new ResponseEntity<>(HttpStatus.NOT_FOUND)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam, acceptHeaderParam, _ as String) >> new ResponseEntity<>(HttpStatus.NOT_FOUND)
when: 'get resource data from cm handles service method invoked'
objectUnderTest.getResourceDataOperationalForCmHandle(cmHandle,
resourceId, acceptHeaderParam,
- fieldsParam, depthParam, null)
+ optionsParam, null)
then: 'resource data not found'
thrown(ResourceDataNotFound.class)
}
@@ -226,16 +243,15 @@ class DmiServiceImplSpec extends Specification {
def cmHandle = 'testCmHandle'
def resourceId = 'testResourceId'
def acceptHeaderParam = 'testAcceptParam'
- def fieldsParam = 'testFields'
- def depthParam = 10
+ def optionsParam = '(fields=x/y/z,depth=10,test=abc)'
def contentQuery = 'content=config'
and: 'sdnc operation returns OK response'
- mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, fieldsParam,
- depthParam, acceptHeaderParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam,
+ acceptHeaderParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
when: 'get resource data from cm handles service method invoked'
def response = objectUnderTest.getResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceId, acceptHeaderParam,
- fieldsParam, depthParam, null)
+ optionsParam, null)
then: 'response have expected json'
response == 'response json'
}
@@ -278,4 +294,4 @@ class DmiServiceImplSpec extends Specification {
then: 'a dmi exception is thrown'
thrown(DmiException.class)
}
-} \ No newline at end of file
+}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy
index 14a62ebb..4411971a 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy
@@ -61,10 +61,10 @@ class SdncOperationsSpec extends Specification {
def 'Get resource data from node to SDNC.'() {
given: 'expected url, topology-id, sdncOperation object'
- def expectedUrl = '/rests/data/network-topology:network-topology/topology=test-topology/node=node1/yang-ext:mount/testResourceId?fields=testFields&depth=10&content=testContent'
+ def expectedUrl = '/rests/data/network-topology:network-topology/topology=test-topology/node=node1/yang-ext:mount/testResourceId?a=1&b=2&content=testContent'
when: 'called get modules from node'
objectUnderTest.getResouceDataForOperationalAndRunning('node1', 'testResourceId',
- 'testFields', 10, 'testAcceptParam', 'content=testContent')
+ '(a=1,b=2)', 'testAcceptParam', 'content=testContent')
then: 'the get operation is executed with the correct URL'
1 * mockSdncRestClient.getOperation(expectedUrl, _ as HttpHeaders)
}
@@ -77,4 +77,33 @@ class SdncOperationsSpec extends Specification {
then: 'the post operation is executed with the correct URL and data'
1 * mockSdncRestClient.postOperationWithJsonData(expectedUrl, 'requestData', _ as HttpHeaders)
}
-} \ No newline at end of file
+
+ def 'build query param list for SDNC where options contains a #scenario'() {
+ when: 'build query param list is called with #scenario'
+ def result = objectUnderTest.buildQueryParamList(optionsParamInQuery,'d=4')
+ then: 'result equals to expected result'
+ result == expectedResult
+ where: 'following parameters are used'
+ scenario | optionsParamInQuery || expectedResult
+ 'single key-value pair' | '(a=x)' || ['a=x','d=4']
+ 'multiple key-value pairs'| '(a=x,b=y,c=z)' || ['a=x','b=y','c=z','d=4']
+ '/ as special char' | '(a=x,b=y,c=t/z)' || ['a=x','b=y','c=t/z','d=4']
+ '" as special char' | '(a=x,b=y,c="z")' || ['a=x','b=y','c="z"','d=4']
+ '[] as special char' | '(a=x,b=y,c=[z])' || ['a=x','b=y','c=[z]','d=4']
+ '= in value' | '(a=(x=y),b=x=y)' || ['a=(x=y)','b=x=y','d=4']
+ }
+
+ def 'options parameters contains a comma #scenario'() {
+ // https://jira.onap.org/browse/CPS-719
+ when: 'build query param list is called with #scenario'
+ def result = objectUnderTest.buildQueryParamList(optionsParamInQuery,'d=4')
+ then: 'expect 2 elements from options +1 from content query param (2+1) = 3 elements'
+ def expectedNoOfElements = 3
+ and: 'results contains more elements than expected'
+ result.size() > expectedNoOfElements
+ where: 'following parameters are used'
+ scenario | optionsParamInQuery
+ '"," in value' | '(a=(x,y),b=y)'
+ '"," in string value' | '(a="x,y",b=y)'
+ }
+}
diff --git a/src/test/resources/GetModules.json b/src/test/resources/GetModules.json
index 23fe77c2..57f5aefd 100644
--- a/src/test/resources/GetModules.json
+++ b/src/test/resources/GetModules.json
@@ -1,5 +1,4 @@
{
- "operation": "read",
"data": {
"modules": [
{
@@ -15,4 +14,4 @@
"cmHandleProperties": {
"subsystemId": "system-001"
}
-} \ No newline at end of file
+}
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index e8ca3d01..dc30c9da 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -31,3 +31,15 @@ sdnc:
auth:
username: test
password: test
+
+cps-core:
+ baseUrl: some url for cps
+ dmiRegistrationUrl: some registration url
+ auth:
+ username: some cps core user
+ password: some cps core password
+
+dmi:
+ service:
+ url: some url for the dmi service
+