From e1f41c3e6591b572a75021f4b51538f8fdbfc88d Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Sat, 12 Mar 2022 22:41:10 +0530 Subject: 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 Change-Id: I05645c92ccebb8aa422a47f6edcde7b64088a118 --- .../impl/NetworkCmProxyDataServiceImplSpec.groovy | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'cps-ncmp-service/src/test') 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 e6d18d9156..c21d7e7742 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.'() { -- cgit 1.2.3-korg