summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
authorsourabh_sourabh <sourabh.sourabh@est.tech>2022-03-12 22:41:10 +0530
committersourabh_sourabh <sourabh.sourabh@est.tech>2022-03-14 22:46:19 +0530
commite1f41c3e6591b572a75021f4b51538f8fdbfc88d (patch)
tree24dbad0eba106783b3a4483345b4197d99e0b9cc /cps-ncmp-service/src/test/groovy
parent7c98a26620b424d7328b57e0aeedd634cdeeb564 (diff)
Async: NCMP Rest impl. including Request ID generation
- In case of invalid topic return http status 400 with error message - Unit test is modified to handle/validate InvalidTopicException Issue-ID: CPS-828 Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech> Change-Id: I05645c92ccebb8aa422a47f6edcde7b64088a118
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.groovy33
1 files changed, 17 insertions, 16 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 e6d18d915..c21d7e774 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
@@ -22,6 +22,7 @@
package org.onap.cps.ncmp.api.impl
+import org.onap.cps.ncmp.api.impl.exception.InvalidTopicException
import org.onap.cps.ncmp.api.impl.operations.YangModelCmHandleRetriever
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import spock.lang.Shared
@@ -217,7 +218,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
exceptionThrown.details.contains('NOK-json')
}
- def 'Get resource data for operational from DMI with empty topic sync request.'() {
+ def 'DMI Operational data request with #scenario'() {
given: 'cps data service returns valid data node'
mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',
cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode
@@ -227,14 +228,14 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
when: 'get resource data is called data operational with blank topic'
def responseData = objectUnderTest.getResourceDataOperationalForCmHandle('', '',
'', '', emptyTopic)
- then: '(synchronous) the dmi response is expected'
- assert responseData == '{dmi-response}'
+ then: 'a invalid topic exception is thrown'
+ thrown(InvalidTopicException)
where: 'the following parameters are used'
- scenario | emptyTopic
- 'No topic in url' | ''
- 'Null topic in url' | null
- 'Empty topic in url' | '\"\"'
- 'Blank topic in url' | ' '
+ scenario | emptyTopic
+ 'no topic value in url' | ''
+ 'empty topic value in url' | '\"\"'
+ 'blank topic value in url' | ' '
+ 'invalid non-empty topic value in url' | '1_5_*_#'
}
def 'Get resource data for data operational from DMI with valid topic i.e. async request.'() {
@@ -263,7 +264,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
assert responseData.body.requestId.length() > 0
}
- def 'Get resource data for pass through running from DMI sync request where #scenario.'() {
+ def 'DMI pass through running data request with #scenario'() {
given: 'cps data service returns valid data node'
mockCpsDataService.getDataNode('NCMP-Admin', 'ncmp-dmi-registry',
cmHandleXPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> dataNode
@@ -273,14 +274,14 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
when: 'get resource data is called for data operational with valid topic'
def responseData = objectUnderTest.getResourceDataPassThroughRunningForCmHandle('',
'', '', '', emptyTopic)
- then: '(synchronous) the dmi response is expected'
- assert responseData == '{dmi-response}'
+ then: 'a invalid topic exception is thrown'
+ thrown(InvalidTopicException)
where: 'the following parameters are used'
- scenario | emptyTopic
- 'No topic in url' | ''
- 'Null topic in url' | null
- 'Empty topic in url' | '\"\"'
- 'Blank topic in url' | ' '
+ scenario | emptyTopic
+ 'no topic value in url' | ''
+ 'empty topic value in url' | '\"\"'
+ 'blank topic value in url' | ' '
+ 'invalid non-empty topic value in url' | '1_5_*_#'
}
def 'Getting Yang Resources.'() {