- Create few sample bank accounts on startup
- Allow the user to add more bank accounts through a POST API
- Retrieve an account through a GET API
- Retrieve all accounts through a GET API
- Transfer funds between 2 accounts
- Handles synchronization in a multi-threaded scenario, ensuring data integrity
- Environment:
OpenJDK 8
- Build:
mvn clean install
- Run:
java -jar target/moneytransfer-1.0-SNAPSHOT.jar
- Numerous extensive test cases cover this service
- Unit Tests
- Functional Tests
- Integration Tests
- Multi-Threaded Integration Tests, several parallel threads started in TransferAndGetIntegrationParallelTest.java
- Endpoint: /bankAccount/add
- Returns HTTP 200 OK on successful request without body
- Sample Request Body:
{ "id": 10, "balance": 1 }
- Errors:
- HTTP 404 with "Incomplete transfer parameters" in Response body
- HTTP 412 with "Illegal add account parameters" in Response body
- HTTP 412 with "Account already present" in Response body
- Endpoint: /bankAccount/{id}
- Returns HTTP 200 OK on successful request with body
- Sample Response Body:
{ "id": 2, "balance": 50.00 }
- Errors:
- HTTP 404 with "Illegal get account parameters" in Response body
- HTTP 412 with "Account not found" in Response body
- Endpoint: /bankAccount/all
- Returns HTTP 200 OK on successful request with body
- Sample Response Body:
{ "allBankAccounts": [ { "id": 1, "balance": 100.00 }, { "id": 2, "balance": 50.00 }, { "id": 3, "balance": 20.52 }, { "id": 4, "balance": 30.61 } ] }
- Endpoint: /transferMoney
- Returns HTTP 200 OK on successful request with body
- Sample Request Body:
{ "from": 1, "to": 2, "amount": 10 }
- Sample Response Body:
{ "updatedAccounts": { "from": { "id": 1, "balance": 90.00 }, "to": { "id": 2, "balance": 60.00 } } }
- Errors:
- HTTP 404 with "Incomplete transfer parameters" in Response body
- HTTP 412 with "Can't transfer funds to self" in Response body
- HTTP 412 with "Only positive amount transfer allowed" in Response body
- HTTP 412 with "Account not found" in Response body
- HTTP 412 with "Account balance insufficient for this transfer" in Response body
- Jetty server 9
- Jersey 2
- Jackson 2
- Junit 4
- Vmlens Concurrent JUnit
- Jersey Test Framework Provider Jetty
- lombok