Skip to content

adrianliz/banking-kata-java

 
 

Repository files navigation

Banking Kata - Java

CI

Purpose

This demo was created for the purposes of meetup series on TDD & Clean Architecture. See the YouTube Meetups. Please note that this project is purely for demo purposes only.

Overview

This project illustrates TDD & Clean Architecture implementation in Java, showing the Use Case Driven Development Approach.

We implement a Banking system with the following use cases:

  • Open account
  • Withdraw funds
  • Deposit funds
  • View account

Prerequisites

  • OpenJDK 17
  • Docker

Note: If you also want to run without Docker, you can install:

Environment variables

To be able to run the tests (since some of the tests are dependent on the database - the integration tests), we then need to set the environment variables.

Note: Soon we plan to also separate the tests so that they can be run separately.

In IntelliJ, for the Tests in 'banking-kata.test' configuration, you can copy this into the Environment variables

POSTGRES_URL=jdbc:postgresql://localhost:5432/banking_kata;
POSTGRES_USER=postgres;
POSTGRES_PASSWORD=admin;
MONGO_INITDB_ROOT_USERNAME=rootuser;
MONGO_INITDB_ROOT_PASSWORD=rootpass;
ME_CONFIG_MONGODB_ADMINUSERNAME=rootuser;
ME_CONFIG_MONGODB_ADMINPASSWORD=rootpass;
ME_CONFIG_MONGODB_SERVER=mongodb;
KEYCLOAK_REALM_URL=http://localhost:10000/auth/realms/banking-kata;
KEYCLOAK_TEST_CLIENT_ID=test-client;
KEYCLOAK_TEST_CLIENT_SECRET=XXXX

You need to have created the database, in the example I had created a database called banking_kata.

Keycloak settings:

  • You need to have created a keycloak realm with client_credentials flow enabled.
  • In the example I had created a realm called banking-kata with a client_id test-client.

Please update the environment variable values based on your local settings.

Running build

Environment Variables

$env:POSTGRES_URL='jdbc:postgresql://localhost:5432/banking_kata'
$env:POSTGRES_USER='postgres'
$env:POSTGRES_PASSWORD='admin'
$env:MONGO_INITDB_ROOT_USERNAME='rootuser'
$env:MONGO_INITDB_ROOT_PASSWORD='rootpass'
$env:ME_CONFIG_MONGODB_ADMINUSERNAME='rootuser'
$env:ME_CONFIG_MONGODB_ADMINPASSWORD='rootpass'
$env:ME_CONFIG_MONGODB_SERVER='mongodb'
$env:KEYCLOAK_REALM_URL='http://localhost:10000/auth/realms/banking-kata'
$env:KEYCLOAK_TEST_CLIENT_ID='test-client'
$env:KEYCLOAK_TEST_CLIENT_SECRET='XXXX'

Running build with automated tests:

./gradlew build
./gradlew integrationTest

Running JaCoCo code coverage:

./gradlew jacocoTestReport

Running PIT mutation testing:

./gradlew pitest

Reports

See the build\reports directory for the generated reports for test results, code coverage and mutation testing.

Reports:

  • build\reports\tests
  • build\reports\jacoco
  • build\reports\pitest

Contributing

If you'd like to contribute, see instructions here https://github.com/valentinacupac/banking-kata-java/blob/main/CONTRIBUTING.md

About

Banking Kata (Java)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 97.9%
  • Groovy 1.3%
  • Other 0.8%