Skip to content

Instantly share code, notes, and snippets.

@robfletcher
Created November 7, 2014 09:20
Show Gist options
  • Save robfletcher/c5e73e43fb7f24d4f634 to your computer and use it in GitHub Desktop.
Save robfletcher/c5e73e43fb7f24d4f634 to your computer and use it in GitHub Desktop.
def "subscriber receives message"() {
given: "An async event bus"
def eventBus = new AsyncEventBus(Executors.newCachedThreadPool())
and: "A Fake Service"
def vars = new BlockingVariables()
def fakeService = Stub(FictionalService) {
process(_) >> { PersonMessage message -> vars.message = message }
}
and: "A Subscriber"
def subscriber = new PersonSubscriber(eventBus, fakeService)
and: "A Person Message"
def personMessage = new PersonMessage(new Person(), PersonMessage.ACTION.CREATE)
when: "A message is published"
eventBus.post(personMessage)
then: "Our publisher delegates the message to our service"
vars.message == personMessage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment