diff options
author | mpriyank <priyank.maheshwari@est.tech> | 2024-03-06 12:52:47 +0000 |
---|---|---|
committer | Priyank Maheshwari <priyank.maheshwari@est.tech> | 2024-03-06 15:25:00 +0000 |
commit | 351f39126899711dd0ec4fcee35b1f5fbd295bbb (patch) | |
tree | 90e3a59e3d0515635ef21b7ed59fe3b65f701ae4 /src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy | |
parent | 344e546241667dddc80f5296398780d09ed48009 (diff) |
Remove old subscription code and other fixes
- removed old subscription related dummy code.
- updated cps version to 3.4.6 to use the latest released version
- added six dependency for the RTD fix
- Removing the CloudEventMapper for now. Can be brought back when
somebody uses it
- added missing test for InvalidDatastoreException which was failing on
coverage check locally
Issue-ID: CPS-2149
Change-Id: I60e9036398fea82bb0162ab5524a1cc45dedb611
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy')
-rw-r--r-- | src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy | 35 |
1 files changed, 25 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 8ce9735a..7b2570b0 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 @@ -21,21 +21,19 @@ package org.onap.cps.ncmp.dmi.rest.controller - import org.onap.cps.ncmp.dmi.TestUtils import org.onap.cps.ncmp.dmi.config.WebSecurityConfig 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.ModuleSetSchemasInner -import org.onap.cps.ncmp.dmi.notifications.async.AsyncTaskExecutor -import org.onap.cps.ncmp.dmi.notifications.async.DmiAsyncRequestResponseEventProducer - -import org.onap.cps.ncmp.dmi.service.model.ModuleReference import org.onap.cps.ncmp.dmi.model.ModuleSet +import org.onap.cps.ncmp.dmi.model.ModuleSetSchemasInner import org.onap.cps.ncmp.dmi.model.YangResource import org.onap.cps.ncmp.dmi.model.YangResources +import org.onap.cps.ncmp.dmi.notifications.async.AsyncTaskExecutor +import org.onap.cps.ncmp.dmi.notifications.async.DmiAsyncRequestResponseEventProducer import org.onap.cps.ncmp.dmi.service.DmiService +import org.onap.cps.ncmp.dmi.service.model.ModuleReference import org.spockframework.spring.SpringBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value @@ -48,16 +46,17 @@ import org.springframework.security.test.context.support.WithMockUser import org.springframework.test.web.servlet.MockMvc import spock.lang.Specification +import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.CREATE import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.DELETE import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.PATCH import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.READ -import static org.springframework.http.HttpStatus.BAD_REQUEST -import static org.springframework.http.HttpStatus.NO_CONTENT -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post -import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.CREATE import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.UPDATE +import static org.springframework.http.HttpStatus.BAD_REQUEST import static org.springframework.http.HttpStatus.CREATED +import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR +import static org.springframework.http.HttpStatus.NO_CONTENT import static org.springframework.http.HttpStatus.OK +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post @Import(WebSecurityConfig) @WebMvcTest(DmiRestController.class) @@ -224,6 +223,22 @@ class DmiRestControllerSpec extends Specification { 0 * mockDmiService.getResourceData(*_) } + def 'Get resource data for invalid datastore'() { + given: 'Get resource data url' + def getResourceDataForCmHandleUrl = "${basePathV1}/ch/some-cmHandle/data/ds/dummy-datastore" + + "?resourceIdentifier=parent/child&options=(fields=myfields,depth=5)" + and: 'an invalid write request data for "create" operation' + def jsonData = '{"operation":"create"}' + when: 'the request is posted' + def response = mvc.perform( + post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON).content(jsonData) + ).andReturn().response + then: 'response status is internal server error' + response.status == INTERNAL_SERVER_ERROR.value() + and: 'response contains expected error message' + response.contentAsString.contains('dummy-datastore is an invalid datastore name') + } + def 'data with #scenario operation using passthrough running.'() { given: 'write data for passthrough running url' def writeDataForPassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" + |