From 69a68f1c14dec4bfc3e76b55bc21a71107775619 Mon Sep 17 00:00:00 2001 From: "david.mcweeney" Date: Wed, 1 May 2024 12:08:00 +0100 Subject: CPS-2181 - #1 Included Module Set Tag in NCMP calls to DMI for Yang Module Resources Change-Id: I4f8cf79667e3155f49b9109d26b5807f5d54f90c Signed-off-by: david.mcweeney Issue-ID: CPS-2181 --- .../impl/operations/DmiModelOperationsSpec.groovy | 24 +++++++++++++++++++--- .../impl/operations/DmiOperationsBaseSpec.groovy | 13 ++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) (limited to 'cps-ncmp-service/src/test/groovy/org/onap') 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 e99e8a3d02..9aab467479 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 @@ -58,7 +58,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":{},"moduleSetTag":"tag1"}', READ, NO_AUTH_HEADER) + mockDmiRestClient.postOperationWithJsonData(expectedUrl, '{"cmHandleProperties":{},"moduleSetTag":""}', READ, NO_AUTH_HEADER) >> responseFromDmi when: 'get module references is called' def result = objectUnderTest.getModuleReferences(yangModelCmHandle) @@ -91,7 +91,7 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { and: 'a positive response from DMI service when it is called with tha expected parameters' def responseFromDmi = new ResponseEntity(HttpStatus.OK) mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/modules", - '{"cmHandleProperties":' + expectedAdditionalPropertiesInRequest + ',"moduleSetTag":"tag1"}', READ, NO_AUTH_HEADER) >> responseFromDmi + '{"cmHandleProperties":' + expectedAdditionalPropertiesInRequest + ',"moduleSetTag":""}', READ, NO_AUTH_HEADER) >> responseFromDmi when: 'a get module references is called' def result = objectUnderTest.getModuleReferences(yangModelCmHandle) then: 'the result is the response from DMI service' @@ -139,7 +139,7 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { def 'Retrieving yang resources, DMI property handling #scenario.'() { given: 'a cm handle' mockYangModelCmHandleRetrieval(dmiProperties) - and: 'a positive response from DMI service when it is called with the expected parameters' + and: 'a positive response from DMI service when it is called with the expected moduleSetTag, modules and properties' def responseFromDmi = new ResponseEntity<>([[moduleName: 'mod1', revision: 'A', yangSource: 'some yang source']], HttpStatus.OK) mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/moduleResources", '{"data":{"modules":[{"name":"mod1","revision":"A"},{"name":"mod2","revision":"X"}]},"cmHandleProperties":' + expectedAdditionalPropertiesInRequest + '}', @@ -154,6 +154,24 @@ class DmiModelOperationsSpec extends DmiOperationsBaseSpec { 'without properties' | [] || '{}' } + def 'Retrieving yang resources #scenario'() { + given: 'a cm handle' + mockYangModelCmHandleRetrieval([], moduleSetTag) + and: 'a positive response from DMI service when it is called with the expected moduleSetTag' + def responseFromDmi = new ResponseEntity<>([[moduleName: 'mod1', revision: 'A', yangSource: 'some yang source']], HttpStatus.OK) + mockDmiRestClient.postOperationWithJsonData("${dmiServiceName}/dmi/v1/ch/${cmHandleId}/moduleResources", + '{' + expectedModuleSetTagInRequest + '"data":{"modules":[{"name":"mod1","revision":"A"},{"name":"mod2","revision":"X"}]},"cmHandleProperties":{}}', + READ, NO_AUTH_HEADER) >> responseFromDmi + when: 'get new yang resources from DMI service' + def result = objectUnderTest.getNewYangResourcesFromDmi(yangModelCmHandle, newModuleReferences) + then: 'the result is the response from DMI service' + assert result == [mod1:'some yang source'] + where: 'the following Module Set Tags are used' + scenario | moduleSetTag || expectedModuleSetTagInRequest + 'Without module set tag' | '' || '' + 'With module set tag' | 'moduleSetTag1' || '"moduleSetTag":"moduleSetTag1",' + } + def 'Retrieving yang resources from DMI with no module references.'() { given: 'a cm handle' mockYangModelCmHandleRetrieval([]) diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiOperationsBaseSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiOperationsBaseSpec.groovy index b7af502de8..72a0f2f11a 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiOperationsBaseSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiOperationsBaseSpec.groovy @@ -58,22 +58,27 @@ abstract class DmiOperationsBaseSpec extends Specification { def static resourceIdentifier = 'parent/child' def mockYangModelCmHandleRetrieval(dmiProperties) { - populateYangModelCmHandle(dmiProperties) + populateYangModelCmHandle(dmiProperties, '') + mockInventoryPersistence.getYangModelCmHandle(cmHandleId) >> yangModelCmHandle + } + + def mockYangModelCmHandleRetrieval(dmiProperties, moduleSetTag) { + populateYangModelCmHandle(dmiProperties, moduleSetTag) mockInventoryPersistence.getYangModelCmHandle(cmHandleId) >> yangModelCmHandle } def mockYangModelCmHandleCollectionRetrieval(dmiProperties) { - populateYangModelCmHandle(dmiProperties) + populateYangModelCmHandle(dmiProperties, "") mockInventoryPersistence.getYangModelCmHandles(_) >> [yangModelCmHandle] } - def populateYangModelCmHandle(dmiProperties) { + def populateYangModelCmHandle(dmiProperties, moduleSetTag) { yangModelCmHandle.dmiDataServiceName = dmiServiceName yangModelCmHandle.dmiServiceName = dmiServiceName yangModelCmHandle.dmiProperties = dmiProperties yangModelCmHandle.id = cmHandleId yangModelCmHandle.compositeState = new CompositeState() yangModelCmHandle.compositeState.cmHandleState = CmHandleState.READY - yangModelCmHandle.moduleSetTag = 'tag1' + yangModelCmHandle.moduleSetTag = moduleSetTag } } -- cgit 1.2.3-korg