From dffff5df568b0f7654dcf019cee2333b29db09e2 Mon Sep 17 00:00:00 2001 From: tragait Date: Mon, 10 Jan 2022 12:16:25 +0000 Subject: impl patch operation in dmi Change-Id: Ie87216fa6cb120bea685286b7f0dacd8e22f603b Signed-off-by: tragait Issue-ID: CPS-641 --- .../onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy | 2 +- .../dmi/rest/controller/DmiRestControllerSpec.groovy | 16 +++++++++------- .../ncmp/dmi/service/operation/SdncOperationsSpec.groovy | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/test/groovy/org') diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy index 1798c9f2..9d80b71f 100644 --- a/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy +++ b/src/test/groovy/org/onap/cps/ncmp/dmi/config/DmiConfigurationSpec.groovy @@ -56,7 +56,7 @@ class DmiConfigurationSpec extends Specification { given: 'a DMI configuration' DmiConfiguration objectUnderTest = new DmiConfiguration() and: 'a rest template builder' - RestTemplateBuilder mockRestTemplateBuilder = Mock(RestTemplateBuilder) + RestTemplateBuilder mockRestTemplateBuilder = Spy(RestTemplateBuilder) when: 'rest template method is invoked' objectUnderTest.restTemplate(mockRestTemplateBuilder) then: 'DMI configuration uses the build method on the template builder' 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 221603c2..ac632bb2 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 @@ -44,6 +44,7 @@ import org.springframework.test.web.servlet.MockMvc import spock.lang.Specification 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 @@ -211,14 +212,14 @@ class DmiRestControllerSpec extends Specification { 0 * mockDmiService.getResourceData(*_) } - def 'write data with #scenario operation using passthrough running.'() { + def 'data with #scenario operation using passthrough running.'() { given: 'write data for passthrough running url and jsonData' def writeDataForPassthroughRunning = "${basePathV1}/ch/some-cmHandle/data/ds/ncmp-datastore:passthrough-running" + "?resourceIdentifier=some-resourceIdentifier" def jsonData = TestUtils.getResourceFileContent(requestBodyFile) and: 'dmi service is called' mockDmiService.writeData(operationEnum, 'some-cmHandle', - 'some-resourceIdentifier', 'application/json', + 'some-resourceIdentifier', dataType, 'normal request body' ) >> '{some-json}' when: 'write data for passthrough running post api is invoked with json data' def response = mvc.perform( @@ -230,11 +231,12 @@ class DmiRestControllerSpec extends Specification { and: 'the data in the request body is as expected' response.getContentAsString() == expectedJsonResponse where: 'given request body and data' - scenario | requestBodyFile | operationEnum || expectedResponseStatus | expectedJsonResponse - 'Create' | 'createDataWithNormalChar.json' | CREATE || CREATED.value() | '{some-json}' - 'Update' | 'updateData.json' | UPDATE || OK.value() | '{some-json}' - 'Delete' | 'deleteData.json' | DELETE || NO_CONTENT.value() | '{some-json}' - 'Read' | 'readData.json' | READ || OK.value() | '' + scenario | requestBodyFile | operationEnum | dataType || expectedResponseStatus | expectedJsonResponse + 'Create' | 'createDataWithNormalChar.json' | CREATE | 'application/json' || CREATED.value() | '{some-json}' + 'Update' | 'updateData.json' | UPDATE | 'application/json' || OK.value() | '{some-json}' + 'Delete' | 'deleteData.json' | DELETE | 'application/json' || NO_CONTENT.value() | '{some-json}' + 'Read' | 'readData.json' | READ | 'application/json' || OK.value() | '' + 'Patch' | 'patchData.json' | PATCH | 'application/yang.patch+json' || OK.value() | '{some-json}' } def 'Create data using passthrough for special characters.'(){ 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 5079ada7..49cdc205 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 @@ -37,6 +37,7 @@ 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.UPDATE import static org.onap.cps.ncmp.dmi.model.DataAccessRequest.OperationEnum.READ @@ -138,6 +139,7 @@ class SdncOperationsSpec extends Specification { 'Update' | UPDATE || HttpMethod.PUT 'Read' | READ || HttpMethod.GET 'Delete' | DELETE || HttpMethod.DELETE + 'Patch' | PATCH || HttpMethod.PATCH } def 'build query param list for SDNC where options contains a #scenario'() { -- cgit 1.2.3-korg