diff options
Diffstat (limited to 'cps-ncmp-service')
14 files changed, 81 insertions, 57 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index f8cab4f1ca..f44c28c713 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -51,6 +51,7 @@ import org.onap.cps.ncmp.api.impl.operations.DmiOperations; import org.onap.cps.ncmp.api.impl.utils.YangDataConverter; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.ncmp.api.inventory.CmHandleState; +import org.onap.cps.ncmp.api.inventory.CompositeState; import org.onap.cps.ncmp.api.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.inventory.sync.ModuleSyncService; import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters; @@ -231,13 +232,14 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>(); try { cmHandleRegistrationResponses = dmiPluginRegistration.getCreatedCmHandles().stream() - .map(cmHandle -> - YangModelCmHandle.toYangModelCmHandle( + .map(cmHandle -> { + setCompositeStateToAdvised(cmHandle); + return YangModelCmHandle.toYangModelCmHandle( dmiPluginRegistration.getDmiPlugin(), dmiPluginRegistration.getDmiDataPlugin(), dmiPluginRegistration.getDmiModelPlugin(), - CmHandleState.ADVISED, - cmHandle) + cmHandle); + } ) .map(this::registerNewCmHandle) .collect(Collectors.toList()); @@ -250,6 +252,13 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService return cmHandleRegistrationResponses; } + private void setCompositeStateToAdvised(final NcmpServiceCmHandle ncmpServiceCmHandle) { + final CompositeState compositeState = new CompositeState(); + compositeState.setCmHandleState(CmHandleState.ADVISED); + compositeState.setLastUpdateTimeNow(); + ncmpServiceCmHandle.setCompositeState(compositeState); + } + protected List<CmHandleRegistrationResponse> parseAndRemoveCmHandlesInDmiRegistration( final List<String> tobeRemovedCmHandles) { final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java index 82ea00eb32..95ff48a9c2 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java @@ -78,8 +78,7 @@ public class YangDataConverter { (String) cmHandleDataNode.getLeaves().get("dmi-service-name"), (String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"), (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"), - ncmpServiceCmHandle.getCompositeState().getCmHandleState(), - ncmpServiceCmHandle + ncmpServiceCmHandle ); } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java index 5b719054a6..65e03f1f9d 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java @@ -34,9 +34,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.onap.cps.ncmp.api.impl.operations.RequiredDmiService; -import org.onap.cps.ncmp.api.inventory.CmHandleState; import org.onap.cps.ncmp.api.inventory.CompositeState; -import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder; import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; import org.onap.cps.utils.CpsValidator; @@ -70,8 +68,6 @@ public class YangModelCmHandle { @JsonProperty("public-properties") private List<Property> publicProperties; - private static final CompositeStateBuilder compositeStateBuilder = new CompositeStateBuilder(); - /** * Create a yangModelCmHandle. * @@ -84,7 +80,6 @@ public class YangModelCmHandle { public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName, final String dmiDataServiceName, final String dmiModelServiceName, - final CmHandleState cmHandleState, final NcmpServiceCmHandle ncmpServiceCmHandle) { CpsValidator.validateNameCharacters(ncmpServiceCmHandle.getCmHandleId()); final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle(); @@ -95,8 +90,7 @@ public class YangModelCmHandle { yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties())); yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties( ncmpServiceCmHandle.getPublicProperties())); - compositeStateBuilder.withCmHandleState(cmHandleState); - yangModelCmHandle.setCompositeState(compositeStateBuilder.build()); + yangModelCmHandle.setCompositeState(ncmpServiceCmHandle.getCompositeState()); return yangModelCmHandle; } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeStateBuilder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeStateBuilder.java index f4d96389de..012ba5ede2 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeStateBuilder.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CompositeStateBuilder.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada - * Copyright (C) 2022 Nordix Foundation. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,18 +115,13 @@ public class CompositeStateBuilder { .get("cm-handle-state")); for (final DataNode stateChildNode : dataNode.getChildDataNodes()) { if (stateChildNode.getXpath().endsWith("/lock-reason")) { - this.lockReason = new LockReason(LockReasonCategory.valueOf( - (String) stateChildNode.getLeaves().get("reason")), - (String) stateChildNode.getLeaves().get("details")); + this.lockReason = getLockReason(stateChildNode); } if (stateChildNode.getXpath().endsWith("/datastores")) { for (final DataNode dataStoreNodes : stateChildNode.getChildDataNodes()) { Operational operationalDataStore = null; if (dataStoreNodes.getXpath().contains("/operational")) { - operationalDataStore = Operational.builder() - .syncState(SyncState.valueOf((String) dataStoreNodes.getLeaves().get("sync-state"))) - .lastSyncTime((String) dataStoreNodes.getLeaves().get("last-sync-time")) - .build(); + operationalDataStore = getOperationalDataStore(dataStoreNodes); } this.datastores = DataStores.builder().operationalDataStore(operationalDataStore).build(); } @@ -135,4 +130,18 @@ public class CompositeStateBuilder { return this; } + private Operational getOperationalDataStore(final DataNode dataStoreNodes) { + return Operational.builder() + .syncState(SyncState.valueOf((String) dataStoreNodes.getLeaves().get("sync-state"))) + .lastSyncTime((String) dataStoreNodes.getLeaves().get("last-sync-time")) + .build(); + } + + private LockReason getLockReason(final DataNode stateChildNode) { + final boolean isLockReasonExists = stateChildNode.getLeaves().containsKey("reason"); + return new LockReason(isLockReasonExists + ? LockReasonCategory.valueOf((String) stateChildNode.getLeaves().get("reason")) + : null, (String) stateChildNode.getLeaves().get("details")); + } + } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java index 1985bd959a..c24063cb45 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java @@ -60,7 +60,7 @@ public class InventoryPersistence { */ public CompositeState getCmHandleState(final String cmHandleId) { final DataNode stateAsDataNode = cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - String.format(XPATH_TO_CM_HANDLE, cmHandleId) + "/state", + String.format(XPATH_TO_CM_HANDLE, cmHandleId) + "/state", FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); return compositeStateBuilder.fromDataNode(stateAsDataNode).build(); } @@ -96,11 +96,13 @@ public class InventoryPersistence { * Method to return data nodes representing the cm handles. * * @param cpsPath cps path for which the cmHandle is requested + * @param fetchDescendantsOption defines the scope of data to fetch: either single node or all the descendant nodes * @return a list of data nodes representing the cm handles. */ - public List<DataNode> getCmHandleDataNodesByCpsPath(final String cpsPath) { + public List<DataNode> getCmHandleDataNodesByCpsPath(final String cpsPath, + final FetchDescendantsOption fetchDescendantsOption) { return cpsDataPersistenceService.queryDataNodes( - NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath, FetchDescendantsOption.OMIT_DESCENDANTS); + NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath, fetchDescendantsOption); } /** @@ -111,9 +113,9 @@ public class InventoryPersistence { */ public List<DataNode> getCmHandlesByIdAndState(final String cmHandleId, final CmHandleState cmHandleState) { return cpsDataPersistenceService.queryDataNodes(NCMP_DATASPACE_NAME, - NCMP_DMI_REGISTRY_ANCHOR, "//cm-handles[@id='" + cmHandleId + "']/state[@cm-handle-state=\"" - + cmHandleState + "\"]/ancestor::cm-handles", - FetchDescendantsOption.OMIT_DESCENDANTS); + NCMP_DMI_REGISTRY_ANCHOR, "//cm-handles[@id='" + cmHandleId + "']/state[@cm-handle-state=\"" + + cmHandleState + "\"]/ancestor::cm-handles", + FetchDescendantsOption.OMIT_DESCENDANTS); } /** @@ -123,9 +125,9 @@ public class InventoryPersistence { */ public List<DataNode> getCmHandlesByOperationalSyncState(final SyncState syncState) { return cpsDataPersistenceService.queryDataNodes(NCMP_DATASPACE_NAME, - NCMP_DMI_REGISTRY_ANCHOR, "//state/datastores" - + "/operational[@sync-state=\"" + syncState + "\"]/ancestor::cm-handles", - FetchDescendantsOption.OMIT_DESCENDANTS); + NCMP_DMI_REGISTRY_ANCHOR, "//state/datastores" + + "/operational[@sync-state=\"" + syncState + "\"]/ancestor::cm-handles", + FetchDescendantsOption.OMIT_DESCENDANTS); } /** @@ -145,4 +147,4 @@ public class InventoryPersistence { FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); } -} +}
\ No newline at end of file diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java index c920649b8b..e590ca1cd0 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java @@ -27,7 +27,6 @@ import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; import org.onap.cps.ncmp.api.inventory.CmHandleState; import org.onap.cps.ncmp.api.inventory.CompositeState; -import org.onap.cps.ncmp.api.inventory.CompositeState.LockReason; import org.onap.cps.ncmp.api.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.inventory.LockReasonCategory; import org.springframework.scheduling.annotation.Scheduled; @@ -77,14 +76,19 @@ public class ModuleSyncWatchdog { @Scheduled(fixedDelayString = "${timers.locked-modules-sync.sleep-time-ms:300000}") public void executeLockedMisbehavingCmHandlePoll() { final List<YangModelCmHandle> lockedMisbehavingCmHandles = syncUtils.getLockedMisbehavingYangModelCmHandles(); - for (final YangModelCmHandle lockedMisbehavingModelCmHandle: lockedMisbehavingCmHandles) { - final CompositeState updatedCompositeState = lockedMisbehavingModelCmHandle.getCompositeState(); - updatedCompositeState.setCmHandleState(CmHandleState.ADVISED); - updatedCompositeState.setLastUpdateTimeNow(); - updatedCompositeState.setLockReason(LockReason.builder() - .details(updatedCompositeState.getLockReason().getDetails()).build()); + for (final YangModelCmHandle lockedMisbehavingModelCmHandle : lockedMisbehavingCmHandles) { + final CompositeState compositeState = lockedMisbehavingModelCmHandle.getCompositeState(); + setCompositeStateToAdvisedAndRetainOldLockReasonDetails(compositeState); log.debug("Locked misbehaving cm handle {} is being recycled", lockedMisbehavingModelCmHandle.getId()); - inventoryPersistence.saveCmHandleState(lockedMisbehavingModelCmHandle.getId(), updatedCompositeState); + inventoryPersistence.saveCmHandleState(lockedMisbehavingModelCmHandle.getId(), compositeState); } } + + private void setCompositeStateToAdvisedAndRetainOldLockReasonDetails(final CompositeState compositeState) { + compositeState.setCmHandleState(CmHandleState.ADVISED); + compositeState.setLastUpdateTimeNow(); + final String oldLockReasonDetails = compositeState.getLockReason().getDetails(); + compositeState.setLockReason(CompositeState.LockReason.builder() + .details(oldLockReasonDetails).build()); + } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java index b5456ab149..42edcb7ec8 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java @@ -43,6 +43,7 @@ import org.onap.cps.ncmp.api.inventory.CompositeState; import org.onap.cps.ncmp.api.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.inventory.LockReasonCategory; import org.onap.cps.ncmp.api.inventory.SyncState; +import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.model.DataNode; import org.onap.cps.utils.JsonObjectMapper; import org.springframework.http.ResponseEntity; @@ -111,7 +112,8 @@ public class SyncUtils { */ public List<YangModelCmHandle> getLockedMisbehavingYangModelCmHandles() { final List<DataNode> lockedCmHandleAsDataNodeList = inventoryPersistence.getCmHandleDataNodesByCpsPath( - "//lock-reason[@reason=\"LOCKED_MISBEHAVING\"]/ancestor::cm-handles"); + "//lock-reason[@reason=\"LOCKED_MISBEHAVING\"]/ancestor::cm-handles", + FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); return lockedCmHandleAsDataNodeList.stream() .map(cmHandle -> YangDataConverter.convertCmHandleToYangModel(cmHandle, cmHandle.getLeaves().get("id").toString())).collect(Collectors.toList()); diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy index 5357c42b7d..5d6d0a512d 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy @@ -164,9 +164,14 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { } and: 'save list elements is invoked with the expected parameters' interaction { - def expectedJsonData = """{"cm-handles":[{"id":"cmhandle","dmi-service-name":"my-server","state":{"cm-handle-state":"ADVISED"},"additional-properties":$expectedDmiProperties,"public-properties":$expectedPublicProperties}]}""" 1 * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry', - '/dmi-registry', expectedJsonData, noTimestamp) + '/dmi-registry', _, noTimestamp) >> { + args -> { + assert args[3].startsWith('{"cm-handles":[{"id":"cmhandle","dmi-service-name":"my-server","state":{"cm-handle-state":"ADVISED","last-update-time":"20') + assert args[3].contains(expectedDmiProperties) + assert args[3].contains(expectedPublicProperties) + } + } } where: scenario | dmiProperties | publicProperties || expectedDmiProperties | expectedPublicProperties diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy index d58fe6a7cd..1d4312c682 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy @@ -238,10 +238,11 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { when: 'parse and create cm handle in dmi registration then sync module' objectUnderTest.parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(mockDmiPluginRegistration) then: 'validate params for creating anchor and list elements' - 1 * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry', - '/dmi-registry', '{"cm-handles":[{"id":"some-cm-handle-id",' + - '"state":{"cm-handle-state":"ADVISED"},' - + '"additional-properties":[],"public-properties":[]}]}', null) + 1 * mockCpsDataService.saveListElements('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', _, null) >> { + args -> { + assert args[3].startsWith('{"cm-handles":[{"id":"some-cm-handle-id","state":{"cm-handle-state":"ADVISED","last-update-time":"20') + } + } } def 'Execute cm handle id search'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceSpec.groovy index 8c23b302c5..46bd047ab7 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/InventoryPersistenceSpec.groovy @@ -189,10 +189,10 @@ class InventoryPersistenceSpec extends Specification { def cpsPath = '//cps-path' and: 'cps data service returns a valid data node' mockCpsDataPersistenceService.queryDataNodes('NCMP-Admin', 'ncmp-dmi-registry', - cpsPath, OMIT_DESCENDANTS) + cpsPath, INCLUDE_ALL_DESCENDANTS) >> Arrays.asList(cmHandleDataNode) when: 'get cm handles by cps path is invoked' - def result = objectUnderTest.getCmHandleDataNodesByCpsPath(cpsPath) + def result = objectUnderTest.getCmHandleDataNodesByCpsPath(cpsPath, INCLUDE_ALL_DESCENDANTS) then: 'the returned result is a list of data nodes returned by cps data service' assert result.contains(cmHandleDataNode) } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncServiceSpec.groovy index 8050a571af..f93b3a73ed 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncServiceSpec.groovy @@ -24,7 +24,6 @@ import org.onap.cps.api.CpsAdminService import org.onap.cps.api.CpsModuleService import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle -import org.onap.cps.ncmp.api.inventory.CmHandleState import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle import org.onap.cps.spi.model.ModuleReference import spock.lang.Specification @@ -45,7 +44,7 @@ class ModuleSyncServiceSpec extends Specification { def ncmpServiceCmHandle = new NcmpServiceCmHandle() def dmiServiceName = 'some service name' ncmpServiceCmHandle.cmHandleId = 'cmHandleId-1' - def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '' , '', CmHandleState.ADVISED, ncmpServiceCmHandle) + def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle) and: 'DMI operations returns some module references' def moduleReferences = [ new ModuleReference(moduleName:'module1',revision:'1'), new ModuleReference(moduleName:'module2',revision:'2') ] diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/SyncUtilsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/SyncUtilsSpec.groovy index 14f2015755..2c45ab7695 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/SyncUtilsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/sync/SyncUtilsSpec.groovy @@ -30,6 +30,7 @@ import org.onap.cps.ncmp.api.inventory.CompositeState import org.onap.cps.ncmp.api.inventory.InventoryPersistence import org.onap.cps.ncmp.api.inventory.LockReasonCategory import org.onap.cps.ncmp.api.inventory.SyncState +import org.onap.cps.spi.FetchDescendantsOption import org.onap.cps.spi.model.DataNode import org.onap.cps.utils.JsonObjectMapper import org.springframework.http.HttpStatus @@ -83,7 +84,8 @@ class SyncUtilsSpec extends Specification{ def 'Get all locked Cm-Handle where Lock Reason is LOCKED_MISBEHAVING cm handle #scenario'() { given: 'the cps (persistence service) returns a collection of data nodes' mockInventoryPersistence.getCmHandleDataNodesByCpsPath( - '//lock-reason[@reason="LOCKED_MISBEHAVING"]/ancestor::cm-handles') >> [dataNode ] + '//lock-reason[@reason="LOCKED_MISBEHAVING"]/ancestor::cm-handles', + FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) >> [dataNode ] when: 'get locked Misbehaving cm handle is called' def result = objectUnderTest.getLockedMisbehavingYangModelCmHandles() then: 'the returned cm handle collection is the correct size' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/YangModelCmHandleSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/YangModelCmHandleSpec.groovy index 3376691ee7..438ebed8f6 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/YangModelCmHandleSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/YangModelCmHandleSpec.groovy @@ -1,5 +1,5 @@ /* - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * Copyright (C) 2021-2022 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,6 @@ package org.onap.cps.ncmp.api.models import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle -import org.onap.cps.ncmp.api.inventory.CmHandleState import spock.lang.Specification import static org.onap.cps.ncmp.api.impl.operations.RequiredDmiService.DATA @@ -36,7 +35,7 @@ class YangModelCmHandleSpec extends Specification { ncmpServiceCmHandle.dmiProperties = [myDmiProperty:'value1'] ncmpServiceCmHandle.publicProperties = [myPublicProperty:'value2'] when: 'it is converted to a yang model cm handle' - def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('','','', CmHandleState.ADVISED, ncmpServiceCmHandle) + def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle) then: 'the result has the right size' assert objectUnderTest.dmiProperties.size() == 1 and: 'the DMI property in the result has the correct name and value' @@ -49,7 +48,7 @@ class YangModelCmHandleSpec extends Specification { def 'Resolve DMI service name: #scenario and #requiredService service require.'() { given: 'a yang model cm handle' - def objectUnderTest = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, dmiDataServiceName, dmiModelServiceName, CmHandleState.ADVISED, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1')) + def objectUnderTest = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, dmiDataServiceName, dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1')) expect: assert objectUnderTest.resolveDmiServiceName(requiredService) == expectedService where: diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/utils/DmiServiceUrlBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/utils/DmiServiceUrlBuilderSpec.groovy index b3ea3b870d..2d993973eb 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/utils/DmiServiceUrlBuilderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/utils/DmiServiceUrlBuilderSpec.groovy @@ -20,7 +20,6 @@ package org.onap.cps.ncmp.api.utils -import org.onap.cps.ncmp.api.inventory.CmHandleState import static org.onap.cps.ncmp.api.impl.operations.DmiOperations.DataStoreEnum.PASSTHROUGH_RUNNING @@ -35,7 +34,7 @@ class DmiServiceUrlBuilderSpec extends Specification { @Shared YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('dmiServiceName', - 'dmiDataServiceName', 'dmiModuleServiceName', CmHandleState.ADVISED , new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id')) + 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id')) NcmpConfiguration.DmiProperties dmiProperties = new NcmpConfiguration.DmiProperties() |