Testing Your Message-Driven Application With Sp...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Testing Your Message-Driven Application With Spring

Jakub Pilimon

May 21, 2018

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

16 slides
  1. 1 © 2018 Pivotal Testing your Message-Driven Application with Spring

    Jakub Pilimon, @JakubPilimon https://github.com/spring-cloud-samples/messaging-application
  2. 2 Spring Developer Advocate @Pivotal Trainer @Bottega Interested in •

    Domain-Driven Design • Architecture • Test-Driven Development About me Twitter: @JakubPilimon Blog: http://pillopl.github.io #dddbyexamples
  3. 3

  4. 5 Why Messaging? CREDIT CARD APPLICATION CONTROLLER APPLY FOR CARD

    SERVICE CREDIT CARD DOMAIN EVENT PUBLISHER CREDIT CARD REPOSITORY CONSUMER (MAIL, REPORT, ETC)
  5. 6

  6. 7

  7. 8 Why Messaging? CREDIT CARD APPLICATION CONTROLLER APPLY FOR CARD

    SERVICE CREDIT CARD DOMAIN EVENT PUBLISHER CREDIT CARD REPOSITORY CONSUMER (MAIL, REPORT, ETC) def 'should emit CardGranted when client born in 70s or later'() { when: applyForCardService.apply("89121514667") then: 1 * domainEventsPublisher.publish( { it instanceof CardGranted } ) }
  8. 9 Why Messaging? CREDIT CARD APPLICATION CONTROLLER APPLY FOR CARD

    SERVICE CREDIT CARD DOMAIN EVENT PUBLISHER CREDIT CARD REPOSITORY CONSUMER (MAIL, REPORT, ETC) @Test public void shouldEmitCardGrantedEvent() { // when cardApplicationController.applyForCard(new CardApplication("70345678")); // then verify(domainEventsPublisher).publish(isA(CardGranted.class)); }
  9. 10 Why Messaging? CREDIT CARD APPLICATION CONTROLLER APPLY FOR CARD

    SERVICE CREDIT CARD DOMAIN EVENT PUBLISHER CREDIT CARD REPOSITORY CONSUMER (MAIL, REPORT, ETC) def 'should be able to get card when born in 70s or later'() { when: cardApplicationController.applyForCard(new CardApplication("70345678")) then: events.poll().getPayload().contains("card-granted") }
  10. 11

  11. 12 Why Messaging? CREDIT CARD APPLICATION CONTROLLER APPLY FOR CARD

    SERVICE CREDIT CARD DOMAIN EVENT PUBLISHER CREDIT CARD REPOSITORY CONSUMER (MAIL, REPORT, ETC) label: card_rejected input: triggeredBy: sendRejected() outputMessage: sentTo: channel headers: type: card-application-rejected contentType: application/json body: clientPesel: 86010156812 timestamp: 2018-01-01T12:12:12.000Z matchers: body: - path: $.timestamp type: by_regex predefined: iso_8601_with_offset
  12. 13

More Decks by Jakub Pilimon

Other Decks in Programming