X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-rest%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fncmp%2Frest%2Fmapper%2FCmHandleStateMapperSpec.groovy;h=b5f7f0edeba5caa361536f9dc971ee9483d949fc;hb=605e2ad3d0e612a020d1a3236765e27154132afb;hp=bc9ea80bd265a7830962100520d3948921239458;hpb=e5cdeae638105b2a3a191fc2273c63d73ff8503c;p=cps.git 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 bc9ea80bd..b5f7f0ede 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,14 +20,15 @@ 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 -import org.onap.cps.ncmp.api.inventory.CmHandleState -import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder -import org.onap.cps.ncmp.api.inventory.LockReasonCategory +import org.onap.cps.ncmp.api.impl.inventory.CmHandleState +import org.onap.cps.ncmp.api.impl.inventory.CompositeStateBuilder import org.onap.cps.ncmp.rest.model.CmHandleCompositeState -import org.onap.cps.ncmp.api.inventory.DataStoreSyncState +import org.onap.cps.ncmp.api.impl.inventory.DataStoreSyncState import spock.lang.Specification - import java.time.OffsetDateTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter @@ -43,7 +44,7 @@ class CmHandleStateMapperSpec extends Specification { def compositeState = new CompositeStateBuilder() .withCmHandleState(CmHandleState.ADVISED) .withLastUpdatedTime(formattedDateAndTime.toString()) - .withLockReason(LockReasonCategory.MODULE_SYNC_FAILED, 'locked details') + .withLockReason(MODULE_SYNC_FAILED, 'locked details') .withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, formattedDateAndTime).build() compositeState.setDataSyncEnabled(false) when: 'mapper is called' @@ -53,7 +54,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 @@ -61,22 +62,22 @@ class CmHandleStateMapperSpec extends Specification { def 'Handling null state.'() { expect: 'converting null returns null' - objectUnderTest.toDataStores(null) == null + CmHandleStateMapper.toDataStores(null) == null } 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' | LockReasonCategory.MODULE_SYNC_FAILED || 'LOCKED_MISBEHAVING' - 'null value' | null || null + scenario | lockReason || expectedExternalLockReason + 'MODULE_SYNC_FAILED' | MODULE_SYNC_FAILED || MODULE_SYNC_FAILED + 'null value' | null || LOCKED_MISBEHAVING } }