[cps] Fix getResourceDataForPassthroughOperational endpoint 58/128158/15
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>
Tue, 29 Mar 2022 10:03:52 +0000 (11:03 +0100)
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>
Tue, 5 Apr 2022 13:13:42 +0000 (14:13 +0100)
Get endpoint only accepts application/json.

Issue-ID: CPS-957
Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Change-Id: Ifc7426fbcd6073a39554014dc18b2107b6343b16

15 files changed:
cps-ncmp-rest/docs/openapi/components.yaml
cps-ncmp-rest/docs/openapi/ncmp.yml
cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiModelOperations.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiOperations.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy
docs/api/swagger/ncmp/openapi.yaml

index 7719193..247fabd 100644 (file)
@@ -1,6 +1,7 @@
 #  ============LICENSE_START=======================================================
 #  Copyright (C) 2021-2022 Nordix Foundation
 #  Modifications Copyright (C) 2021 Pantheon.tech
+#  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.
@@ -367,14 +368,6 @@ components:
         sample 3:
           value:
             resourceIdentifier: parent=shops,child=bookstore
-    acceptParamInHeader:
-      name: Accept
-      in: header
-      required: false
-      description: Accept parameter for response, if accept parameter is null, that means client can accept any format.
-      schema:
-        type: string
-        enum: [ application/json, application/yang-data+json ]
     optionsParamInQuery:
       name: options
       in: query
index 2c9ee24..03ed98a 100755 (executable)
@@ -1,7 +1,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.
@@ -27,7 +27,6 @@ getResourceDataForPassthroughOperational:
     parameters:
       - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
-      - $ref: 'components.yaml#/components/parameters/acceptParamInHeader'
       - $ref: 'components.yaml#/components/parameters/optionsParamInQuery'
       - $ref: 'components.yaml#/components/parameters/topicParamInQuery'
     responses:
@@ -61,7 +60,6 @@ resourceDataForPassthroughRunning:
     parameters:
       - $ref: 'components.yaml#/components/parameters/cmHandleInPath'
       - $ref: 'components.yaml#/components/parameters/resourceIdentifierInQuery'
-      - $ref: 'components.yaml#/components/parameters/acceptParamInHeader'
       - $ref: 'components.yaml#/components/parameters/optionsParamInQuery'
       - $ref: 'components.yaml#/components/parameters/topicParamInQuery'
     responses:
index 0201fad..de6c3c4 100755 (executable)
@@ -3,7 +3,7 @@
  *  Copyright (C) 2021 Pantheon.tech
  *  Modifications Copyright (C) 2021-2022 Nordix Foundation
  *  Modification Copyright (C) 2021 highstreet technologies GmbH
