+ def 'Send UPDATE operation when non-root data nodes are changed.'() {
+ given: 'notification is enabled'
+ spyNotificationProperties.isEnabled() >> true
+ and: 'event factory creates event if operation is UPDATE'
+ def cpsDataUpdatedEvent = new CpsDataUpdatedEvent()
+ mockCpsDataUpdatedEventFactory.createCpsDataUpdatedEvent(myDataspacePublishedName, myAnchorName, myObservedTimestamp,
+ Operation.UPDATE) >> cpsDataUpdatedEvent
+ when: 'dataUpdatedEvent is received for non-root xpath'
+ def future = objectUnderTest.processDataUpdatedEvent(myDataspacePublishedName, myAnchorName, myObservedTimestamp, '/non-root-node',
+ operation)
+ and: 'wait for async processing to complete'
+ future.get(10, TimeUnit.SECONDS)
+ then: 'async process completed successfully'
+ future.isDone()
+ and: 'notification is sent'
+ 1 * mockNotificationPublisher.sendNotification(cpsDataUpdatedEvent)
+ where:
+ operation << [Operation.CREATE, Operation.UPDATE, Operation.DELETE]
+ }
+
+ def 'Send same operation when root nodes are changed.'() {
+ given: 'notification is enabled'
+ spyNotificationProperties.isEnabled() >> true
+ and: 'event factory creates event if operation is #operation'
+ def cpsDataUpdatedEvent = new CpsDataUpdatedEvent()
+ mockCpsDataUpdatedEventFactory.createCpsDataUpdatedEvent(myDataspacePublishedName, myAnchorName, myObservedTimestamp,
+ operation) >> cpsDataUpdatedEvent
+ when: 'dataUpdatedEvent is received for root xpath'
+ def future = objectUnderTest.processDataUpdatedEvent(myDataspacePublishedName, myAnchorName, myObservedTimestamp, '/',
+ operation)
+ and: 'wait for async processing to complete'
+ future.get(10, TimeUnit.SECONDS)
+ then: 'async process completed successfully'
+ future.isDone()
+ and: 'notification is sent'
+ 1 * mockNotificationPublisher.sendNotification(cpsDataUpdatedEvent)
+ where:
+ operation << [Operation.CREATE, Operation.UPDATE, Operation.DELETE]
+ }
+
+