Sample app for money transfers between accounts
Sample app for money transfers between accounts. It supports account creation with initial balance and issuing money transfers between accounts.
It is build using Javalin with Guice and Kotlin. Hibernate with H2 in-memory database.
Tested with JUnit5 and REST-assured
It includes examples for both DB locking and Thread locking.
Server starts on: http://localhost:7000
To start the server:
./mvnw compile exec:java
Or build jar and run it:
./mvnw package && java -jar target/transfer-money-1.0-SNAPSHOT-jar-with-dependencies.jar
GET /api/accounts
200
json
[
{
"accountId": 1,
"balance": 200.00
},
{
"accountId": 2,
"balance": 100.00
}
]
GET /api/accounts/:id
200
json
{
"accountId": 1,
"balance": 200.00
}
POST /api/accounts
json
{
"balance": 200.00
}
201
json
{
"accountId": 1,
"balance": 200.00
}
GET /api/transfers
200
json
[
{
"transferId": 1,
"sourceAccountId": 1,
"destinationAccountId": 2,
"amount": 50.00,
"createdAt": "2019-09-30T20:57:02.15",
"status": "SUCCESS"
},
{
"transferId": 2,
"sourceAccountId": 1,
"destinationAccountId": 2,
"amount": 50.00,
"createdAt": "2019-09-30T20:57:03.102",
"status": "FAILED"
},
{
"transferId": 3,
"sourceAccountId": 1,
"destinationAccountId": 2,
"amount": 50.00,
"createdAt": "2019-09-30T20:57:05.397",
"status": "REQUESTED"
}
]
POST /api/transfers
json
{
"sourceAccountId": 1,
"destinationAccountId": 2,
"amount": 50.0
}
201
json
{
"transferId": 1,
"sourceAccountId": 1,
"destinationAccountId": 2,
"amount": 50.00,
"createdAt": "2019-09-30T20:57:02.15",
"status": "SUCCESS"
}