summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-03-29 11:03:52 +0100
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-04-05 14:13:42 +0100
commitd69742c1f02585ae5d82f49542581698367e9cde (patch)
tree5dd491897dc729627377503e39a23a0393728f07
parent6fb6f7742ec1d94ea3a265f476ddbddb0156c64f (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
-rw-r--r--cps-ncmp-rest/docs/openapi/components.yaml9
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmp.yml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java8
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy14
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java4
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java31
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiModelOperations.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiOperations.java7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy25
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy13
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiModelOperationsSpec.groovy10
-rw-r--r--docs/api/swagger/ncmp/openapi.yaml20
15 files changed, 39 insertions, 138 deletions
diff --git a/cps-ncmp-rest/docs/openapi/components.yaml b/cps-ncmp-rest/docs/openapi/components.yaml
index 7719193547..247fabd023 100644
--- a/cps-ncmp-rest/docs/openapi/components.yaml
+++ b/cps-ncmp-rest/docs/openapi/components.yaml
@@ -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
diff --git a/cps-ncmp-rest/docs/openapi/ncmp.yml b/cps-ncmp-rest/docs/openapi/ncmp.yml
index 2c9ee24559..03ed98a0e9 100755
--- a/cps-ncmp-rest/docs/openapi/ncmp.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmp.yml
@@ -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:
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index 0201fad2b5..de6c3c4f3d 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -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);
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index d5c3cd9f37..88633450b3 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -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',
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'
diff --git a/docs/api/swagger/ncmp/openapi.yaml b/docs/api/swagger/ncmp/openapi.yaml
index 606b69f75e..a43190bccd 100644
--- a/docs/api/swagger/ncmp/openapi.yaml
+++ b/docs/api/swagger/ncmp/openapi.yaml
@@ -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)\