From 117dcc8b8e0a7aa36c6f9f125d37381dabd2ad93 Mon Sep 17 00:00:00 2001 From: seanbeirne Date: Wed, 17 Jul 2024 11:35:22 +0100 Subject: Support alternate Id interface for CPS-E-05 #2 - Supports Alternate Ids for getResourceDataForCmHandle Issue-Id: CPS-2279 Change-Id: I1f145308cec5b545fab2d5c96efbc00fc3a110f4 Signed-off-by: seanbeirne --- .../rest/controller/NetworkCmProxyControllerSpec.groovy | 14 +++++++------- .../NetworkCmProxyRestExceptionHandlerSpec.groovy | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'cps-ncmp-rest/src/test') 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 f7d80ad747..9f5331dbc3 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 @@ -41,6 +41,7 @@ import org.onap.cps.ncmp.impl.data.NetworkCmProxyFacade import org.onap.cps.ncmp.impl.inventory.DataStoreSyncState import org.onap.cps.ncmp.impl.inventory.models.CmHandleState import org.onap.cps.ncmp.impl.inventory.models.LockReasonCategory +import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher import org.onap.cps.ncmp.rest.model.DataOperationDefinition import org.onap.cps.ncmp.rest.model.DataOperationRequest import org.onap.cps.ncmp.rest.util.CmHandleStateMapper @@ -93,6 +94,9 @@ class NetworkCmProxyControllerSpec extends Specification { @SpringBean NetworkCmProxyInventoryFacade mockNetworkCmProxyInventoryFacade = Mock() + @SpringBean + AlternateIdMatcher mockalternateIdMatcher = Mock() + @SpringBean ObjectMapper objectMapper = new ObjectMapper() @@ -136,12 +140,10 @@ class NetworkCmProxyControllerSpec extends Specification { def 'Get Resource Data from pass-through operational.'() { given: 'resource data url' def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child&options=(a=1,b=2)" - and: 'the expected cm resource address' - def expectedCmResourceAddress = new CmResourceAddress(PASSTHROUGH_OPERATIONAL.datastoreName, 'testCmHandle', 'parent/child') when: 'get data resource request is performed' def response = mvc.perform(get(getUrl).contentType(MediaType.APPLICATION_JSON)).andReturn().response then: 'the NCMP data service is called with correct parameters' - 1 * mockNetworkCmProxyFacade.getResourceDataForCmHandle(expectedCmResourceAddress, '(a=1,b=2)', NO_TOPIC, false, NO_AUTH_HEADER) >> Mono.just(new ResponseEntity(HttpStatus.OK)) + 1 * mockNetworkCmProxyFacade.getResourceDataForCmHandle(_, '(a=1,b=2)', NO_TOPIC, false, NO_AUTH_HEADER) >> Mono.just(new ResponseEntity(HttpStatus.OK)) and: 'response status is Ok' assert response.status == HttpStatus.OK.value() } @@ -150,11 +152,10 @@ class NetworkCmProxyControllerSpec extends Specification { given: 'resource data url' def getUrl = "$ncmpBasePathV1/ch/h123/data/ds/ncmp-datastore:operational?resourceIdentifier=parent/child${additionalUrlParam}" and: 'the expected cm resource address' - def expectedCmResourceAddress = new CmResourceAddress('ncmp-datastore:operational', 'h123', 'parent/child') when: 'get data resource request is performed' def response = mvc.perform(get(getUrl).contentType(MediaType.APPLICATION_JSON)).andReturn().response then: 'the NCMP data service is called with correct parameters' - 1 * mockNetworkCmProxyFacade.getResourceDataForCmHandle(expectedCmResourceAddress, NO_OPTIONS, NO_TOPIC, expectedIncludeDescendants, NO_AUTH_HEADER) + 1 * mockNetworkCmProxyFacade.getResourceDataForCmHandle(_, NO_OPTIONS, NO_TOPIC, expectedIncludeDescendants, NO_AUTH_HEADER) and: 'response status is OK' assert response.status == HttpStatus.OK.value() where: 'the following parameters are used' @@ -206,8 +207,7 @@ class NetworkCmProxyControllerSpec extends Specification { given: 'resource data url' def getUrl = "$ncmpBasePathV1/ch/ch-1/data/ds/ncmp-datastore:passthrough-running?resourceIdentifier=$resourceIdentifier&options=(a=1)" and: 'ncmp service returns json object' - def expectedCmResourceAddress = new CmResourceAddress(PASSTHROUGH_RUNNING.datastoreName, 'ch-1', resourceIdentifier) - 1 * mockNetworkCmProxyFacade.getResourceDataForCmHandle(expectedCmResourceAddress, '(a=1)', NO_TOPIC, false, NO_AUTH_HEADER) + 1 * mockNetworkCmProxyFacade.getResourceDataForCmHandle(_, '(a=1)', NO_TOPIC, false, NO_AUTH_HEADER) >> new ResponseEntity('{valid-json}', HttpStatus.OK) when: 'get data resource request is performed' def response = mvc.perform(get(getUrl).contentType(MediaType.APPLICATION_JSON)).andReturn().response diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy index 97f3e03c6d..e6288ffbec 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy @@ -34,6 +34,7 @@ import org.onap.cps.ncmp.api.inventory.NetworkCmProxyInventoryFacade import org.onap.cps.ncmp.impl.data.NcmpCachedResourceRequestHandler import org.onap.cps.ncmp.impl.data.NcmpPassthroughResourceRequestHandler import org.onap.cps.ncmp.impl.data.NetworkCmProxyFacade +import org.onap.cps.ncmp.impl.inventory.InventoryPersistence import org.onap.cps.ncmp.rest.util.CmHandleStateMapper import org.onap.cps.ncmp.rest.util.DataOperationRequestMapper import org.onap.cps.ncmp.rest.util.DeprecationHelper @@ -76,6 +77,9 @@ class NetworkCmProxyRestExceptionHandlerSpec extends Specification { @SpringBean NetworkCmProxyInventoryFacade mockNetworkCmProxyInventoryFacade = Mock() + @SpringBean + InventoryPersistence mockInventoryPersistence = Mock() + @SpringBean JsonObjectMapper stubbedJsonObjectMapper = Stub() -- cgit 1.2.3-korg