Code Monkey home page Code Monkey logo

specmatic-order-bff-jms's Introduction

Specmatic Sample: SpringBoot BFF calling Domain API and JMS

This sample project demonstrates how we can practice contract-driven development and contract testing in a SpringBoot (Kotlin) application that depends on an external domain service and JMS.
Here, Specmatic is used to stub calls to domain API service based on its OpenAPI spec and mock JMS based on its AsyncAPI spec.
Please contact us at https://specmatic.io if you wish to try it out.

Here is the domain api contract/open api spec

Here is the AsyncAPI spec of JMS that defines queues and message schema.

Definitions

  • BFF: Backend for Front End
  • Domain API: API managing the domain model
  • Specmatic Stub/Mock Server: Create a server that can act as a real service using its OpenAPI or AsyncAPI spec

Background

A typical web application might look like this. We can use Specmatic to practice contract-driven development and test all the components mentioned below. In this sample project, we look at how to do this for nodejs BFF which is dependent on Domain API Service and JMS demonstrating both OpenAPI and AsyncAPI support in specmatic.

HTML client talks to client API which talks to backend API

Tech

  1. Spring boot
  2. Specmatic
  3. Specmatic Beta extension (for mocking JMS)
  4. Karate

Start BFF Server

This will start the springboot BFF server

./gradlew bootRun

Access find orders api at http://localhost:8080/findAvailableProducts Note: Unless domain api service is running on port 9000, above requests will fail. Move to next section for solution!

Start BFF Server with Domain API Stub

  1. Download Specmatic Jar from github

  2. Start domain api stub server

java -jar specmatic.jar stub

Access find orders api again at http://localhost:8080/findAvailableProducts with result like

[{"id":698,"name":"NUBYR","type":"book","inventory":278}]

Run Tests

This will start the specmatic stub server for domain api using the information in specmatic.json and run the karate tests that expects the domain api at port 9000.

./gradlew test

specmatic-order-bff-jms's People

Contributors

jaydeepk avatar yogeshnikam671 avatar harikrishnan83 avatar starkhan6368 avatar

Watchers

Saurabh Nanda avatar  avatar Anand Bagmar avatar Julian Harty avatar  avatar Shama Ugale avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.