Fix @Ignore test
[cps.git] / cps-ncmp-rest / src / test / groovy / org / onap / cps / ncmp / rest / mapper / CmHandleStateMapperSpec.groovy
index b1133a1..b5f7f0e 100644 (file)
@@ -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.
 
 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 spock.lang.Ignore
+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
@@ -44,7 +44,7 @@ class CmHandleStateMapperSpec extends Specification {
             def compositeState = new CompositeStateBuilder()
                 .withCmHandleState(CmHandleState.ADVISED)
                 .withLastUpdatedTime(formattedDateAndTime.toString())
-                .withLockReason(LockReasonCategory.LOCKED_MODULE_SYNC_FAILED, 'locked details')
+                .withLockReason(MODULE_SYNC_FAILED, 'locked details')
                 .withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, formattedDateAndTime).build()
         compositeState.setDataSyncEnabled(false)
         when: 'mapper is called'
@@ -54,31 +54,30 @@ 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
     }
 
-    @Ignore
     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
-            'LOCKED_MODULE_SYNC_FAILED' | LockReasonCategory.LOCKED_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
     }
 
 }