summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2022-07-07 15:14:53 +0000
committerGerrit Code Review <gerrit@onap.org>2022-07-07 15:14:53 +0000
commita88cee11a28900cf1e39fd01ffb700ea87b2af16 (patch)
treeca65ef7f2ddedfdf95d332edda99c12044f56ef6 /cps-ncmp-service/src/test
parenta556d4e26f28bf5067f967bc642e79d66b5a9027 (diff)
parentba26e40342ab37efbd2726ef34f942aeb175bd45 (diff)
Merge "Improve test coverage on CompositeStateBuilder"
Diffstat (limited to 'cps-ncmp-service/src/test')
-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
+ }
+
}