summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
authorbmiklos <miklos.baranyak@est.tech>2022-07-07 13:32:16 +0200
committerbmiklos <miklos.baranyak@est.tech>2022-07-07 13:36:32 +0200
commitba26e40342ab37efbd2726ef34f942aeb175bd45 (patch)
tree529627ec16d5c95e1f2adab799e4738a38c6c889 /cps-ncmp-service
parentd6bd3aad095e76262e93fb68bbdb98b5f4bd9860 (diff)
Improve test coverage on CompositeStateBuilder
Issue-ID: CPS-475 Change-Id: Id24f2b0c6fe95ca9c7559a8dbd160c4566ddc32f Signed-off-by: bmiklos <miklos.baranyak@est.tech>
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CompositeStateBuilderSpec.groovy22
1 files changed, 22 insertions, 0 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CompositeStateBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CompositeStateBuilderSpec.groovy
index ad65763630..fa437987b5 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CompositeStateBuilderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/inventory/CompositeStateBuilderSpec.groovy
@@ -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
+ }
+
}