/payments-api

Payments REST API

Primary LanguageJavaMIT LicenseMIT

Build Status Quality Gate Coverage Status

Payments REST API

This repo is integrated with TravisCI, with a CD pipeline which executes the isolated and end to end tests, deploying in the end to Heroku and publishing several metrics to SonarCloud and Coveralls:

Features description

This is RESTful Payments API, where it is possible to:

  • Fetch a payment resource.
  • Create, update and delete a payment resource
  • List a collection of payment resources
  • Persist resource state (currently only in memory)

More info about closed and open issues: https://github.com/islomar/payments-api/projects/1

Prerequisites tu run anything locally

  • You need Java 8 and Maven >= 3.5 installed.

How to run the REST API server locally

  1. In order to start it up, you have two options:
    • mvn spring-boot:run, or
    • mvn clean package && java -jar target/payments-api-1.0.0.jar
  2. To check that it is up and running, you have two options:
    • From a web browser, access http://localhost:9000
    • From a terminal, run curl localhost:9000
    • In either case, you should see a "The server is up and running!" message

Testing

You can see the resulting tests executed in TravisCI: https://travis-ci.org/islomar/payments-api

How to run the automated tests locally

  • Isolated tests: run mvn clean test
  • Sociable tests: run mvn clean test -PintegrationTests (domain boundary tests)
  • End to end tests runmvn clean test -Pend2end (real Spring Boot tests)
  • All tests: run mvn clean test -PallTests (all the above :-) )

Manually test

Mutation testing

  • Mutation testing is a good way to check how good your tests are.
  • Run mvn clean test -DwithHistory org.pitest:pitest-maven:mutationCoverage (example for isolated tests)
  • You can see locally the HTML reports created under /target/pit-reports/

Production environment

REST API documentation

Logging, Alerts and Monitoring

  • Papertrail addon of Heroku to read, search and monitor logs (private unfortunately).
    • Currently, an alert is configured to send to islomar@gmail.com an email in case an ERROR happens.
  • Postman monitor (private): https://is.gd/2L0TMw
    • Not reliable, the requests used should be changed

Basic Monitoring Services

Maven checks

  • Find available plugin updates: mvn versions:display-plugin-updates
  • Find available dependency updates: mvn versions:display-dependency-updates
  • Generate several reports under target/site running mvn site
    • It generates pitest reports (mutation testing)
    • Identify dependencies with known vulnerabilities

New things tried:

  • Cucumber (from scratch)
  • Papertrail logging and basic alerts
  • Micrometer monitoring
  • Lombok
  • ModelMapper
  • draw.io