aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
authorDaniel Hanrahan <daniel.hanrahan@est.tech>2024-09-04 16:19:02 +0000
committerGerrit Code Review <gerrit@onap.org>2024-09-04 16:19:02 +0000
commitd196932c3ed2edbc3f0a0ce0fb097b40715ad0bb (patch)
tree11ca8c69a80bf971184c0c42d95232ce350b669a /cps-ncmp-service/src
parent66f6c6d2634d83d972e8f226156359b72a1f6841 (diff)
parent1721e3c9b5f131a18478e4aa56afce3f0637d1b6 (diff)
Merge "Support alternate id for CPS-E05 GetCmHandleDetailsById"
Diffstat (limited to 'cps-ncmp-service/src')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy15
2 files changed, 14 insertions, 8 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
index 5db6e96076..cde4eacbf2 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/NetworkCmProxyInventoryFacade.java
@@ -183,12 +183,13 @@ public class NetworkCmProxyInventoryFacade {
}
/**
- * Retrieve cm handle details for a given cm handle.
+ * Retrieve cm handle details for a given cm handle reference.
*
- * @param cmHandleId cm handle identifier
+ * @param cmHandleReference cm handle or alternate identifier
* @return cm handle details
*/
- public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleId) {
+ public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleReference) {
+ final String cmHandleId = alternateIdMatcher.getCmHandleId(cmHandleReference);
final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
return toNcmpServiceCmHandleWithTrustLevel(yangModelCmHandle);
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
index be2bf87df0..9e07de48bf 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/NetworkCmProxyInventoryFacadeSpec.groovy
@@ -102,7 +102,7 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
'Cm Handle Reference as alternate-id' | 'some-alternate-id'
}
- def 'Get a cm handle.'() {
+ def 'Get a cm handle details using #scenario'() {
given: 'the system returns a yang modelled cm handle'
def dmiServiceName = 'some service name'
def compositeState = new CompositeState(cmHandleState: CmHandleState.ADVISED,
@@ -114,17 +114,18 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
def publicProperties = [new YangModelCmHandle.Property('Public Book', 'Public Romance Novel')]
def moduleSetTag = 'some-module-set-tag'
def alternateId = 'some-alternate-id'
- def yangModelCmHandle = new YangModelCmHandle(id: 'ch-1', dmiServiceName: dmiServiceName, dmiProperties: dmiProperties,
+ def yangModelCmHandle = new YangModelCmHandle(id: 'some-cm-handle', dmiServiceName: dmiServiceName, dmiProperties: dmiProperties,
publicProperties: publicProperties, compositeState: compositeState, moduleSetTag: moduleSetTag, alternateId: alternateId)
- 1 * mockInventoryPersistence.getYangModelCmHandle('ch-1') >> yangModelCmHandle
+ mockAlternateIdMatcher.getCmHandleId(cmHandleRef) >> 'some-cm-handle'
+ 1 * mockInventoryPersistence.getYangModelCmHandle('some-cm-handle') >> yangModelCmHandle
and: 'a trust level for the cm handle in the cache'
mockTrustLevelManager.getEffectiveTrustLevel(*_) >> TrustLevel.COMPLETE
when: 'getting cm handle details for a given cm handle id from ncmp service'
- def result = objectUnderTest.getNcmpServiceCmHandle('ch-1')
+ def result = objectUnderTest.getNcmpServiceCmHandle(cmHandleRef)
then: 'the result is a ncmpServiceCmHandle'
assert result.class == NcmpServiceCmHandle.class
and: 'the cm handle contains the cm handle id'
- assert result.cmHandleId == 'ch-1'
+ assert result.cmHandleId == 'some-cm-handle'
and: 'the cm handle contains the alternate id'
assert result.alternateId == 'some-alternate-id'
and: 'the cm handle contains the module-set-tag'
@@ -137,6 +138,10 @@ class NetworkCmProxyInventoryFacadeSpec extends Specification {
assert result.compositeState == compositeState
and: 'the cm handle contains the trust level from the cache'
assert result.currentTrustLevel == TrustLevel.COMPLETE
+ where: 'following cm handle reference is used'
+ scenario | cmHandleRef
+ 'Cm Handle Reference as cm handle-id' | 'some-cm-handle'
+ 'Cm Handle Reference as alternate-id' | 'some-alternate-id'
}
def 'Get cm handle public properties using #scenario'() {