aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2024-11-21 15:08:39 +0000
committerToineSiebelink <toine.siebelink@est.tech>2024-11-21 15:08:59 +0000
commit1e34dc01f3319517d66387f2c443c989a0752f7f (patch)
tree76aa6f83c8e92d7c80f91d19ed6fc2af501f77e1 /cps-ncmp-service/src/test/groovy/org/onap
parent9060818e7974ca09a06b715533161876b94fde84 (diff)
Prioritize cm handle ids over alternate ids in data operations
Issue-ID: CPS-2510 Change-Id: I7068d0de45cc2c2e5d8815f0e78c260369f3551e Signed-off-by: seanbeirne <sean.beirne@est.tech> Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy25
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy1
2 files changed, 25 insertions, 1 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
index b046c12387..71054dce41 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
@@ -35,6 +35,7 @@ import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher
import org.onap.cps.ncmp.impl.utils.http.UrlTemplateParameters
import org.onap.cps.ncmp.utils.TestUtils
+import org.onap.cps.spi.exceptions.DataNodeNotFoundException
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
@@ -92,7 +93,6 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
mockDmiRestClient.asynchronousPostOperationWithJsonData(DATA, expectedUrlTemplateWithVariables, expectedJson, READ, NO_AUTH_HEADER) >> responseFromDmi
when: 'get resource data is invoked'
def cmResourceAddress = new CmResourceAddress(expectedDataStore.datastoreName, cmHandleId, resourceIdentifier)
- alternateIdMatcher.getCmHandleId(cmHandleId) >> cmHandleId
def result = objectUnderTest.getResourceDataFromDmi(cmResourceAddress, expectedOptions, NO_TOPIC, NO_REQUEST_ID, NO_AUTH_HEADER).block()
then: 'the result is the response from the DMI service'
assert result.body == '{some-key:some-value}'
@@ -205,6 +205,29 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
CmHandleState.ADVISED || true
}
+ def 'Resolving cm handle references with cm handle id.'() {
+ given: 'a resource address with a cm handle id'
+ def cmResourceAddress = new CmResourceAddress('some store', 'cm-handle-id', 'some resource')
+ and: 'the given cm handle id is available in the inventory'
+ mockInventoryPersistence.getYangModelCmHandle('cm-handle-id') >> yangModelCmHandle
+ expect: 'resolving the cm handle id returns the cm handle'
+ assert objectUnderTest.resolveYangModelCmHandleFromCmHandleReference(cmResourceAddress) == yangModelCmHandle
+ }
+
+ def 'Resolving cm handle references with alternate id.'() {
+ given: 'a resource with a alternate id'
+ def cmResourceAddress = new CmResourceAddress('some store', 'alternate-id', 'some resource')
+ and: 'the alternate id cannot be found in the inventory directly and that results in a data node not found exception'
+ mockInventoryPersistence.getYangModelCmHandle('alternate-id') >> { throw new DataNodeNotFoundException('','') }
+ and: 'the alternate id can be matched to a cm handle id'
+ alternateIdMatcher.getCmHandleId('alternate-id') >> 'cm-handle-id'
+ and: 'that cm handle id is available in the inventory'
+ mockInventoryPersistence.getYangModelCmHandle('cm-handle-id') >> yangModelCmHandle
+ expect: 'resolving that cm handle id returns the cm handle'
+ assert objectUnderTest.resolveYangModelCmHandleFromCmHandleReference(cmResourceAddress) == yangModelCmHandle
+ }
+
+
def extractDataValue(actualDataOperationCloudEvent) {
return toTargetEvent(actualDataOperationCloudEvent, DataOperationEvent).data.responses[0]
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy
index d00d3ab8f6..e479fffe87 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiOperationsBaseSpec.groovy
@@ -44,6 +44,7 @@ abstract class DmiOperationsBaseSpec extends Specification {
ObjectMapper spyObjectMapper = Spy()
def yangModelCmHandle = new YangModelCmHandle()
+ def otherYangModelCmHandle = new YangModelCmHandle()
def static dmiServiceName = 'myServiceName'
def static cmHandleId = 'some-cm-handle'
def static alternateId = 'alt-id-' + cmHandleId