Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts.
- You can use Java, Scala or Kotlin.
- Keep it simple and to the point (e.g. no need to implement any authentication).
- Assume the API is invoked by multiple systems and services on behalf of end users.
- You can use frameworks/libraries if you like (except Spring), but don't forget about
requirement #2 – keep it simple and avoid heavy frameworks. - The datastore should run in-memory for the sake of this test.
- The final result should be executable as a standalone program (should not require
a pre-installed container/server). - Demonstrate with tests that the API works as expected.
- The code produced by you is expected to be of high quality.
- There are no detailed requirements, use common sense.
- Jetty
- Jersey
- H2
- Flyway
- Commons Configuration2
- Commons BeanUtils
- JUnit 5
- Mockito
- Travis CI
- Coveralls
- JaCoCo
- REST Assured
- Tomcat JDBC
$ gradlew test
$ gradlew build
$ java -jar revolut-1.0-SNAPSHOT-all.jar
The Application starts a jetty server on localhost port 8080 with two sample accounts
{
"id": 18181818,
"name": "Jullierme Barros",
"balance": 1000000.00
}
{
"id": 17171717,
"name": "Manoela Barros",
"balance": 1000000.00
}
HTTP METHOD | PATH | USAGE |
---|---|---|
POST | /api/account | create a new account |
GET | /api/account/{accountId} | get account by accountId |
POST | /api/transaction | perform transaction between 2 accounts |
GET | /api/transaction/{transactionId} | get transaction by id |
- 200 OK
- 400 Bad Request
- 404 Not Found
- 500 Internal Server Error
{
"name":"Jullierme",
"balance":100
}
Header:
"Location":"http://localhost:8080/api/account/18181819"
{
"fromAccountId":18181818,
"toAccountId":17171717
"amount":10,
}
{
"id": 1,
"fromAccountId": 18181818,
"toAccountId": 17171717,
"amount": 10.00
}
- To ensure that an account does not transfer amounts without balance, the transfer method uses database transaction control.
- To check asynchronous tests, please see the classes * StressTest.java