diff options
author | puthuparambil.aditya <aditya.puthuparambil@bell.ca> | 2022-03-29 11:03:52 +0100 |
---|---|---|
committer | puthuparambil.aditya <aditya.puthuparambil@bell.ca> | 2022-04-05 14:13:42 +0100 |
commit | d69742c1f02585ae5d82f49542581698367e9cde (patch) | |
tree | 5dd491897dc729627377503e39a23a0393728f07 /cps-ncmp-service/src | |
parent | 6fb6f7742ec1d94ea3a265f476ddbddb0156c64f (diff) |
[cps] Fix getResourceDataForPassthroughOperational endpoint
Get endpoint only accepts application/json.
Issue-ID: CPS-957
Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Change-Id: Ifc7426fbcd6073a39554014dc18b2107b6343b16
Diffstat (limited to 'cps-ncmp-service/src')
10 files changed, 33 insertions, 89 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java index 7f4c18f371..d50b8c5ea8 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java @@ -50,14 +50,12 @@ public interface NetworkCmProxyDataService { * * @param cmHandleId cm handle identifier * @param resourceIdentifier resource identifier - * @param acceptParamInHeader accept param * @param optionsParamInQuery options query * @param topicParamInQuery topic name for (triggering) async responses * @return {@code Object} resource data */ Object getResourceDataOperationalForCmHandle(String cmHandleId, String resourceIdentifier, - String acceptParamInHeader, String optionsParamInQuery, String topicParamInQuery); @@ -67,14 +65,12 @@ public interface NetworkCmProxyDataService { * * @param cmHandleId cm handle identifier * @param resourceIdentifier resource identifier - * @param acceptParamInHeader accept param * @param optionsParamInQuery options query * @param topicParamInQuery topic query * @return {@code Object} resource data */ Object getResourceDataPassThroughRunningForCmHandle(String cmHandleId, String resourceIdentifier, - String acceptParamInHeader, String optionsParamInQuery, String topicParamInQuery); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index 1a69e45d30..81c060eb3b 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -118,22 +118,20 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService @Override public Object getResourceDataOperationalForCmHandle(final String cmHandleId, final String resourceIdentifier, - final String acceptParamInHeader, final String optionsParamInQuery, final String topicParamInQuery) { CpsValidator.validateNameCharacters(cmHandleId); - return validateTopicNameAndGetResourceData(cmHandleId, resourceIdentifier, acceptParamInHeader, + return validateTopicNameAndGetResourceData(cmHandleId, resourceIdentifier, DmiOperations.DataStoreEnum.PASSTHROUGH_OPERATIONAL, optionsParamInQuery, topicParamInQuery); } @Override public Object getResourceDataPassThroughRunningForCmHandle(final String cmHandleId, final String resourceIdentifier, - final String acceptParamInHeader, final String optionsParamInQuery, final String topicParamInQuery) { CpsValidator.validateNameCharacters(cmHandleId); - return validateTopicNameAndGetResourceData(cmHandleId, resourceIdentifier, acceptParamInHeader, + return validateTopicNameAndGetResourceData(cmHandleId, resourceIdentifier, DmiOperations.DataStoreEnum.PASSTHROUGH_RUNNING, optionsParamInQuery, topicParamInQuery); } @@ -349,7 +347,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private Object validateTopicNameAndGetResourceData(final String cmHandleId, final String resourceIdentifier, - final String acceptParamInHeader, final DmiOperations.DataStoreEnum dataStore, final String optionsParamInQuery, final String topicParamInQuery) { @@ -360,8 +357,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService .body(buildDmiResponse(resourceDataRequestId)); } final ResponseEntity<?> responseEntity = dmiDataOperations.getResourceDataFromDmi( - cmHandleId, resourceIdentifier, optionsParamInQuery, acceptParamInHeader, - dataStore, NO_REQUEST_ID, NO_TOPIC); + cmHandleId, resourceIdentifier, optionsParamInQuery, dataStore, NO_REQUEST_ID, NO_TOPIC); return handleResponse(responseEntity, OperationEnum.READ); } }
\ No newline at end of file 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 94faa557fa..f1bb95f34e 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 @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,43 +21,32 @@ package org.onap.cps.ncmp.api.impl.client; +import lombok.AllArgsConstructor; import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration.DmiProperties; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @Component +@AllArgsConstructor public class DmiRestClient { private RestTemplate restTemplate; private DmiProperties dmiProperties; - /** - * Constructor injection for DmiRestClient objects. - * - * @param restTemplate the rest template - * @param dmiProperties the DMI properties - */ - public DmiRestClient(final RestTemplate restTemplate, final DmiProperties dmiProperties) { - this.restTemplate = restTemplate; - this.dmiProperties = dmiProperties; - } /** * Sends POST operation to DMI with json body containing module references. * @param dmiResourceUrl dmi resource url * @param jsonData json data body - * @param httpHeaders http headers * @return response entity of type String */ public ResponseEntity<Object> postOperationWithJsonData(final String dmiResourceUrl, - final String jsonData, - final HttpHeaders httpHeaders) { - final var httpEntity = new HttpEntity<>(jsonData, configureHttpHeaders(httpHeaders)); + final String jsonData) { + final var httpEntity = new HttpEntity<>(jsonData, configureHttpHeaders(new HttpHeaders())); return restTemplate.postForEntity(dmiResourceUrl, httpEntity, Object.class); } @@ -65,15 +55,4 @@ public class DmiRestClient { httpHeaders.setContentType(MediaType.APPLICATION_JSON); return httpHeaders; } - - /** - * Sends POST operation to DMI. - * @param dmiResourceUrl dmi resource url - * @param httpHeaders http headers - * @return response entity of type String - */ - public ResponseEntity<Object> postOperation(final String dmiResourceUrl, final HttpHeaders httpHeaders) { - final var httpEntity = new HttpEntity<>(configureHttpHeaders(httpHeaders)); - return restTemplate.exchange(dmiResourceUrl, HttpMethod.POST, httpEntity, Object.class); - } } 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 68de9d5c6b..855e52dcda 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 @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +30,6 @@ import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration; import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.utils.JsonObjectMapper; -import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; @@ -58,7 +58,6 @@ public class DmiDataOperations extends DmiOperations { * @param cmHandleId network resource identifier * @param resourceId resource identifier * @param optionsParamInQuery options query - * @param acceptParamInHeader accept parameter * @param dataStore data store enum * @param requestId requestId for async responses * @param topicParamInQuery topic name for (triggering) async responses @@ -67,7 +66,6 @@ public class DmiDataOperations extends DmiOperations { public ResponseEntity<Object> getResourceDataFromDmi(final String cmHandleId, final String resourceId, final String optionsParamInQuery, - final String acceptParamInHeader, final DataStoreEnum dataStore, final String requestId, final String topicParamInQuery) { @@ -79,13 +77,11 @@ public class DmiDataOperations extends DmiOperations { .build(); dmiRequestBody.asDmiProperties(yangModelCmHandle.getDmiProperties()); final String jsonBody = jsonObjectMapper.asJsonString(dmiRequestBody); - final var dmiResourceDataUrl = dmiServiceUrlBuilder.getDmiDatastoreUrl( dmiServiceUrlBuilder.populateQueryParams(resourceId, optionsParamInQuery, topicParamInQuery), dmiServiceUrlBuilder.populateUriVariables( yangModelCmHandle, cmHandleId, dataStore)); - final var httpHeaders = prepareHeader(acceptParamInHeader); - return dmiRestClient.postOperationWithJsonData(dmiResourceDataUrl, jsonBody, httpHeaders); + return dmiRestClient.postOperationWithJsonData(dmiResourceDataUrl, jsonBody); } /** @@ -117,7 +113,7 @@ public class DmiDataOperations extends DmiOperations { dmiServiceUrlBuilder.getDmiDatastoreUrl(dmiServiceUrlBuilder.populateQueryParams(resourceId, null, null), dmiServiceUrlBuilder.populateUriVariables(yangModelCmHandle, cmHandleId, PASSTHROUGH_RUNNING)); - return dmiRestClient.postOperationWithJsonData(dmiUrl, jsonBody, new HttpHeaders()); + return dmiRestClient.postOperationWithJsonData(dmiUrl, jsonBody); } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiModelOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiModelOperations.java index d79988e2e0..b033af87cd 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiModelOperations.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiModelOperations.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +37,6 @@ import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.ncmp.api.models.YangResource; import org.onap.cps.spi.model.ModuleReference; import org.onap.cps.utils.JsonObjectMapper; -import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; @@ -107,7 +107,7 @@ public class DmiModelOperations extends DmiOperations { final String cmHandle, final String resourceName) { final String dmiResourceDataUrl = getDmiResourceUrl(dmiServiceName, cmHandle, resourceName); - return dmiRestClient.postOperationWithJsonData(dmiResourceDataUrl, jsonData, new HttpHeaders()); + return dmiRestClient.postOperationWithJsonData(dmiResourceDataUrl, jsonData); } private static String getRequestBodyToFetchYangResources(final Collection<ModuleReference> newModuleReferences, diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiOperations.java index 75ba91b4f7..745007bd44 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiOperations.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiOperations.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +27,6 @@ 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.utils.DmiServiceUrlBuilder; import org.onap.cps.utils.JsonObjectMapper; -import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Service; @RequiredArgsConstructor @@ -56,10 +56,5 @@ public class DmiOperations { .buildAndExpand(dmiServiceName, dmiProperties.getDmiBasePath(), cmHandle, resourceName).toUriString(); } - static HttpHeaders prepareHeader(final String acceptParam) { - final var httpHeaders = new HttpHeaders(); - httpHeaders.set(HttpHeaders.ACCEPT, acceptParam); - return httpHeaders; - } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy index bf5bb73a94..489c71c0e9 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation * Modifications Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2021 Bell Canada + * Modifications Copyright (C) 2021-2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,14 +112,12 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { 'testCmHandle', 'testResourceId', OPTIONS_PARAM, - 'testAcceptParam', PASSTHROUGH_OPERATIONAL, NO_REQUEST_ID, NO_TOPIC) >> new ResponseEntity<>('dmi-response', HttpStatus.OK) when: 'get resource data operational for cm-handle is called' def response = objectUnderTest.getResourceDataOperationalForCmHandle('testCmHandle', 'testResourceId', - 'testAcceptParam', OPTIONS_PARAM, NO_TOPIC) then: 'DMI returns a json response' @@ -138,7 +136,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { when: 'get resource data is called' objectUnderTest.getResourceDataOperationalForCmHandle('testCmHandle', 'testResourceId', - 'testAcceptParam', OPTIONS_PARAM, NO_TOPIC) then: 'exception is thrown with the expected response code and details' @@ -155,7 +152,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { mockDmiDataOperations.getResourceDataFromDmi('testCmHandle', 'testResourceId', OPTIONS_PARAM, - 'testAcceptParam', PASSTHROUGH_OPERATIONAL, NO_REQUEST_ID, NO_TOPIC) @@ -163,7 +159,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { when: 'get resource data is called' objectUnderTest.getResourceDataOperationalForCmHandle('testCmHandle', 'testResourceId', - 'testAcceptParam', OPTIONS_PARAM, NO_TOPIC) then: 'exception is thrown' @@ -181,14 +176,12 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { mockDmiDataOperations.getResourceDataFromDmi('testCmHandle', 'testResourceId', OPTIONS_PARAM, - 'testAcceptParam', PASSTHROUGH_RUNNING, NO_REQUEST_ID, NO_TOPIC) >> new ResponseEntity<>('{dmi-response}', HttpStatus.OK) when: 'get resource data is called' def response = objectUnderTest.getResourceDataPassThroughRunningForCmHandle('testCmHandle', 'testResourceId', - 'testAcceptParam', OPTIONS_PARAM, NO_TOPIC) then: 'get resource data returns expected response' @@ -203,7 +196,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { mockDmiDataOperations.getResourceDataFromDmi('testCmHandle', 'testResourceId', OPTIONS_PARAM, - 'testAcceptParam', PASSTHROUGH_RUNNING, NO_REQUEST_ID, NO_TOPIC) @@ -211,7 +203,6 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { when: 'get resource data is called' objectUnderTest.getResourceDataPassThroughRunningForCmHandle('testCmHandle', 'testResourceId', - 'testAcceptParam', OPTIONS_PARAM, NO_TOPIC) then: 'exception is thrown' @@ -230,7 +221,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { >> new ResponseEntity<>('{dmi-response}', HttpStatus.OK) when: 'get resource data is called data operational with blank topic' def responseData = objectUnderTest.getResourceDataOperationalForCmHandle('', '', - '', '', emptyTopic) + '', emptyTopic) then: 'a invalid topic exception is thrown' thrown(InvalidTopicException) where: 'the following parameters are used' @@ -245,10 +236,10 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { given: 'cps data service returns valid data node' mockCpsDataService.getDataNode(*_) >> dataNode and: 'dmi data operation returns valid response and data' - mockDmiDataOperations.getResourceDataFromDmi(_, _, _, _, _, _, 'my-topic-name') + mockDmiDataOperations.getResourceDataFromDmi(_, _, _, _, _, 'my-topic-name') >> new ResponseEntity<>('{dmi-response}', HttpStatus.OK) when: 'get resource data is called for data operational with valid topic' - def responseData = objectUnderTest.getResourceDataOperationalForCmHandle('', '', '', '', 'my-topic-name') + def responseData = objectUnderTest.getResourceDataOperationalForCmHandle('', '', '', 'my-topic-name') then: 'non empty request id is generated' assert responseData.body.requestId.length() > 0 } @@ -258,11 +249,11 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry', cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode and: 'dmi data operation returns valid response and data' - mockDmiDataOperations.getResourceDataFromDmi(_, _, _, _, _, _, 'my-topic-name') + mockDmiDataOperations.getResourceDataFromDmi(_, _, _, _, _, 'my-topic-name') >> new ResponseEntity<>('{dmi-response}', HttpStatus.OK) when: 'get resource data is called for data operational with valid topic' def responseData = objectUnderTest.getResourceDataPassThroughRunningForCmHandle('', - '', '', OPTIONS_PARAM, 'my-topic-name') + '', OPTIONS_PARAM, 'my-topic-name') then: 'non empty request id is generated' assert responseData.body.requestId.length() > 0 } @@ -272,11 +263,11 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry', cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode and: 'dmi data operation returns valid response and data' - mockDmiDataOperations.getResourceDataFromDmi(_, _, _, _, _, NO_REQUEST_ID, NO_TOPIC) + mockDmiDataOperations.getResourceDataFromDmi(_, _, _, _, NO_REQUEST_ID, NO_TOPIC) >> new ResponseEntity<>('{dmi-response}', HttpStatus.OK) when: 'get resource data is called for data operational with valid topic' def responseData = objectUnderTest.getResourceDataPassThroughRunningForCmHandle('', - '', '', '', emptyTopic) + '', '', emptyTopic) then: 'a invalid topic exception is thrown' thrown(InvalidTopicException) where: 'the following parameters are used' 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 389086c770..394df1d076 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 @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,22 +44,12 @@ class DmiRestClientSpec extends Specification { DmiRestClient objectUnderTest def resourceUrl = 'some url' - def 'DMI POST operation'() { - given: 'the rest template returns a valid response entity' - def mockResponseEntity = Mock(ResponseEntity) - mockRestTemplate.exchange(resourceUrl, HttpMethod.POST, _ as HttpEntity, Object.class) >> mockResponseEntity - when: 'POST operation is invoked' - def result = objectUnderTest.postOperation(resourceUrl, new HttpHeaders()) - then: 'the output of the method is equal to the output from the rest template' - result == mockResponseEntity - } - def 'DMI POST operation with JSON.'() { given: 'the rest template returns a valid response entity' def mockResponseEntity = Mock(ResponseEntity) mockRestTemplate.postForEntity(resourceUrl, _ as HttpEntity, Object.class) >> mockResponseEntity when: 'POST operation is invoked' - def result = objectUnderTest.postOperationWithJsonData(resourceUrl, 'json-data', new HttpHeaders()) + def result = objectUnderTest.postOperationWithJsonData(resourceUrl, 'json-data') then: 'the output of the method is equal to the output from the test template' result == mockResponseEntity } 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 3df862ac5c..2a19df1723 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 @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,12 +63,11 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { and: 'a positive response from DMI service when it is called with the expected parameters' def responseFromDmi = new ResponseEntity<Object>(HttpStatus.OK) def expectedUrl = dmiServiceBaseUrl + "${expectedDatastoreInUrl}?resourceIdentifier=${resourceIdentifier}${expectedOptionsInUrl}" - mockDmiRestClient.postOperationWithJsonData(expectedUrl, - expectedJson, [Accept: ['sample accept header']]) >> responseFromDmi + mockDmiRestClient.postOperationWithJsonData(expectedUrl, expectedJson) >> responseFromDmi dmiServiceUrlBuilder.getDmiDatastoreUrl(_, _) >> expectedUrl when: 'get resource data is invoked' def result = objectUnderTest.getResourceDataFromDmi(cmHandleId, resourceIdentifier, - options, 'sample accept header', dataStore, NO_REQUEST_ID, NO_TOPIC) + options, dataStore, NO_REQUEST_ID, NO_TOPIC) then: 'the result is the response from the DMI service' assert result == responseFromDmi where: 'the following parameters are used' @@ -88,7 +88,7 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { def expectedJson = '{"operation":"' + expectedOperationInUrl + '","dataType":"some data type","data":"requestData","cmHandleProperties":{"prop1":"val1"}}' def responseFromDmi = new ResponseEntity<Object>(HttpStatus.OK) dmiServiceUrlBuilder.getDmiDatastoreUrl(_, _) >> expectedUrl - mockDmiRestClient.postOperationWithJsonData(expectedUrl, expectedJson, [:]) >> responseFromDmi + mockDmiRestClient.postOperationWithJsonData(expectedUrl, expectedJson) >> responseFromDmi when: 'write resource method is invoked' def result = objectUnderTest.writeResourceDataPassThroughRunningFromDmi(cmHandleId, 'parent/child', operation, 'requestData', 'some data type') then: 'the result is the response from the DMI service' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy index d3fc17cc07..574f609e9e 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation + * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +56,7 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { def moduleReferencesAsLisOfMaps = [[moduleName: 'mod1', revision: 'A'], [moduleName: 'mod2', revision: 'X']] def expectedUrl = "${dmiServiceName}/dmi/v1/ch/${cmHandleId}/modules" def responseFromDmi = new ResponseEntity([schemas: moduleReferencesAsLisOfMaps], HttpStatus.OK) - mockDmiRestClient.postOperationWithJsonData(expectedUrl, '{"cmHandleProperties":{}}', [:]) + mockDmiRestClient.postOperationWithJsonData(expectedUrl, '{"cmHandleProperties":{}}') >> responseFromDmi when: 'get module references is called' def result = objectUnderTest.getModuleReferences(yangModelCmHandle) @@ -88,7 +89,7 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { and: 'a positive response from DMI service when it is called with tha expected parameters' def responseFromDmi = new ResponseEntity<String>(HttpStatus.OK) mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/modules", - '{"cmHandleProperties":' + expectedAdditionalPropertiesInRequest + '}', [:]) >> responseFromDmi + '{"cmHandleProperties":' + expectedAdditionalPropertiesInRequest + '}') >> responseFromDmi when: 'a get module references is called' def result = objectUnderTest.getModuleReferences(yangModelCmHandle) then: 'the result is the response from DMI service' @@ -107,7 +108,7 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { [moduleName: 'mod2', revision: 'C', yangSource: 'other yang source']], HttpStatus.OK) def expectedModuleReferencesInRequest = '{"name":"mod1","revision":"A"},{"name":"mod2","revision":"X"}' mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/moduleResources", - '{"data":{"modules":[' + expectedModuleReferencesInRequest + ']},"cmHandleProperties":{}}', [:]) >> responseFromDmi + '{"data":{"modules":[' + expectedModuleReferencesInRequest + ']},"cmHandleProperties":{}}') >> responseFromDmi when: 'get new yang resources from DMI service' def result = objectUnderTest.getNewYangResourcesFromDmi(yangModelCmHandle, newModuleReferences) then: 'the result has the 2 expected yang (re)sources (order is not guaranteed)' @@ -139,8 +140,7 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { and: 'a positive response from DMI service when it is called with the expected parameters' def responseFromDmi = new ResponseEntity<>([[moduleName: 'mod1', revision: 'A', yangSource: 'some yang source']], HttpStatus.OK) mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/moduleResources", - '{"data":{"modules":[' + expectedModuleReferencesInRequest + ']},"cmHandleProperties":'+expectedAdditionalPropertiesInRequest+'}', - [:]) >> responseFromDmi + '{"data":{"modules":[' + expectedModuleReferencesInRequest + ']},"cmHandleProperties":'+expectedAdditionalPropertiesInRequest+'}') >> responseFromDmi when: 'get new yang resources from DMI service' def result = objectUnderTest.getNewYangResourcesFromDmi(yangModelCmHandle, unknownModuleReferences) then: 'the result is the response from DMI service' |