aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
authorJosephKeenan <joseph.keenan@est.tech>2021-11-23 12:18:28 +0000
committerJosephKeenan <joseph.keenan@est.tech>2021-11-25 15:40:10 +0000
commit20b4f9cf0b662de4a7665b2a82593ef0205f5e06 (patch)
treeab849ff17b861f246c328e421e8dcfc8ceb9e851 /cps-ncmp-rest
parentbc742a1dbe39a3269abab9e62a9d489f460144b0 (diff)
Allow separate registration of DMIDataPlugin and DmiModelPugin
Moved relevant code from NetworkCmProxyDataServiceImp to DmiOperations Split DmiOperations into DMiData... and DMIModelOperations Merged update-operation changes Added tests for error message validation in NetworkCmProxyDataServiceImplSpec Removede @Service from DMIOperations and added @component to DmiDataOperations & DmiModelOperations Verify sync robot test is now hardened Added exitonfailure so robot tests stop after first encountered failed test Issue-ID: CPS-736 Change-Id: I0b40931cc8cd4fc0452328a0a7e0f60e6fc38d0a Signed-off-by: JosephKeenan <joseph.keenan@est.tech> Signed-off-by: ToineSiebelink <toine.siebelink@est.tech> Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'cps-ncmp-rest')
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml6
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java55
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy45
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy27
-rw-r--r--cps-ncmp-rest/src/test/resources/dmi_registration_combined_valid.json8
5 files changed, 104 insertions, 37 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index 7c9e1e837..da1878fea 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -38,6 +38,12 @@ components:
dmiPlugin:
type: string
example: onap-dmi-plugin
+ dmiDataPlugin:
+ type: string
+ example: onap-dmi-data-plugin
+ dmiModelPlugin:
+ type: string
+ example: onap-dmi-model-plugin
createdCmHandles:
type: array
items:
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index 449a4344d..222957c9f 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -22,6 +22,9 @@
package org.onap.cps.ncmp.rest.controller;
+import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.CREATE;
+import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE;
+
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.ArrayList;
@@ -132,14 +135,6 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return new ResponseEntity<>(HttpStatus.OK);
}
- @Override
- public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String resourceIdentifier,
- final String cmHandle, final String requestBody, final String contentType) {
- networkCmProxyDataService.updateResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, requestBody, contentType);
- return new ResponseEntity<>(HttpStatus.OK);
- }
-
/**
* Update Node Leaves.
* @deprecated This Method is no longer used as part of NCMP.
@@ -195,25 +190,49 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
}
/**
- * Create resource data in datastore pass through running
- * for given cm-handle.
+ * Create resource data in datastore pass through running for given cm-handle.
*
* @param resourceIdentifier resource identifier
* @param cmHandle cm handle identifier
- * @param requestBody requestBody
+ * @param requestBody the request body
* @param contentType content type of body
- * @return {@code ResponseEntity} response from dmi plugi
+ * @return {@code ResponseEntity} response from dmi plugin
*/
@Override
public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String resourceIdentifier,
final String cmHandle,
final String requestBody,
final String contentType) {
- networkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle(cmHandle,
- resourceIdentifier, requestBody, contentType);
+ networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ resourceIdentifier, CREATE, requestBody, contentType);
return new ResponseEntity<>(HttpStatus.CREATED);
}
+ /**
+ * Update resource data in datastore pass through running for given cm-handle.
+ *
+ * @param resourceIdentifier resource identifier
+ * @param cmHandle cm handle identifier
+ * @param requestBody the request body
+ * @param contentType content type of the body
+ * @return response entity
+ */
+ @Override
+ public ResponseEntity<Object> updateResourceDataRunningForCmHandle(final String resourceIdentifier,
+ final String cmHandle,
+ final String requestBody,
+ final String contentType) {
+ networkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle(cmHandle,
+ resourceIdentifier, UPDATE, requestBody, contentType);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ /**
+ * Execute cm handle search.
+ *
+ * @param conditions the conditions
+ * @return cm handles returned from search.
+ */
@Override
public ResponseEntity<CmHandles> executeCmHandleSearch(final Conditions conditions) {
final List<ConditionProperties> conditionProperties =
@@ -223,6 +242,12 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
return ResponseEntity.ok(cmHandles);
}
+ /**
+ * Return module references for a cm handle.
+ *
+ * @param cmHandle the cm handle
+ * @return module references for cm handle
+ */
@Override
public ResponseEntity<Object> getModuleReferencesByCmHandle(final String cmHandle) {
final Collection<ModuleReference>
@@ -264,6 +289,4 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
}
return cmHandleProperties;
}
-
-
}
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index e96b27df8..436f22b32 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -31,6 +31,8 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put
+import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.CREATE
+import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE
import com.google.gson.Gson
import org.onap.cps.ncmp.api.NetworkCmProxyDataService
@@ -219,19 +221,36 @@ class NetworkCmProxyControllerSpec extends Specification {
'? needs to be encoded as %3F' | 'idWith%3F'
}
+ def 'Update resource data from passthrough running.' () {
+ given: 'update resource data url'
+ def updateUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ "?resourceIdentifier=parent/child"
+ when: 'update data resource request is performed'
+ def response = mvc.perform(
+ put(updateUrl)
+ .contentType(MediaType.APPLICATION_JSON_VALUE)
+ .accept(MediaType.APPLICATION_JSON_VALUE).content('some-request-body')
+ ).andReturn().response
+ then: 'ncmp service method to update resource is called'
+ 1 * mockNetworkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'parent/child', UPDATE,'some-request-body', 'application/json;charset=UTF-8')
+ and: 'the response status is OK'
+ response.status == HttpStatus.OK.value()
+ }
+
def 'Create Resource Data from passthrough running with #scenario.' () {
given: 'resource data url'
- def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ def url = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
"?resourceIdentifier=parent/child"
- when: 'get data resource request is performed'
+ when: 'create resource request is performed'
def response = mvc.perform(
- post(getUrl)
+ post(url)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
).andReturn().response
then: 'ncmp service method to create resource called'
- 1 * mockNetworkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle('testCmHandle',
- 'parent/child', requestBody, 'application/json;charset=UTF-8')
+ 1 * mockNetworkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle('testCmHandle',
+ 'parent/child', CREATE, requestBody, 'application/json;charset=UTF-8')
and: 'resource is created'
response.status == HttpStatus.CREATED.value()
where: 'given request body'
@@ -282,21 +301,5 @@ class NetworkCmProxyControllerSpec extends Specification {
response.contentAsString == '{"cmHandles":[]}'
}
- def 'Update resource data from passthrough running.' () {
- given: 'update resource data url'
- def updateUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
- "?resourceIdentifier=parent/child"
- when: 'update data resource request is performed'
- def response = mvc.perform(
- put(updateUrl)
- .contentType(MediaType.APPLICATION_JSON_VALUE)
- .accept(MediaType.APPLICATION_JSON_VALUE).content('some-request-body')
- ).andReturn().response
- then: 'ncmp service method to update resource is called'
- 1 * mockNetworkCmProxyDataService.updateResourceDataPassThroughRunningForCmHandle('testCmHandle',
- 'parent/child', 'some-request-body', 'application/json;charset=UTF-8')
- and: 'the response status is OK'
- response.status == HttpStatus.OK.value()
- }
}
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
index e558ac45b..4addf7bdf 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
@@ -22,6 +22,10 @@ package org.onap.cps.ncmp.rest.controller
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.TestUtils
import org.onap.cps.ncmp.api.NetworkCmProxyDataService
+import org.onap.cps.ncmp.api.impl.NetworkCmProxyDataServiceImpl
+import org.onap.cps.ncmp.api.models.CmHandle
+import org.onap.cps.ncmp.api.models.DmiPluginRegistration
+import org.onap.cps.ncmp.api.models.PersistenceCmHandle
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
@@ -61,5 +65,28 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
response.status == HttpStatus.CREATED.value()
}
+ def 'Dmi plugin registration with #scenario' () {
+ given: 'jsonData, cmHandle, & DmiPluginRegistration'
+ def jsonData = TestUtils.getResourceFileContent('dmi_registration_combined_valid.json' )
+ def cmHandle = new CmHandle(cmHandleID : 'example-name')
+ def expectedDmiPluginRegistration = new DmiPluginRegistration(
+ dmiPlugin: 'service1',
+ dmiDataPlugin: '',
+ dmiModelPlugin: '',
+ createdCmHandles: [cmHandle])
+ when: 'post request is performed & registration is called with correct DMI plugin information'
+ def response = mvc.perform(
+ post("$ncmpBasePathV1/ch")
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(jsonData)
+ ).andReturn().response
+ then: 'no NcmpException is thrown & updateDmiRegistrationAndSyncModule is called with correct parameters'
+ 1 * mockNetworkCmProxyDataService.updateDmiRegistrationAndSyncModule({
+ it.getDmiPlugin() == expectedDmiPluginRegistration.getDmiPlugin()
+ it.getDmiDataPlugin() == expectedDmiPluginRegistration.getDmiDataPlugin()
+ it.getDmiModelPlugin() == expectedDmiPluginRegistration.getDmiModelPlugin()
+ it.getCreatedCmHandles().get(0).getCmHandleID() == expectedDmiPluginRegistration.getCreatedCmHandles().get(0).getCmHandleID()
+ })
+ }
}
diff --git a/cps-ncmp-rest/src/test/resources/dmi_registration_combined_valid.json b/cps-ncmp-rest/src/test/resources/dmi_registration_combined_valid.json
new file mode 100644
index 000000000..bded4f215
--- /dev/null
+++ b/cps-ncmp-rest/src/test/resources/dmi_registration_combined_valid.json
@@ -0,0 +1,8 @@
+{
+ "dmiPlugin": "service1",
+ "dmiDataPlugin": "",
+ "dmiModelPlugin": "",
+ "createdCmHandles": [{
+ "cmHandle": "example-name"
+ }]
+} \ No newline at end of file