Improve test coverage on CompositeStateBuilder 14/129814/1
authorbmiklos <miklos.baranyak@est.tech>
Thu, 7 Jul 2022 11:32:16 +0000 (13:32 +0200)
committerbmiklos <miklos.baranyak@est.tech>
Thu, 7 Jul 2022 11:36:32 +0000 (13:36 +0200)
Issue-ID: CPS-475
Change-Id: Id24f2b0c6fe95ca9c7559a8dbd160c4566ddc32f
Signed-off-by: bmiklos <miklos.baranyak@est.tech>
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CompositeStateBuilderSpec.groovy

index ad65763..fa43798 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.cps.ncmp.api.inventory
 
 import org.onap.cps.spi.model.DataNode
 import org.onap.cps.spi.model.DataNodeBuilder
+import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder
 import spock.lang.Specification
 
 import java.time.OffsetDateTime
@@ -63,4 +64,25 @@ class CompositeStateBuilderSpec extends Specification {
             assert compositeState.cmHandleState == CmHandleState.ADVISED
     }
 
+    def 'CompositeStateBuilder build'() {
+        given: 'A CompositeStateBuilder with all private fields set'
+            def finalCompositeStateBuilder = new CompositeStateBuilder()
+                .withCmHandleState(CmHandleState.ADVISED)
+                .withLastUpdatedTime(formattedDateAndTime.toString())
+                .withLockReason(LockReasonCategory.LOCKED_MODULE_SYNC_FAILED, 'locked details')
+                .withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, formattedDateAndTime)
+        when: 'build is called'
+            def result = finalCompositeStateBuilder.build()
+        then: 'result is of the correct type'
+            assert result.class == CompositeState.class
+        and: 'built result should have correct values'
+            assert !result.getDataSyncEnabled()
+            assert result.getLastUpdateTime() == formattedDateAndTime
+            assert result.getLockReason().getLockReasonCategory() == LockReasonCategory.LOCKED_MODULE_SYNC_FAILED
+            assert result.getLockReason().getDetails() == 'locked details'
+            assert result.getCmHandleState() == CmHandleState.ADVISED
+            assert result.getDataStores().getOperationalDataStore().getDataStoreSyncState() == DataStoreSyncState.SYNCHRONIZED
+            assert result.getDataStores().getOperationalDataStore().getLastSyncTime() == formattedDateAndTime
+    }
+
 }