+ def cpsDataUpdatedEvent = objectUnderTest.createCpsDataUpdatedEvent(anchor,
+ DateTimeUtility.toOffsetDateTime(inputObservedTimestamp), Operation.CREATE)
+ then: 'CPS data updated event is created with correct envelope'
+ with(cpsDataUpdatedEvent) {
+ type == 'org.onap.cps.data-updated-event'
+ source == new URI('urn:cps:org.onap.cps')
+ schema == new URI('urn:cps:org.onap.cps:data-updated-event-schema:v1')
+ StringUtils.hasText(id)
+ content != null
+ }
+ and: 'correct content'
+ with(cpsDataUpdatedEvent.content) {
+ assert isExpectedDateTimeFormat(observedTimestamp): "$observedTimestamp is not in $dateTimeFormat format"
+ if (inputObservedTimestamp != null)
+ assert observedTimestamp == inputObservedTimestamp
+ else
+ assert OffsetDateTime.now().minusSeconds(20).isBefore(
+ DateTimeUtility.toOffsetDateTime(observedTimestamp))
+ assert anchorName == 'my-anchorname'
+ assert dataspaceName == 'my-dataspace'
+ assert schemaSetName == 'my-schemaset-name'
+ assert operation == Content.Operation.CREATE
+ assert data == new Data().withAdditionalProperty('leafName', 'leafValue')
+ }
+ where:
+ scenario | inputObservedTimestamp
+ 'with observed timestamp -0400' | '2021-01-01T23:00:00.345-0400'
+ 'with observed timestamp +0400' | '2021-01-01T23:00:00.345+0400'
+ 'missing observed timestamp' | null
+ }