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
@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'
+ def expectedUrl = 'testDmiBasePath/dmi/api/v1/ch/testCmhandle/data/ds' +
+ '/ncmp-datastore:passthrough-operational/testResourceId?fields=testFieldsQuery&depth=10'
+ when: 'get resource data is called to DMI'
+ objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath',
+ 'testCmhandle',
+ 'testResourceId',
+ 'testFieldsQuery',
+ 10,
+ '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/api/v1/ch/testCmhandle/data/ds' +
+ '/ncmp-datastore:passthrough-running/testResourceId?fields=testFieldsQuery&depth=10'
+ when: 'get resource data is called to DMI'
+ objectUnderTest.getResourceDataPassThroughRunningFromDmi('testDmiBasePath',
+ 'testCmhandle',
+ 'testResourceId',
+ 'testFieldsQuery',
+ 10,
+ '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/api/v1/ch/testCmhandle/data/ds' +
+ '/ncmp-datastore:passthrough-running/testResourceId'
+ when: 'get resource data is called to DMI'
+ objectUnderTest.createResourceDataPassThroughRunningFromDmi('testDmiBasePath',
+ 'testCmhandle',
+ 'testResourceId',
+ '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/api/v1/ch/testCmhandle/modules'
when: 'get resource data is called to dmi'
- objectUnderTest.getResouceDataFromDmi('testDmiBasePath',
+ objectUnderTest.getResourceFromDmi('testDmiBasePath',
'testCmhandle',
- 'testResourceId',
- 'testFieldsQuery',
- 10,
- 'testAcceptJson',
- 'testJsonbody')
- then: 'the put operation is executed with the correct URL'
- 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders)
+ 'modules')
+ then: 'the post operation is executed with the correct URL'
+ 1 * mockDmiRestClient.postOperation(expectedUrl, _ as HttpHeaders)
}
}
\ No newline at end of file