- *  Modifications (C) 2021 Bell Canada
+ *  Modifications (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.
@@ -73,7 +73,6 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
      *
      * @param cmHandle cm handle identifier
      * @param resourceIdentifier resource identifier
-     * @param acceptParamInHeader accept header parameter
      * @param optionsParamInQuery options query parameter
      * @param topicParamInQuery topic query parameter
      * @return {@code ResponseEntity} response from dmi plugin
@@ -81,12 +80,10 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
     @Override
     public ResponseEntity<Object> getResourceDataOperationalForCmHandle(final String cmHandle,
                                                                         final @NotNull @Valid String resourceIdentifier,
-                                                                        final String acceptParamInHeader,
                                                                         final @Valid String optionsParamInQuery,
                                                                         final @Valid String topicParamInQuery) {
         final Object responseObject = networkCmProxyDataService.getResourceDataOperationalForCmHandle(cmHandle,
                 resourceIdentifier,
-                acceptParamInHeader,
                 optionsParamInQuery,
                 topicParamInQuery);
         return ResponseEntity.ok(responseObject);
@@ -97,7 +94,6 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
      *
      * @param cmHandle cm handle identifier
      * @param resourceIdentifier resource identifier
-     * @param acceptParamInHeader accept header parameter
      * @param optionsParamInQuery options query parameter
      * @param topicParamInQuery topic query parameter
      * @return {@code ResponseEntity} response from dmi plugin
@@ -105,12 +101,10 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
     @Override
     public ResponseEntity<Object> getResourceDataRunningForCmHandle(final String cmHandle,
                                                                     final @NotNull @Valid String resourceIdentifier,
-                                                                    final String acceptParamInHeader,
                                                                     final @Valid String optionsParamInQuery,
                                                                     final @Valid String topicParamInQuery) {
         final Object responseObject = networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(cmHandle,
                 resourceIdentifier,
-                acceptParamInHeader,
                 optionsParamInQuery,
                 topicParamInQuery);
         return ResponseEntity.ok(responseObject);
index d5c3cd9..8863345 100644 (file)
@@ -3,7 +3,7 @@
  *  Copyright (C) 2021 Pantheon.tech
  *  Modification Copyright (C) 2021 highstreet technologies GmbH
  *  Modification Copyright (C) 2021-2022 Nordix Foundation
- *  Modification Copyright (C) 2021 Bell Canada.
+ *  Modification 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.
@@ -81,12 +81,10 @@ class NetworkCmProxyControllerSpec extends Specification {
             def response = mvc.perform(
                     get(getUrl)
                             .contentType(MediaType.APPLICATION_JSON)
-                    .accept(MediaType.APPLICATION_JSON_VALUE)
             ).andReturn().response
         then: 'the NCMP data service is called with getResourceDataOperationalForCmHandle'
             1 * mockNetworkCmProxyDataService.getResourceDataOperationalForCmHandle('testCmHandle',
                     'parent/child',
-                    'application/json',
                     '(a=1,b=2)',
                     NO_TOPIC)
         and: 'response status is Ok'
@@ -101,12 +99,10 @@ class NetworkCmProxyControllerSpec extends Specification {
             def response = mvc.perform(
                     get(getUrl)
                     .contentType(MediaType.APPLICATION_JSON)
-                    .accept(MediaType.APPLICATION_JSON_VALUE)
             ).andReturn().response
         then: 'the NCMP data service is called with operational data for cm handle'
             1 * mockNetworkCmProxyDataService.getResourceDataOperationalForCmHandle('testCmHandle',
                     'parent/child',
-                    'application/json',
                     '(a=1,b=2)',
                     expectedTopicName)
         and: 'response status is Ok'
@@ -127,14 +123,12 @@ class NetworkCmProxyControllerSpec extends Specification {
         and: 'ncmp service returns json object'
             mockNetworkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle('testCmHandle',
                     resourceIdentifier,
-                    'application/json',
                     '(a=1,b=2)',
                     NO_TOPIC) >> '{valid-json}'
         when: 'get data resource request is performed'
             def response = mvc.perform(
                     get(getUrl)
                             .contentType(MediaType.APPLICATION_JSON)
-                            .accept(MediaType.APPLICATION_JSON_VALUE)
             ).andReturn().response
         then: 'response status is Ok'
             response.status == HttpStatus.OK.value()
@@ -157,8 +151,7 @@ class NetworkCmProxyControllerSpec extends Specification {
         when: 'update data resource request is performed'
             def response = mvc.perform(
                 put(updateUrl)
-                    .contentType(MediaType.APPLICATION_JSON_VALUE)
-                    .accept(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
+                    .contentType(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
             ).andReturn().response
         then: 'ncmp service method to update resource is called'
             1 * mockNetworkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle('testCmHandle',
@@ -175,8 +168,7 @@ class NetworkCmProxyControllerSpec extends Specification {
         when: 'create resource request is performed'
             def response = mvc.perform(
                     post(url)
-                            .contentType(MediaType.APPLICATION_JSON_VALUE)
-                            .accept(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
+                            .contentType(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
             ).andReturn().response
         then: 'ncmp service method to create resource called'
             1 * mockNetworkCmProxyDataService.writeResourceDataPassThroughRunningForCmHandle('testCmHandle',
index 7f4c18f..d50b8c5 100644 (file)
@@ -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);
 
index 1a69e45..81c060e 100755 (executable)
@@ -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
index 94faa55..f1bb95f 100644 (file)
@@ -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.
 
 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);
-    }
 }
index 68de9d5..855e52d 100644 (file)
@@ -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);
     }
 
 }
index d79988e..b033af8 100644 (file)
@@ -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,
index 75ba91b..745007b 100644 (file)
@@ -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;
-    }
 
 }
index bf5bb73..489c71c 100644 (file)
@@ -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'
index 389086c..394df1d 100644 (file)
@@ -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
     }
index 3df862a..2a19df1 100644 (file)
@@ -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'
index d3fc17c..574f609 100644 (file)
@@ -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'
index 606b69f..a43190b 100644 (file)
@@ -41,16 +41,6 @@ paths:
           sample 3:
             value:
               resourceIdentifier: "parent=shops,child=bookstore"
-      - name: Accept
-        in: header
-        description: "Accept parameter for response, if accept parameter is null,\
-          \ that means client can accept any format."
-        required: false
-        schema:
-          type: string
-          enum:
-          - application/json
-          - application/yang-data+json
       - name: options
         in: query
         description: "options parameter in query, it is mandatory to wrap key(s)=value(s)\
@@ -178,16 +168,6 @@ paths:
           sample 3:
             value:
               resourceIdentifier: "parent=shops,child=bookstore"
-      - name: Accept
-        in: header
-        description: "Accept parameter for response, if accept parameter is null,\
-          \ that means client can accept any format."
-        required: false
-        schema:
-          type: string
-          enum:
-          - application/json
-          - application/yang-data+json
       - name: options
         in: query
         description: "options parameter in query, it is mandatory to wrap key(s)=value(s)\