X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Finventory%2FInventoryPersistenceImplSpec.groovy;h=929ea84e36571e66a8b40671376661d494723e44;hb=9575b84ab4e2db885d8761a98eaae9ff3a06aa81;hp=355487f64aef642f53df6a1740252abf86860fd2;hpb=fd226778aec35a6ca28b1788aa9150863cb4f63c;p=cps.git diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy index 355487f64..929ea84e3 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceImplSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation + * Copyright (C) 2022-2023 Nordix Foundation * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +28,7 @@ import org.onap.cps.api.CpsModuleService import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle import org.onap.cps.spi.CascadeDeleteAllowed import org.onap.cps.spi.FetchDescendantsOption +import org.onap.cps.spi.exceptions.DataValidationException import org.onap.cps.spi.model.DataNode import org.onap.cps.spi.model.ModuleDefinition import org.onap.cps.spi.model.ModuleReference @@ -38,6 +39,7 @@ import spock.lang.Specification import java.time.OffsetDateTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter +import java.util.stream.Collectors import static org.onap.cps.ncmp.api.impl.constants.DmiRegistryConstants.NO_TIMESTAMP import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS @@ -64,6 +66,9 @@ class InventoryPersistenceImplSpec extends Specification { def leaves = ["dmi-service-name":"common service name","dmi-data-service-name":"data service name","dmi-model-service-name":"model service name"] def xpath = "/dmi-registry/cm-handles[@id='some-cm-handle']" + def cmHandleId2 = 'another-cm-handle' + def xpath2 = "/dmi-registry/cm-handles[@id='another-cm-handle']" + @Shared def childDataNodesForCmHandleWithAllProperties = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/additional-properties[@name='name1']", leaves: ["name":"name1", "value":"value1"]), new DataNode(xpath: "/dmi-registry/cm-handles[@id='some cm handle']/public-properties[@name='name2']", leaves: ["name":"name2","value":"value2"])] @@ -118,6 +123,17 @@ class InventoryPersistenceImplSpec extends Specification { 1 * mockCpsValidator.validateNameCharacters(cmHandleId) } + def "Retrieve multiple YangModelCmHandles"() { + given: 'the cps data service returns 2 data nodes from the DMI registry' + def dataNodes = [new DataNode(xpath: xpath), new DataNode(xpath: xpath2)] + mockCpsDataService.getDataNodes('NCMP-Admin', 'ncmp-dmi-registry', [xpath, xpath2] , INCLUDE_ALL_DESCENDANTS) >> dataNodes + when: 'retrieving the yang modelled cm handle' + def results = objectUnderTest.getYangModelCmHandles([cmHandleId, cmHandleId2]) + then: 'verify both have returned and cmhandleIds are correct' + assert results.size() == 2 + assert results.id.containsAll([cmHandleId, cmHandleId2]) + } + def 'Get a Cm Handle Composite State'() { given: 'a valid cm handle id' def cmHandleId = 'Some-Cm-Handle' @@ -270,4 +286,12 @@ class InventoryPersistenceImplSpec extends Specification { 'sample dataNode xpath', NO_TIMESTAMP); } + def 'Delete multiple data nodes via xPath'() { + when: 'Delete data nodes method is called with multiple xpaths as parameters' + objectUnderTest.deleteDataNodes(['xpath1', 'xpath2']) + then: 'the cps data service method to delete data nodes is invoked once with the same xPaths' + 1 * mockCpsDataService.deleteDataNodes('NCMP-Admin', 'ncmp-dmi-registry', + ['xpath1', 'xpath2'], NO_TIMESTAMP); + } + }