summaryrefslogtreecommitdiffstats
path: root/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-03-29 11:22:31 +0100
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-04-04 12:06:34 +0100
commit39450c583c097c3b083ca79a39c5f99a218f6cdc (patch)
treea975b082dbf11e6536c6fc5bee09215d830a3224 /src/test/groovy/org/onap
parent15bbf1487764bbfeaffcaa6a4a4beaea69f50d1e (diff)
[dmi-plugin] Fix getResourceDataForPassthroughOperational endpoint
Get endpoint only accepts application/json. Issue-ID: CPS-957 Change-Id: I7b9dd00f293f183dc76623c8e32699e8e90fd17c Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Diffstat (limited to 'src/test/groovy/org/onap')
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy13
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy20
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy15
3 files changed, 16 insertions, 32 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
index ac632bb2..b42eb4d2 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
- * 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.
@@ -183,15 +183,13 @@ class DmiRestControllerSpec extends Specification {
def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}'
when: 'get resource data POST api is invoked'
def response = mvc.perform(
- post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON).content(json)
+ post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON).content(json)
).andReturn().response
then: 'response status is ok'
response.status == OK.value()
and: 'dmi service called with get resource data'
1 * mockDmiService.getResourceData('some-cmHandle',
'parent/child',
- 'application/json',
'(fields=myfields,depth=5)',
'content=all')
}
@@ -203,8 +201,7 @@ class DmiRestControllerSpec extends Specification {
def jsonData = TestUtils.getResourceFileContent('createDataWithNormalChar.json')
when: 'get resource data POST api is invoked'
def response = mvc.perform(
- post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON).content(jsonData)
+ post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON).content(jsonData)
).andReturn().response
then: 'response status is bad request'
response.status == BAD_REQUEST.value()
@@ -265,15 +262,13 @@ class DmiRestControllerSpec extends Specification {
def json = '{"cmHandleProperties" : { "prop1" : "value1", "prop2" : "value2"}}'
when: 'get resource data POST api is invoked'
def response = mvc.perform(
- post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON).content(json)
+ post(getResourceDataForCmHandleUrl).contentType(MediaType.APPLICATION_JSON).content(json)
).andReturn().response
then: 'response status is ok'
response.status == OK.value()
and: 'dmi service called with get resource data for a cm handle'
1 * mockDmiService.getResourceData('some-cmHandle',
resourceIdentifier,
- 'application/json',
'(fields=myfields,depth=5)',
'content=config')
where: 'tokens are used in the resource identifier parameter'
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
index edf1a80a..e38d5c37 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
- * 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.
@@ -198,15 +198,13 @@ class DmiServiceImplSpec extends Specification {
given: 'cm-handle, passthrough parameter, resourceId, accept header, fields, depth'
def cmHandle = 'testCmHandle'
def resourceId = 'testResourceId'
- def acceptHeaderParam = 'testAcceptParam'
def optionsParam = '(fields=x/y/z,depth=10,test=abc)'
def contentQuery = 'content=all'
and: 'sdnc operation returns OK response'
- mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam, acceptHeaderParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
when: 'get resource data from cm handles service method invoked'
def response = objectUnderTest.getResourceData(cmHandle,
- resourceId, acceptHeaderParam,
- optionsParam, contentQuery)
+ resourceId, optionsParam, contentQuery)
then: 'response have expected json'
response == 'response json'
}
@@ -215,15 +213,13 @@ class DmiServiceImplSpec extends Specification {
given: 'cm-handle, passthrough parameter, resourceId, accept header, fields, depth, query param'
def cmHandle = 'testCmHandle'
def resourceId = 'testResourceId'
- def acceptHeaderParam = 'testAcceptParam'
def optionsParam = '(fields=x/y/z,depth=10,test=abc)'
def restConfQueryParam = 'content=config'
and: 'sdnc operation returns "NOT_FOUND" response'
- mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam, acceptHeaderParam, _ as String) >> new ResponseEntity<>(HttpStatus.NOT_FOUND)
+ mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam, _ as String) >> new ResponseEntity<>(HttpStatus.NOT_FOUND)
when: 'get resource data from cm handles service method invoked'
objectUnderTest.getResourceData(cmHandle,
- resourceId, acceptHeaderParam,
- optionsParam, restConfQueryParam)
+ resourceId, optionsParam, restConfQueryParam)
then: 'resource data not found'
thrown(ResourceDataNotFound.class)
}
@@ -232,16 +228,14 @@ class DmiServiceImplSpec extends Specification {
given: 'cm-handle, passthrough parameter, resourceId, accept header, fields, depth'
def cmHandle = 'testCmHandle'
def resourceId = 'testResourceId'
- def acceptHeaderParam = 'testAcceptParam'
def optionsParam = '(fields=x/y/z,depth=10,test=abc)'
def contentQuery = 'content=config'
and: 'sdnc operation returns OK response'
mockSdncOperations.getResouceDataForOperationalAndRunning(cmHandle, resourceId, optionsParam,
- acceptHeaderParam, contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
+ contentQuery) >> new ResponseEntity<>('response json', HttpStatus.OK)
when: 'get resource data from cm handles service method invoked'
def response = objectUnderTest.getResourceData(cmHandle,
- resourceId, acceptHeaderParam,
- optionsParam, contentQuery)
+ resourceId, optionsParam, contentQuery)
then: 'response have expected json'
response == 'response json'
}
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy
index c71f6d92..724d2d4e 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/operation/SdncOperationsSpec.groovy
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 Nordix Foundation
- * 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.
@@ -117,19 +117,14 @@ class SdncOperationsSpec extends Specification {
1 * mockSdncRestClient.httpOperationWithJsonData(HttpMethod.POST, expectedUrl, 'some-json-data', _ as HttpHeaders)
}
- def 'Get resource data from node to SDNC. with#scenario accept header'() {
+ def 'Get resource data from node to SDNC.'() {
given: 'expected url, topology-id, sdncOperation object'
def expectedUrl = '/rests/data/network-topology:network-topology/topology=test-topology/node=node1/yang-ext:mount/testResourceId?a=1&b=2&content=testContent'
when: 'called get modules from node'
objectUnderTest.getResouceDataForOperationalAndRunning('node1', 'testResourceId',
- '(a=1,b=2)', acceptParamInHeader, 'content=testContent')
- then: 'the get operation is executed with the correct URL and Http headers'
- 1 * mockSdncRestClient.getOperation(expectedUrl, expectedHttpHeaders)
- where:
- scenario | acceptParamInHeader || expectedHttpHeaders
- 'test' | 'test' || new HttpHeaders([Accept:'test'])
- 'empty' | '' || new HttpHeaders()
- 'null' | null || new HttpHeaders()
+ '(a=1,b=2)', 'content=testContent')
+ then: 'the get operation is executed with the correct URL'
+ 1 * mockSdncRestClient.getOperation(expectedUrl)
}
def 'Write resource data with #scenario operation to SDNC.'() {