summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy25
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy31
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy5
3 files changed, 51 insertions, 10 deletions
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 f24f65a8..b1528c71 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
@@ -186,12 +186,12 @@ class DmiRestControllerSpec extends Specification {
response.status == HttpStatus.NOT_FOUND.value()
}
- def 'Get resource data for cm handle.'() {
+ 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"
def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}'
- when: 'get resource data GET api is invoked'
+ when: 'get resource data PUT api is invoked'
def response = mvc.perform(
put(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON).content(json)
@@ -206,4 +206,25 @@ class DmiRestControllerSpec extends Specification {
5,
['prop1':'value1', 'prop2':'value2'])
}
+
+ def 'Get resource data for pass-through running from cm handle.'() {
+ given: 'Get resource data url'
+ def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" +
+ "/testResourceIdentifier?fields=testFields&depth=5"
+ def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}'
+ when: 'get resource data PUT api is invoked'
+ def response = mvc.perform(
+ put(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON).content(json)
+ ).andReturn().response
+ then: 'response status is ok'
+ response.status == HttpStatus.OK.value()
+ and: 'dmi service called with get resource data for cm handle'
+ 1 * mockDmiService.getResourceDataPassThroughRunningForCmHandle('some-cmHandle',
+ 'testResourceIdentifier',
+ 'application/json',
+ 'testFields',
+ 5,
+ ['prop1':'value1', 'prop2':'value2'])
+ }
} \ 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 e456d411..31b60a7c 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
@@ -30,8 +30,6 @@ 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.model.ModuleSchemaList
-import org.onap.cps.ncmp.dmi.model.ModuleSchemas
import org.onap.cps.ncmp.dmi.service.client.NcmpRestClient
import org.onap.cps.ncmp.dmi.service.operation.SdncOperations
import org.springframework.http.HttpStatus
@@ -166,15 +164,17 @@ class DmiServiceImplSpec extends Specification {
thrown(ModuleResourceNotFoundException)
}
- def 'Get resource data from cm handle.'() {
+ 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 contentQuery = 'content=all'
and: 'sdnc operation returns OK response'
- mockSdncOperations.getResouceDataForOperational(cmHandle, resourceId, fieldsParam, depthParam, acceptHeaderParam ) >> new ResponseEntity<>('response json', HttpStatus.OK)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, fieldsParam,
+ depthParam, 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,
@@ -191,8 +191,8 @@ class DmiServiceImplSpec extends Specification {
def fieldsParam = 'testFields'
def depthParam = 10
and: 'sdnc operation returns "NOT_FOUND" response'
- mockSdncOperations.getResouceDataForOperational(cmHandle, resourceId, fieldsParam, depthParam, acceptHeaderParam )
- >> new ResponseEntity<>(HttpStatus.NOT_FOUND)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, fieldsParam,
+ depthParam, acceptHeaderParam, _ as String) >> new ResponseEntity<>(HttpStatus.NOT_FOUND)
when: 'get resource data from cm handles service method invoked'
objectUnderTest.getResourceDataOperationalForCmHandle(cmHandle,
resourceId, acceptHeaderParam,
@@ -200,4 +200,23 @@ class DmiServiceImplSpec extends Specification {
then: 'resource data not found'
thrown(ResourceDataNotFound.class)
}
+
+ def 'Get resource data for pass through running 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 contentQuery = 'content=config'
+ and: 'sdnc operation returns OK response'
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, fieldsParam,
+ depthParam, 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)
+ then: 'response have expected json'
+ response == 'response json'
+ }
} \ 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 8a415c82..3557bc1b 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,9 +61,10 @@ class SdncOperationsSpec extends Specification {
def 'Get resource data from node to SDNC.'() {
given: 'excpected 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=all'
+ def expectedUrl = '/rests/data/network-topology:network-topology/topology=test-topology/node=node1/yang-ext:mount/testResourceId?fields=testFields&depth=10&content=testContent'
when: 'called get modules from node'
- objectUnderTest.getResouceDataForOperational('node1', 'testResourceId', 'testFields', 10,'testAcceptParam')
+ objectUnderTest.getResouceDataForOperationalAndRunning('node1', 'testResourceId',
+ 'testFields', 10, 'testAcceptParam', 'content=testContent')
then: 'the get operation is executed with the correct URL'
1 * mockSdncRestClient.getOperation(expectedUrl, _ as HttpHeaders)
}