X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2Foperation%2FDmiOperationsSpec.groovy;h=44d4f0ce2717fb04d6bb792d94770efd7defe36b;hb=6c7791e04e43b056ab944c3f7935f182fcbb13fb;hp=75b5383d8a1ea10f561fde1a9b0abe43aec6e304;hpb=dc5ed75c841da857611713bceed8bf9988204d3d;p=cps.git diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy index 75b5383d8..44d4f0ce2 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy @@ -22,7 +22,6 @@ package org.onap.cps.ncmp.api.impl.operation import org.onap.cps.ncmp.api.impl.client.DmiRestClient import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration -import org.onap.cps.ncmp.api.impl.operation.DmiOperations import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @@ -40,19 +39,98 @@ class DmiOperationsSpec extends Specification { @Autowired DmiOperations objectUnderTest = new DmiOperations(mockDmiRestClient) - def 'call get resource data for pass-through:operational datastore from dmi.'() { + def 'call get resource data for pass-through:operational datastore from DMI.'() { given: 'expected url' - def expectedUrl = 'testDmiBasePath/v1/ch/testCmhandle/data/ds' + - '/ncmp-datastore:passthrough-operational/testResourceId?fields=testFieldsQuery&depth=10' - when: 'get resource data is called to dmi' - objectUnderTest.getResouceDataFromDmi('testDmiBasePath', + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child&options=(a=1,b=2)' + when: 'get resource data is called to DMI' + objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath', 'testCmhandle', - 'testResourceId', - 'testFieldsQuery', - 10, + 'parent/child', + '(a=1,b=2)', 'testAcceptJson', 'testJsonbody') then: 'the put operation is executed with the correct URL' 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) } + def 'call get resource data for pass-through:running datastore from DMI.'() { + given: 'expected url' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child&options=(a=1,b=2)' + when: 'get resource data is called to DMI' + objectUnderTest.getResourceDataPassThroughRunningFromDmi('testDmiBasePath', + 'testCmhandle', + 'parent/child', + '(a=1,b=2)', + 'testAcceptJson', + 'testJsonbody') + then: 'the put operation is executed with the correct URL' + 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) + } + def 'call get resource data for pass-through:operational datastore from DMI when options is null.'() { + given: 'expected url' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child' + when: 'get resource data is called to DMI' + objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath', + 'testCmhandle', + 'parent/child', + null, + 'testAcceptJson', + 'testJsonbody') + then: 'the put operation is executed with the correct URL' + 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) + } + def 'call create resource data for pass-through:running datastore from DMI.'() { + given: 'expected url' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child' + when: 'get resource data is called to DMI' + objectUnderTest.createResourceDataPassThroughRunningFromDmi('testDmiBasePath', + 'testCmhandle', + 'parent/child', + 'testJsonbody') + then: 'the put operation is executed with the correct URL' + 1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) + } + + def 'Call get resource from dmi.'() { + given: 'expected url' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/modules' + when: 'get resource data is called to dmi' + objectUnderTest.getResourceFromDmi('testDmiBasePath', + 'testCmhandle', + 'modules') + then: 'the post operation is executed with the correct URL' + 1 * mockDmiRestClient.postOperation(expectedUrl, _ as HttpHeaders) + } + + def 'Call get resource from dmi with json data.'() { + given: 'expected url & json data' + def requestBody = 'some json' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmHandle/modules' + def expectedHttpHeaders = new HttpHeaders() + when: 'get resource data is called to dmi' + objectUnderTest.getResourceFromDmiWithJsonData('testDmiBasePath', + requestBody, + 'testCmHandle', + 'modules') + then: 'the post operation is executed with the correct URL and json data' + 1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, requestBody, expectedHttpHeaders) + } + + def 'Update resource data for pass-through:running datastore from DMI.'() { + given: 'the expected url' + def cmHandle = 'some-cmhandle' + def resourceIdentifier = 'parent/child' + def expectedUrl = 'some-dmi-service-name/dmi/v1/ch/' + cmHandle + '/data/ds' + + '/ncmp-datastore:passthrough-running?resourceIdentifier=' + resourceIdentifier + when: 'replace resource data is called for DMI' + objectUnderTest.updateResourceDataPassThroughRunningFromDmi('some-dmi-service-name', + cmHandle, + resourceIdentifier, + 'some-json-body') + then: 'the post operation is executed with the correct URL' + 1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, 'some-json-body', _ as HttpHeaders) + } } \ No newline at end of file