Inventory Persistance returns YangModelCmHandles for alternate Ids 28/139628/5
authorseanbeirne <sean.beirne@est.tech>
Mon, 2 Dec 2024 11:33:36 +0000 (11:33 +0000)
committerseanbeirne <sean.beirne@est.tech>
Wed, 4 Dec 2024 16:53:45 +0000 (16:53 +0000)
-Remove getCmHandleDataNodeByAlternateId(s) methods and replace with
Yang Model methods

Issue-ID: CPS-2486
Change-Id: I2c9c96f033b3b1eefadb7eff14c91f9a936630e6
Signed-off-by: seanbeirne <sean.beirne@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/WriteRequestExaminer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/AlternateIdChecker.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/utils/AlternateIdMatcher.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/WriteRequestExaminerSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/AlternateIdCheckerSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/utils/AlternateIdMatcherSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryByAlternateIdPerfTest.groovy

index e13d3c2..429a379 100644 (file)
@@ -34,8 +34,6 @@ import org.onap.cps.ncmp.api.datajobs.models.WriteOperation;
 import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
 import org.onap.cps.ncmp.impl.models.RequiredDmiService;
 import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher;
-import org.onap.cps.ncmp.impl.utils.YangDataConverter;
-import org.onap.cps.spi.model.DataNode;
 import org.springframework.stereotype.Service;
 
 @Slf4j
@@ -67,10 +65,8 @@ public class WriteRequestExaminer {
                                        final Map<ProducerKey, List<DmiWriteOperation>> dmiWriteOperationsPerProducerKey,
                                        final WriteOperation writeOperation) {
         log.debug("data job id for write operation is: {}", dataJobId);
-        final DataNode dataNode = alternateIdMatcher
-                .getCmHandleDataNodeByLongestMatchingAlternateId(writeOperation.path(), PATH_SEPARATOR);
-
-        final YangModelCmHandle yangModelCmHandle = YangDataConverter.toYangModelCmHandle(dataNode);
+        final YangModelCmHandle yangModelCmHandle = alternateIdMatcher
+                .getYangModelCmHandleByLongestMatchingAlternateId(writeOperation.path(), PATH_SEPARATOR);
 
         final DmiWriteOperation dmiWriteOperation = createDmiWriteOperation(writeOperation, yangModelCmHandle);
 
index 3600d6d..8ebd456 100644 (file)
@@ -28,6 +28,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle;
+import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
 import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
 import org.springframework.stereotype.Service;
 
@@ -96,8 +97,8 @@ public class AlternateIdChecker {
                 .map(NcmpServiceCmHandle::getAlternateId)
                 .filter(StringUtils::isNotBlank)
                 .collect(Collectors.toSet());
-        return inventoryPersistence.getCmHandleDataNodesByAlternateIds(alternateIdsToCheck).stream()
-                .map(dataNode -> (String) dataNode.getLeaves().get("alternate-id"))
+        return inventoryPersistence.getYangModelCmHandleByAlternateIds(alternateIdsToCheck).stream()
+                .map(YangModelCmHandle::getAlternateId)
                 .collect(Collectors.toSet());
     }
 
index e5dd937..e39da06 100644 (file)
@@ -130,20 +130,20 @@ public interface InventoryPersistence extends NcmpPersistence {
     Collection<DataNode> getCmHandleDataNodeByCmHandleId(String cmHandleId);
 
     /**
-     * Get data node with the given alternate id.
+     * Get yang model cm handle with the given alternate id.
      *
      * @param alternateId alternate ID
-     * @return data node
+     * @return yang model cm handle
      */
-    DataNode getCmHandleDataNodeByAlternateId(String alternateId);
+    YangModelCmHandle getYangModelCmHandleByAlternateId(String alternateId);
 
     /**
-     * Get data nodes for the given batch of alternate ids.
+     * Get yang model cm handles for the given batch of alternate ids.
      *
      * @param alternateIds alternate IDs
-     * @return data nodes
+     * @return yang model cm handles
      */
-    Collection<DataNode> getCmHandleDataNodesByAlternateIds(Collection<String> alternateIds);
+    Collection<YangModelCmHandle> getYangModelCmHandleByAlternateIds(Collection<String> alternateIds);
 
     /**
      * Get collection of data nodes of given cm handles.
@@ -168,7 +168,7 @@ public interface InventoryPersistence extends NcmpPersistence {
      * Check database if cm handle id exists if not return false.
      *
      * @param cmHandleId cmHandle Id
-     * @return Boolean
+     * @return boolean
      */
-    Boolean isExistingCmHandleId(String cmHandleId);
+    boolean isExistingCmHandleId(String cmHandleId);
 }
index e468ed1..f8a3810 100644 (file)
@@ -189,24 +189,25 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
     }
 
     @Override
