From 14ace1a5da8dd770acd098cf2de575c16962ee78 Mon Sep 17 00:00:00 2001 From: JosephKeenan Date: Mon, 29 Nov 2021 14:48:34 +0000 Subject: [PATCH] Changing putOperationWithJson to postOperationWithJson Issue-ID: CPS-736 Change-Id: I3fd2e0b6d6c20683b18f79ed78ed5c8990aee6d8 Signed-off-by: JosephKeenan --- .../org/onap/cps/ncmp/api/impl/client/DmiRestClient.java | 15 --------------- .../cps/ncmp/api/impl/operations/DmiDataOperations.java | 4 ++-- .../cps/ncmp/api/impl/client/DmiRestClientSpec.groovy | 10 ---------- .../ncmp/api/impl/operations/DmiDataOperationsSpec.groovy | 2 +- csit/plans/cps/setup.sh | 1 + csit/plans/cps/test.properties | 2 +- 6 files changed, 5 insertions(+), 29 deletions(-) diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java index 62eca9451..9f3df6b9a 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java @@ -46,21 +46,6 @@ public class DmiRestClient { this.dmiProperties = dmiProperties; } - /** - * Sends a PUT operation to DMI with JSON payload. - * - * @param dmiResourceUrl the DMI resource URL - * @param jsonData the JSON payload - * @param headers the HTTP headers - * @return response entity of type Object - */ - public ResponseEntity putOperationWithJsonData(final String dmiResourceUrl, - final String jsonData, final HttpHeaders headers) { - //TODO Toine Siebelink, should we use POST operation below instead (and return a String-Entity!) - final var httpEntity = new HttpEntity<>(jsonData, configureHttpHeaders(headers)); - return restTemplate.exchange(dmiResourceUrl, HttpMethod.PUT, httpEntity, Object.class); - } - /** * Sends POST operation to DMI with json body containing module references. * @param dmiResourceUrl dmi resource url diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java index b8336455c..eccb9a098 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java @@ -62,7 +62,7 @@ public class DmiDataOperations extends DmiOperations { * @param dataStore data store enum * @return {@code ResponseEntity} response entity */ - public ResponseEntity getResourceDataFromDmi(final String cmHandle, + public ResponseEntity getResourceDataFromDmi(final String cmHandle, final String resourceId, final String optionsParamInQuery, final String acceptParamInHeader, @@ -79,7 +79,7 @@ public class DmiDataOperations extends DmiOperations { persistenceCmHandle.resolveDmiServiceName(DATA), cmHandle, resourceId, optionsParamInQuery, dataStore); final var httpHeaders = prepareHeader(acceptParamInHeader); - return dmiRestClient.putOperationWithJsonData(dmiResourceDataUrl, jsonBody, httpHeaders); + return dmiRestClient.postOperationWithJsonData(dmiResourceDataUrl, jsonBody, httpHeaders); } /** diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy index a1779a757..8c46178dd 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy @@ -43,16 +43,6 @@ class DmiRestClientSpec extends Specification { DmiRestClient objectUnderTest def resourceUrl = 'some url' - def 'DMI PUT operation.'() { - given: 'the rest template returns a valid response entity' - def mockResponseEntity = Mock(ResponseEntity) - mockRestTemplate.exchange(resourceUrl, HttpMethod.PUT, _ as HttpEntity, Object.class) >> mockResponseEntity - when: 'PUT operation is invoked' - def result = objectUnderTest.putOperationWithJsonData(resourceUrl, 'json-data', new HttpHeaders()) - then: 'the output of the method is equal to the output from the test template' - result == mockResponseEntity - } - def 'DMI POST operation'() { given: 'the rest template returns a valid response entity' def mockResponseEntity = Mock(ResponseEntity) diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy index 674a44238..b9704b1ea 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy @@ -45,7 +45,7 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { mockPersistenceCmHandleRetrieval(additionalProperties) and: 'a positive response from dmi service when it is called with the expected parameters' def responseFromDmi = new ResponseEntity(HttpStatus.OK) - mockDmiRestClient.putOperationWithJsonData( + mockDmiRestClient.postOperationWithJsonData( "${dmiServiceName}/dmi/v1/ch/${cmHandleId}/data/ds/ncmp-datastore:${expectedDatastoreInUrl}?resourceIdentifier=${resourceIdentifier}${expectedOptionsInUrl}", expectedJson, [Accept:['sample accept header']]) >> responseFromDmi when: 'get resource data is invoked' diff --git a/csit/plans/cps/setup.sh b/csit/plans/cps/setup.sh index 1e27fb972..5b3fd9649 100755 --- a/csit/plans/cps/setup.sh +++ b/csit/plans/cps/setup.sh @@ -72,6 +72,7 @@ chmod +x docker-compose cd $WORKSPACE/archives git clone "https://gerrit.onap.org/r/cps/ncmp-dmi-plugin" mkdir -p $WORKSPACE/archives/dc-dmi +cat $WORKSPACE/archives/ncmp-dmi-plugin/docker-compose/docker-compose.yml cp $WORKSPACE/archives/ncmp-dmi-plugin/docker-compose/*.yml $WORKSPACE/archives/dc-dmi cd $WORKSPACE/archives/dc-dmi # download docker-compose of a required version (1.25.0 supports configuration of version 3.7) diff --git a/csit/plans/cps/test.properties b/csit/plans/cps/test.properties index 3e546fbec..53b7d40d0 100644 --- a/csit/plans/cps/test.properties +++ b/csit/plans/cps/test.properties @@ -23,4 +23,4 @@ DMI_SERVICE_URL=http://$LOCAL_IP:$DMI_PORT DOCKER_REPO=nexus3.onap.org:10003 CPS_VERSION=latest -DMI_VERSION=latest \ No newline at end of file +DMI_VERSION=1.1.0-SNAPSHOT-latest \ No newline at end of file -- 2.16.6