import com.fasterxml.jackson.databind.ObjectMapper
import spock.lang.Specification
-
import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
-import static CompositeState.DataStores
-import static CompositeState.Operational
+import static org.onap.cps.ncmp.api.inventory.CompositeState.DataStores
+import static org.onap.cps.ncmp.api.inventory.CompositeState.Operational
import static org.onap.cps.ncmp.utils.TestUtils.getResourceFileContent
import static org.springframework.util.StringUtils.trimAllWhitespace
def "Composite State Specification"() {
given: "a Composite State"
def compositeState = new CompositeState(cmHandleState: CmHandleState.ADVISED,
- lockReason: CompositeState.LockReason.builder().lockReasonCategory(LockReasonCategory.LOCKED_MISBEHAVING).details("lock misbehaving details").build(),
+ lockReason: CompositeState.LockReason.builder().lockReasonCategory(LockReasonCategory.LOCKED_MODULE_SYNC_FAILED).details("lock details").build(),
lastUpdateTime: formattedDateAndTime.toString(),
dataSyncEnabled: false,
dataStores: dataStores())
when: 'it is represented as JSON'
- def jsonStateModelAsString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(compositeState)
+ def resultJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(compositeState)
then: 'it matches expected state model as JSON'
- def expectedStateModelAsjson = getResourceFileContent('expectedStateModel.json')
- assert trimAllWhitespace(expectedStateModelAsjson) == trimAllWhitespace(jsonStateModelAsString)
+ def expectedJson = getResourceFileContent('expectedStateModel.json')
+ assert trimAllWhitespace(expectedJson) == trimAllWhitespace(resultJson)
}
def dataStores() {
DataStores.builder().operationalDataStore(Operational.builder()
- .syncState('NONE_REQUESTED')
+ .dataStoreSyncState(DataStoreSyncState.NONE_REQUESTED)
.lastSyncTime(formattedDateAndTime.toString()).build())
.build()
}