-    public DataNode getCmHandleDataNodeByAlternateId(final String alternateId) {
+    public YangModelCmHandle getYangModelCmHandleByAlternateId(final String alternateId) {
         final String cpsPathForCmHandleByAlternateId = getCpsPathForCmHandleByAlternateId(alternateId);
         final Collection<DataNode> dataNodes = cmHandleQueryService
             .queryNcmpRegistryByCpsPath(cpsPathForCmHandleByAlternateId, OMIT_DESCENDANTS);
         if (dataNodes.isEmpty()) {
             throw new CmHandleNotFoundException(alternateId);
         }
-        return dataNodes.iterator().next();
+        return YangDataConverter.toYangModelCmHandle(dataNodes.iterator().next());
     }
 
     @Override
-    public Collection<DataNode> getCmHandleDataNodesByAlternateIds(final Collection<String> alternateIds) {
+    public Collection<YangModelCmHandle> getYangModelCmHandleByAlternateIds(final Collection<String> alternateIds) {
         if (alternateIds.isEmpty()) {
             return Collections.emptyList();
         }
         final String cpsPathForCmHandlesByAlternateIds = getCpsPathForCmHandlesByAlternateIds(alternateIds);
-        return cmHandleQueryService.queryNcmpRegistryByCpsPath(cpsPathForCmHandlesByAlternateIds,
-            INCLUDE_ALL_DESCENDANTS);
+        final Collection<DataNode> dataNodes = cmHandleQueryService.queryNcmpRegistryByCpsPath(
+            cpsPathForCmHandlesByAlternateIds, INCLUDE_ALL_DESCENDANTS);
+        return YangDataConverter.toYangModelCmHandles(dataNodes);
     }
 
     @Override
@@ -229,7 +230,7 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
     }
 
     @Override
-    public Boolean isExistingCmHandleId(final String cmHandleId) {
+    public boolean isExistingCmHandleId(final String cmHandleId) {
         try {
             return  !getCmHandleDataNodeByCmHandleId(cmHandleId).isEmpty();
         } catch (final DataNodeNotFoundException exception) {
index 36c0cfa..b97da29 100644 (file)
 package org.onap.cps.ncmp.impl.utils;
 
 import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException;
 import org.onap.cps.ncmp.exceptions.NoAlternateIdMatchFoundException;
 import org.onap.cps.ncmp.impl.inventory.InventoryPersistence;
-import org.onap.cps.spi.model.DataNode;
+import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle;
 import org.springframework.stereotype.Service;
 
-@Slf4j
 @Service
 @RequiredArgsConstructor
 public class AlternateIdMatcher {
@@ -37,19 +35,21 @@ public class AlternateIdMatcher {
     private final InventoryPersistence inventoryPersistence;
 
     /**
-     * Get data node that matches longest alternate id by removing elements (as defined by the separator string)
-     * from right to left. If alternate id contains a hash then all elements after that hash are ignored.
+     * Get yang model cm handle that matches longest alternate id by removing elements
+     * (as defined by the separator string) from right to left.
+     * If alternate id contains a hash then all elements after that hash are ignored.
      *
      * @param alternateId alternate ID
      * @param separator   a string that separates each element from the next.
-     * @return data node
+     * @return yang model cm handle
      */
-    public DataNode getCmHandleDataNodeByLongestMatchingAlternateId(final String alternateId, final String separator) {
+    public YangModelCmHandle getYangModelCmHandleByLongestMatchingAlternateId(final String alternateId,
+                                                                              final String separator) {
         final String[] splitPath = alternateId.split("#", 2);
         String bestMatch = splitPath[0];
         while (StringUtils.isNotEmpty(bestMatch)) {
             try {
-                return inventoryPersistence.getCmHandleDataNodeByAlternateId(bestMatch);
+                return inventoryPersistence.getYangModelCmHandleByAlternateId(bestMatch);
             } catch (final CmHandleNotFoundException ignored) {
                 bestMatch = getParentPath(bestMatch, separator);
             }
@@ -67,8 +67,7 @@ public class AlternateIdMatcher {
         if (inventoryPersistence.isExistingCmHandleId(cmHandleReference)) {
             return cmHandleReference;
         } else {
-            return inventoryPersistence.getCmHandleDataNodeByAlternateId(cmHandleReference)
-              .getLeaves().get("id").toString();
+            return inventoryPersistence.getYangModelCmHandleByAlternateId(cmHandleReference).getId();
         }
     }
 
index 47b5766..6aa84d1 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2024 Nordix Foundation
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
 
 package org.onap.cps.ncmp.impl.datajobs
 
@@ -6,7 +25,6 @@ import org.onap.cps.ncmp.api.datajobs.models.WriteOperation
 import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
 import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
 import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher
-import org.onap.cps.spi.model.DataNode
 import spock.lang.Specification
 
 class WriteRequestExaminerSpec extends Specification {
@@ -15,14 +33,14 @@ class WriteRequestExaminerSpec extends Specification {
     def objectUnderTest = new WriteRequestExaminer(mockAlternateIdMatcher)
 
     def setup() {
-        def ch1 = new DataNode(leaves: [id: 'ch1', 'dmi-service-name': 'dmiA', 'data-producer-identifier': 'p1'])
-        def ch2 = new DataNode(leaves: [id: 'ch2', 'dmi-service-name': 'dmiA', 'data-producer-identifier': 'p1'])
-        def ch3 = new DataNode(leaves: [id: 'ch3', 'dmi-service-name': 'dmiA', 'data-producer-identifier': 'p2'])
-        def ch4 = new DataNode(leaves: [id: 'ch4', 'dmi-service-name': 'dmiB', 'data-producer-identifier': 'p1'])
-        mockAlternateIdMatcher.getCmHandleDataNodeByLongestMatchingAlternateId('fdn1', '/') >> ch1
-        mockAlternateIdMatcher.getCmHandleDataNodeByLongestMatchingAlternateId('fdn2', '/') >> ch2
-        mockAlternateIdMatcher.getCmHandleDataNodeByLongestMatchingAlternateId('fdn3', '/') >> ch3
-        mockAlternateIdMatcher.getCmHandleDataNodeByLongestMatchingAlternateId('fdn4', '/') >> ch4
+        def ch1 = new YangModelCmHandle(id: 'ch1', dmiServiceName: 'dmiA', dataProducerIdentifier: 'p1', dmiProperties: [])
+        def ch2 = new YangModelCmHandle(id: 'ch2', dmiServiceName: 'dmiA', dataProducerIdentifier: 'p1', dmiProperties: [])
+        def ch3 = new YangModelCmHandle(id: 'ch3', dmiServiceName: 'dmiA', dataProducerIdentifier: 'p2', dmiProperties: [])
+        def ch4 = new YangModelCmHandle(id: 'ch4', dmiServiceName: 'dmiB', dataProducerIdentifier: 'p1', dmiProperties: [])
+        mockAlternateIdMatcher.getYangModelCmHandleByLongestMatchingAlternateId('fdn1', '/') >> ch1
+        mockAlternateIdMatcher.getYangModelCmHandleByLongestMatchingAlternateId('fdn2', '/') >> ch2
+        mockAlternateIdMatcher.getYangModelCmHandleByLongestMatchingAlternateId('fdn3', '/') >> ch3
+        mockAlternateIdMatcher.getYangModelCmHandleByLongestMatchingAlternateId('fdn4', '/') >> ch4
     }
 
     def 'Create a map of dmi write requests per producer key with #scenario.'() {
index b976ff4..087265b 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.cps.ncmp.impl.inventory
 import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
 import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
 import org.onap.cps.spi.exceptions.DataNodeNotFoundException
-import org.onap.cps.spi.model.DataNode
 import spock.lang.Specification
 
 class AlternateIdCheckerSpec extends Specification {
@@ -37,8 +36,8 @@ class AlternateIdCheckerSpec extends Specification {
             def batch = [new NcmpServiceCmHandle(cmHandleId: 'ch-1', alternateId: alt1),
                          new NcmpServiceCmHandle(cmHandleId: 'ch-2', alternateId: alt2)]
         and: 'the database already contains cm handle(s) with these alternate ids: #altAlreadyInDb'
-            mockInventoryPersistenceService.getCmHandleDataNodesByAlternateIds(_ as Collection<String>) >>
-                { args -> args[0].stream().filter(altId -> altAlreadyInDb.contains(altId)).map(altId -> new DataNode(leaves: ["alternate-id": altId])).toList() }
+            mockInventoryPersistenceService.getYangModelCmHandleByAlternateIds(_ as Collection<String>) >>
+                { args -> args[0].stream().filter(altId -> altAlreadyInDb.contains(altId)).map(altId -> new YangModelCmHandle(alternateId: altId)).toList() }
         when: 'the batch of new cm handles is checked'
             def result = objectUnderTest.getIdsOfCmHandlesWithRejectedAlternateId(batch, AlternateIdChecker.Operation.CREATE)
         then: 'the result contains ids of the rejected cm handles'
@@ -57,8 +56,8 @@ class AlternateIdCheckerSpec extends Specification {
         given: 'a batch of 1 existing cm handle to update alternate id to #proposedAlt'
             def batch = [new NcmpServiceCmHandle(cmHandleId: 'ch-1', alternateId: proposedAlt)]
         and: 'the database already contains a cm handle with alternate id: #altAlreadyInDb'
-            mockInventoryPersistenceService.getCmHandleDataNodesByAlternateIds(_ as Collection<String>) >>
-                { args -> args[0].stream().filter(altId -> altAlreadyInDb == altId).map(altId -> new DataNode(leaves: ["alternate-id": altId])).toList() }
+            mockInventoryPersistenceService.getYangModelCmHandleByAlternateIds(_ as Collection<String>) >>
+                { args -> args[0].stream().filter(altId -> altAlreadyInDb == altId).map(altId -> new YangModelCmHandle(alternateId: altId)).toList() }
             mockInventoryPersistenceService.getYangModelCmHandle(_) >> new YangModelCmHandle(alternateId: altAlreadyInDb)
         when: 'the batch of cm handle updates is checked'
             def result = objectUnderTest.getIdsOfCmHandlesWithRejectedAlternateId(batch, AlternateIdChecker.Operation.UPDATE)
@@ -75,7 +74,7 @@ class AlternateIdCheckerSpec extends Specification {
         given: 'a batch of 1 non-existing cm handle to update alternate id'
             def batch = [new NcmpServiceCmHandle(cmHandleId: 'non-existing', alternateId: 'altId')]
         and: 'the database does not contain any cm handles'
-            mockInventoryPersistenceService.getCmHandleDataNodesByAlternateIds(_) >> []
+            mockInventoryPersistenceService.getYangModelCmHandleByAlternateIds(_) >> []
             mockInventoryPersistenceService.getYangModelCmHandle(_) >> { throwDataNodeNotFoundException() }
         when: 'the batch of cm handle updates is checked'
             def result = objectUnderTest.getIdsOfCmHandlesWithRejectedAlternateId(batch, AlternateIdChecker.Operation.UPDATE)
index 4d8855c..ab7ed98 100644 (file)
@@ -31,6 +31,7 @@ import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException
 import org.onap.cps.ncmp.api.inventory.models.CompositeState
 import org.onap.cps.ncmp.impl.inventory.models.CmHandleState
 import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
+import org.onap.cps.ncmp.impl.utils.YangDataConverter
 import org.onap.cps.spi.CascadeDeleteAllowed
 import org.onap.cps.spi.FetchDescendantsOption
 import org.onap.cps.spi.model.DataNode
@@ -67,6 +68,8 @@ class InventoryPersistenceImplSpec extends Specification {
 
     def mockCmHandleQueries = Mock(CmHandleQueryService)
 
+    def mockYangDataConverter = Mock(YangDataConverter)
+
     def objectUnderTest = new InventoryPersistenceImpl(spiedJsonObjectMapper, mockCpsDataService, mockCpsModuleService,
             mockCpsValidator, mockCpsAnchorService, mockCmHandleQueries)
 
@@ -312,29 +315,31 @@ class InventoryPersistenceImplSpec extends Specification {
             1 * mockCpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, expectedXPath, INCLUDE_ALL_DESCENDANTS)
     }
 
-    def 'Get cm handle data node by alternate id'() {
+    def 'Get yang model cm handle by alternate id'() {
         given: 'expected xPath to get cmHandle data node'
             def expectedXPath = '/dmi-registry/cm-handles[@alternate-id=\'alternate id\']'
+            def expectedDataNode = new DataNode(xpath: expectedXPath, leaves: [id: 'id', alternateId: 'alternate id'])
         and: 'query service is invoked with expected xpath'
-            mockCmHandleQueries.queryNcmpRegistryByCpsPath(expectedXPath, OMIT_DESCENDANTS) >> [new DataNode()]
-        expect: 'getting the cm handle data node'
-            assert objectUnderTest.getCmHandleDataNodeByAlternateId('alternate id') == new DataNode()
+            mockCmHandleQueries.queryNcmpRegistryByCpsPath(expectedXPath, OMIT_DESCENDANTS) >> [expectedDataNode]
+            mockYangDataConverter.toYangModelCmHandle(expectedDataNode) >> new YangModelCmHandle(id: 'id')
+        expect: 'getting the yang model cm handle'
+            assert objectUnderTest.getYangModelCmHandleByAlternateId('alternate id') == new YangModelCmHandle(id: 'id')
     }
 
-    def 'Attempt to get non existing cm handle data node by alternate id'() {
+    def 'Attempt to get non existing yang model cm handle by alternate id'() {
         given: 'query service is invoked and returns empty collection of data nodes'
             mockCmHandleQueries.queryNcmpRegistryByCpsPath(*_) >> []
-        when: 'getting the cm handle data node'
-            objectUnderTest.getCmHandleDataNodeByAlternateId('alternate id')
+        when: 'getting the yang model cm handle'
+            objectUnderTest.getYangModelCmHandleByAlternateId('alternate id')
         then: 'no data found exception thrown'
             def thrownException = thrown(CmHandleNotFoundException)
             assert thrownException.getMessage().contains('Cm handle not found')
             assert thrownException.getDetails().contains('No cm handles found with reference alternate id')
     }
 
-    def 'Get multiple cm handle data nodes by alternate ids, passing empty collection'() {
-        when: 'getting the cm handle data node for no alternate ids'
-            objectUnderTest.getCmHandleDataNodesByAlternateIds([])
+    def 'Get multiple yang model cm handles by alternate ids, passing empty collection'() {
+        when: 'getting the  yang model cm handle for no alternate ids'
+            objectUnderTest.getYangModelCmHandleByAlternateIds([])
         then: 'query service is not invoked'
             0 * mockCmHandleQueries.queryNcmpRegistryByCpsPath(_, _)
     }
index 0a58039..a6d21af 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.cps.ncmp.impl.utils
 import org.onap.cps.ncmp.api.exceptions.CmHandleNotFoundException
 import org.onap.cps.ncmp.exceptions.NoAlternateIdMatchFoundException
 import org.onap.cps.ncmp.impl.inventory.InventoryPersistence
-import org.onap.cps.spi.model.DataNode
+import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
 import spock.lang.Specification
 
 class AlternateIdMatcherSpec extends Specification {
@@ -33,14 +33,14 @@ class AlternateIdMatcherSpec extends Specification {
 
     def setup() {
         given: 'cm handle in the registry with alternate id /a/b'
-            mockInventoryPersistence.getCmHandleDataNodeByAlternateId('/a/b') >> new DataNode()
+            mockInventoryPersistence.getYangModelCmHandleByAlternateId('/a/b') >> new YangModelCmHandle()
         and: 'no other cm handle'
-            mockInventoryPersistence.getCmHandleDataNodeByAlternateId(_) >> { throw new CmHandleNotFoundException('') }
+            mockInventoryPersistence.getYangModelCmHandleByAlternateId(_) >> { throw new CmHandleNotFoundException('') }
     }
 
     def 'Finding longest alternate id matches.'() {
         expect: 'querying for alternate id a matching result found'
-            assert objectUnderTest.getCmHandleDataNodeByLongestMatchingAlternateId(targetAlternateId, '/') != null
+            assert objectUnderTest.getYangModelCmHandleByLongestMatchingAlternateId(targetAlternateId, '/') != null
         where: 'the following parameters are used'
             scenario                                | targetAlternateId
             'exact match'                           | '/a/b'
@@ -55,7 +55,7 @@ class AlternateIdMatcherSpec extends Specification {
 
     def 'Attempt to find longest alternate id match without any matches.'() {
         when: 'attempt to find alternateId'
-            objectUnderTest.getCmHandleDataNodeByLongestMatchingAlternateId(targetAlternateId, '/')
+            objectUnderTest.getYangModelCmHandleByLongestMatchingAlternateId(targetAlternateId, '/')
         then: 'no alternate id match found exception thrown'
             def thrown = thrown(NoAlternateIdMatchFoundException)
         and: 'the exception has the relevant details from the error response'
@@ -73,12 +73,12 @@ class AlternateIdMatcherSpec extends Specification {
             def result = objectUnderTest.getCmHandleId(cmHandleReference)
         then: 'the inventory persistence service returns a cm handle (or not)'
             mockInventoryPersistence.isExistingCmHandleId(cmHandleReference) >> existingCmHandleIdResponse
-            mockInventoryPersistence.getCmHandleDataNodeByAlternateId(cmHandleReference) >> alternateIdGetResponse
+            mockInventoryPersistence.getYangModelCmHandleByAlternateId(cmHandleReference) >> alternateIdGetResponse
         and: 'correct result is returned'
             assert result == cmHandleReference
-        where:
+        where: 'the following parameters are used'
             cmHandleReference | existingCmHandleIdResponse | alternateIdGetResponse
             'ch-1'            |  true                      |  ''
-            'alt-1'           |  false                     |  new DataNode(leaves: [id:'alt-1'])
+            'alt-1'           |  false                     |  new YangModelCmHandle(id: 'alt-1')
     }
 }
index a2d3a4a..b00893b 100644 (file)
@@ -41,7 +41,7 @@ class CmHandleQueryByAlternateIdPerfTest extends NcmpPerfTestBase {
         when: 'an alternate id as cps path query'
             resourceMeter.start()
             def cpsPath = "/a/b/c/d-5/e/f/g/h/i"
-            def dataNodes = objectUnderTest.getCmHandleDataNodeByLongestMatchingAlternateId(cpsPath, '/')
+            def dataNodes = objectUnderTest.getYangModelCmHandleByLongestMatchingAlternateId(cpsPath, '/')
         and: 'the ids of the result are extracted and converted to xpath'
             def cpsXpaths = dataNodes.stream().map(dataNode -> "/dmi-registry/cm-handles[@id='${dataNode.leaves.id}']".toString() ).collect(Collectors.toSet())
         and: 'a single get is executed to get all the parent objects and their descendants'