This application is a simple bank account implementation. An account able to withdraw money and transfer money to another account. The transfer can be with debit card or credit card. If a credit card is used, extra %1 transaction fee is charged. An account can linked with a credit card or bank account.
- It should be possible to transfer and withdraw money from an account. It is possible to pay
with either debit card or credit card. If a transfer/withdraw is done with a credit card, 1% of the amount is charged extra. Use design patterns where
applicable and write some test cases as well.
TransferControllerITandWithdrawControllerITis created to test the requirement. And alsofeeamounttotalAmountbeforeBalanceafterBalancefields are visible to see the amount changes by a transaction intransaction_history
- A negative balance is not possible
InsufficientBalanceExceptioncreated to manage negative or possible negative balances
- Account should contain at least some user details, card details and current balance
- All models are placed in
com.rabobank.bankaccountmanager.domainpackage
- All models are placed in
- One rest endpoint to see current available balance in all accounts
BankAccountController.getAllBalancesandBankAccountController.getBalance
- One rest endpoint to withdraw money
WithdrawController.withdraw
- One rest endpoint to transfer money
TransferController.transfer
- One credit card or debit card is linked with one account
- See the
@OneToOnerelation on database
- See the
- It should be able to audit transfers or withdrawals
updatedAtandcreatedAtfields placed in all tables. Alsotransaction_historytable is created to keep all changes.
- JDK1.8
- gradle
- docker
- docker-compose
- Spring Boot
- Spring Async
- Hibernate/JPA
- Postgresql
- Lombok
- Flyway
- Swagger
- Test Containers
- pojo-tester
find all endpoint details: api-docs after running application
The unit and integration test package is same. The name of the unit test classes ends with Test; The name of the integration test class ends with 'IT'.
93 test cases are created to test all cases.
Run the command to run all tests:
gradle test
- Line coverage:
%99(406/410) - Case coverage:
%100
pojo-tester is used to automate model/dto tests. All related tests under domain package.
testImplementation 'pl.pojo:pojo-tester:0.7.6'
testcontainers and postgresql docker is used in integration test. First of all, it is creating a docker container environment to execute integration tests. That's why, It waits at the beginning.
testImplementation 'org.testcontainers:testcontainers:1.11.4'
testImplementation 'org.testcontainers:postgresql:1.11.4'
All integration tests run with test spring profile. The profile inserts test data to database.
gradle clean build
to build:
docker-compose build
to run;
docker-compose up -d
to stop:
docker-compose down
