This is an Java 11 RESTful web service built with Spring Boot framework + H2 in file database using Gradle.
You should have Java 11 installed.
To build and run:
./gradlew bootRun
To test that it works, open a browser tab at http://localhost:8080.
Alternatively, you can run
curl -s http://localhost:8080
Build the jar package and run the JUnit test cases that cover both RESTFul APIs and DB access:
./gradlew build
| URI | Verb | HTTP response code | Description |
|---|---|---|---|
/accounts |
GET | Success: 200 Failed: 400 |
get details of all accounts |
Example:
curl -s http://localhost:8080/accounts
| URI | Verb | Request Body | HTTP response code | Description |
|---|---|---|---|---|
/transfer |
POST | {"srcAccId": <source account id>, "destAccId": <destination account id>, "amount": <amount to transfer>} |
Success: 200 Failed: 400 / 500 |
Transfer amount from source account to destination account |
Example:
curl -s -X POST -H "Content-type: application/json" -d '{"srcAccId" : "12345678", "destAccId" : "88888888", "amount" : 100}' "http://localhost:8080/transfer"
There are 2 different response codes according to source of the problem:
- 400 (Client side exception): When client sent an invalid request. This can be fixed by client.
- 500 (Server side exception): Server failed to fulfill a valid request due to an error with server, for example DB access problem.