summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
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 /cps-ncmp-service/src/test/groovy
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
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-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
4 files changed, 19 insertions, 37 deletions
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 bf5bb73a9..489c71c0e 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 389086c77..394df1d07 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 3df862ac5..2a19df172 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 d3fc17cc0..574f609e9 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'