diff options
Diffstat (limited to 'cps-ncmp-service/src/test')
2 files changed, 28 insertions, 11 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy index 099fc5ac18..8f3d8d97ba 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy @@ -108,9 +108,24 @@ class ModuleOperationsUtilsSpec extends Specification{ assert compositeState.lockReason.lockReasonCategory == MODULE_SYNC_FAILED assert compositeState.lockReason.details.contains(expectedDetails) where: - scenario | lockReason || expectedDetails - 'does not exist' | null || 'Attempt #1 failed: new error message' - 'exists' | CompositeState.LockReason.builder().details("Attempt #2 failed: some error message").build() || 'Attempt #3 failed: new error message' + scenario | lockReason || expectedDetails + 'does not exist' | null || 'Attempt #1 failed: new error message' + 'exists' | CompositeState.LockReason.builder().details("Attempt #2 failed: some error message").build() || 'Attempt #3 failed: new error message' + } + + def 'Update lock reason details that contains #scenario'() { + given: 'A locked state' + def compositeState = new CompositeStateBuilder().withCmHandleState(CmHandleState.LOCKED) + .withLockReason(MODULE_UPGRADE, "Upgrade to ModuleSetTag: " + moduleSetTag).build() + when: 'update cm handle details' + objectUnderTest.updateLockReasonDetailsAndAttempts(compositeState, MODULE_UPGRADE_FAILED, 'new error message') + then: 'the composite state lock reason and details are updated' + assert compositeState.lockReason.lockReasonCategory == MODULE_UPGRADE_FAILED + assert compositeState.lockReason.details.contains("Upgrade to ModuleSetTag: " + expectedDetails) + where: + scenario | moduleSetTag || expectedDetails + 'a module set tag' | 'someModuleSetTag' || 'someModuleSetTag' + 'empty module set tag' | '' || 'not-specified' } def 'Get all locked Cm-Handle where Lock Reason is MODULE_SYNC_FAILED cm handle #scenario'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy index d5225cda29..2ded84fac1 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy @@ -76,7 +76,7 @@ class ModuleSyncServiceSpec extends Specification { when: 'module sync is triggered' objectUnderTest.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle) then: 'create schema set from module is invoked with correct parameters' - 1 * mockCpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', newModuleNameContentToMap, moduleReferences) + 1 * mockCpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', newModuleNameContentToMap, moduleReferences) and: 'anchor is created with the correct parameters' 1 * mockCpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', 'ch-1') where: 'the following parameters are used' @@ -110,15 +110,17 @@ class ModuleSyncServiceSpec extends Specification { mockCmHandleQueries.cmHandleHasState('otherId', CmHandleState.READY) >> true when: 'module sync is triggered' objectUnderTest.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle) - then: 'create schema set from module is invoked for the upgraded cm handle' - 1 * mockCpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences) + then: 'update schema set from module is invoked for the upgraded cm handle' + expectedCallsToUpgradeSchemaSet * mockCpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences) + and: 'create schema set from module is invoked for the upgraded cm handle' + expectedCallsToCeateSchemaSet * mockCpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences) and: 'No anchor is created for the upgraded cm handle' 0 * mockCpsAdminService.createAnchor(*_) where: 'the following parameters are used' - scenario | populateCache | existingCmHandlesWithSameTag - 'new' | false | [] - 'in cache' | true | [] - 'in database' | false | [cmHandleWithModuleSetTag] + scenario | populateCache | existingCmHandlesWithSameTag || expectedCallsToUpgradeSchemaSet | expectedCallsToCeateSchemaSet + 'new' | false | [] || 0 | 1 + 'in cache' | true | [] || 1 | 0 + 'in database' | false | [cmHandleWithModuleSetTag] || 1 | 0 } def 'upgrade model for a existing cm handle'() { @@ -138,7 +140,7 @@ class ModuleSyncServiceSpec extends Specification { when: 'module upgrade is triggered' objectUnderTest.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle) then: 'the upgrade is delegated to the module service (with the correct parameters)' - 1 * mockCpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'cmHandleId-1', Collections.emptyMap(), moduleReferences) + 1 * mockCpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'cmHandleId-1', Collections.emptyMap(), moduleReferences) } def 'Delete Schema Set for CmHandle'() { |