X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-service%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fnotification%2FNotificationServiceSpec.groovy;h=6ef6874b335b05d0d9d360ff2b8b25e22362366d;hb=refs%2Fchanges%2F42%2F128942%2F3;hp=c20bdeea7c495e126e8474e8aef8d62506fe272e;hpb=d3bb89c442eaad9d635deffd34fe5ae680394790;p=cps.git diff --git a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy index c20bdeea7..6ef6874b3 100644 --- a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy +++ b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy @@ -90,35 +90,15 @@ class NotificationServiceSpec extends Specification { 'dataspace name matches filter' | 'my-dataspace-published' || 1 } - 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(anchor, myObservedTimestamp, - Operation.UPDATE) >> cpsDataUpdatedEvent - when: 'dataUpdatedEvent is received for non-root xpath' - def future = objectUnderTest.processDataUpdatedEvent(anchor, 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.'() { + def '#scenario are changed with xpath #xpath and operation #operation'() { given: 'notification is enabled' spyNotificationProperties.isEnabled() >> true and: 'event factory creates event if operation is #operation' def cpsDataUpdatedEvent = new CpsDataUpdatedEvent() - mockCpsDataUpdatedEventFactory.createCpsDataUpdatedEvent(anchor, myObservedTimestamp, operation) >> + mockCpsDataUpdatedEventFactory.createCpsDataUpdatedEvent(anchor, myObservedTimestamp, expectedOperationInEvent) >> cpsDataUpdatedEvent - when: 'dataUpdatedEvent is received for root xpath' - def future = objectUnderTest.processDataUpdatedEvent(anchor, myObservedTimestamp, '/', operation) + when: 'dataUpdatedEvent is received for #xpath' + def future = objectUnderTest.processDataUpdatedEvent(anchor, myObservedTimestamp, xpath, operation) and: 'wait for async processing to complete' future.get(10, TimeUnit.SECONDS) then: 'async process completed successfully' @@ -126,10 +106,21 @@ class NotificationServiceSpec extends Specification { and: 'notification is sent' 1 * mockNotificationPublisher.sendNotification(cpsDataUpdatedEvent) where: - operation << [Operation.CREATE, Operation.UPDATE, Operation.DELETE] + scenario | xpath | operation || expectedOperationInEvent + 'Same event is sent when root nodes' | '' | Operation.CREATE || Operation.CREATE + 'Same event is sent when root nodes' | '' | Operation.UPDATE || Operation.UPDATE + 'Same event is sent when root nodes' | '' | Operation.DELETE || Operation.DELETE + 'Same event is sent when root nodes' | '/' | Operation.CREATE || Operation.CREATE + 'Same event is sent when root nodes' | '/' | Operation.UPDATE || Operation.UPDATE + 'Same event is sent when root nodes' | '/' | Operation.DELETE || Operation.DELETE + 'Same event is sent when container nodes' | '/parent' | Operation.CREATE || Operation.CREATE + 'Same event is sent when container nodes' | '/parent' | Operation.UPDATE || Operation.UPDATE + 'Same event is sent when container nodes' | '/parent' | Operation.DELETE || Operation.DELETE + 'UPDATE event is sent when non root nodes' | '/parent/child' | Operation.CREATE || Operation.UPDATE + 'UPDATE event is sent when non root nodes' | '/parent/child' | Operation.UPDATE || Operation.UPDATE + 'UPDATE event is sent when non root nodes' | '/parent/child' | Operation.DELETE || Operation.UPDATE } - def 'Error handling in notification service.'() { given: 'notification is enabled' spyNotificationProperties.isEnabled() >> true @@ -146,5 +137,4 @@ class NotificationServiceSpec extends Specification { notThrown Exception 1 * spyNotificationErrorHandler.onException(_, _, _, '/', Operation.CREATE) } - }