From 55164b23839f187ae089fd08c34487dcfd165188 Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Tue, 26 Sep 2023 12:11:42 +0100 Subject: Expose REST endpoint to update YANG schema set using moduleSetTag - Added new schema to upgrade model into component. - Modified Ncmp rest input mapper to add upgradedCmHandles attributes. - Modified cm handle state mapper to add new lock reason. - Added new method to parse and upgrade Cm handles in DmiRegistration. - YANG data converter is modified to add "module-set-tag" atribute. - Cm handle new query method is added for cps path without appending ancestor. - Modified setCompositeStateForRetry to add lock reason. - New lock reason category is added. - Existing module sync service is modified to upgrade the model "syncAndCreateOrUpgradeSchemaSetAndAnchor". - Sync util method "getModuleSyncFailedCmHandles" to modified to add another lock reason "LOCKED_MISBEHAVING". - Added new attribute "UpgradedCmHandles" into DmiPluginRegistration and DmiPluginRegistrationResponse. - New attribute "moduleSetTag" is added into NcmpServiceCmHandle. - New model "UpgradedCmHandles" is added. - New method "updateSchemaSetWithExistingModules" is added into cps module service to update cm handle with exsting model. - Code coverage is reducced to 96 percentage that would be addressed and pushed into new patch. Issue-ID: CPS-1798 Signed-off-by: sourabh_sourabh Change-Id: I540acb404e38fc434de87a0d959bfde710a18b03 Signed-off-by: sourabh_sourabh --- .../rest/controller/NetworkCmProxyControllerSpec.groovy | 3 +-- .../cps/ncmp/rest/mapper/CmHandleStateMapperSpec.groovy | 15 ++++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'cps-ncmp-rest/src/test/groovy/org') diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy index 6bfa5936ed..de044d0aac 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy @@ -615,8 +615,7 @@ class NetworkCmProxyControllerSpec extends Specification { def expectedContent = [ '"state":', '"cmHandleState":"ADVISED"', - '"reason":"LOCKED_MISBEHAVING"', - '"details":"lock details"', + '"lockReason":{"reason":"MODULE_SYNC_FAILED","details":"lock details"}', '"lastUpdateTime":"2022-12-31T20:30:40.000+0000"', '"dataSyncEnabled":false', '"dataSyncState":', diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapperSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapperSpec.groovy index 1fa83a539c..f394f91938 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapperSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapperSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation + * Copyright (C) 2022-2023 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package org.onap.cps.ncmp.rest.mapper +import static org.onap.cps.ncmp.api.impl.inventory.LockReasonCategory.LOCKED_MISBEHAVING import static org.onap.cps.ncmp.api.impl.inventory.LockReasonCategory.MODULE_SYNC_FAILED import org.mapstruct.factory.Mappers @@ -55,7 +56,7 @@ class CmHandleStateMapperSpec extends Specification { and: 'mapped result should have correct values' assert !result.dataSyncEnabled assert result.lastUpdateTime == formattedDateAndTime - assert result.lockReason.reason == 'LOCKED_MISBEHAVING' + assert result.lockReason.reason == MODULE_SYNC_FAILED.name() assert result.lockReason.details == 'locked details' assert result.cmHandleState == 'ADVISED' assert result.dataSyncState.operational.getSyncState() != null @@ -69,17 +70,17 @@ class CmHandleStateMapperSpec extends Specification { def 'Internal to External Lock Reason Mapping of #scenario'() { given: 'a LOCKED composite state with locked reason of #scenario' - def compositeState = new CompositeStateBuilder() + def compositeState = new CompositeStateBuilder() .withCmHandleState(CmHandleState.LOCKED) .withLockReason(lockReason, '').build() when: 'the composite state is mapped to a CMHandle composite state' - def result = objectUnderTest.toCmHandleCompositeStateExternalLockReason(compositeState) + def result = objectUnderTest.toCmHandleCompositeStateExternalLockReason(compositeState) then: 'the composite state contains the expected lock Reason and details' - result.getLockReason().getReason() == expectedExternalLockReason + result.getLockReason().getReason() == (expectedExternalLockReason as String) where: scenario | lockReason || expectedExternalLockReason - 'MODULE_SYNC_FAILED' | MODULE_SYNC_FAILED || 'LOCKED_MISBEHAVING' - 'null value' | null || null + 'MODULE_SYNC_FAILED' | MODULE_SYNC_FAILED || MODULE_SYNC_FAILED + 'null value' | null || LOCKED_MISBEHAVING } } -- cgit 1.2.3-korg