Revolut Transfer Money challenge code
Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts.
- Java 8
- Maven
- Intellij IDEA
- mvn clean compile install
- java -jar target/revolut-transfer-money-1.0.jar
after run jar file you can see this message: "Embedded Server start successfully" then 3 rest endpoint is available for call
- notice: if after run you get a message for access network please accept it. because tests uses java.net classes for open connections.
- /api/account/create (POST): provide Account entity as json for request body like: { "accountNumber" : 200, "ownerName" : "Fazel farnia", "balance" : 3000 }
- /api/account/loadall (GET): without body, response include array of accounts as json
- /api/transaction/transferMoney (POST): provide Transaction entity as json in request body like: { "fromAccountNumber":100, "toAccountNumber":200, "amount":3 }
notice: at first create two Account by first endpoint and then call transfer money, then for see the result of previous rest call you can call second endpoint and find modified balances of accounts.
- repository: for testing store and retrieve accounts from hashMap as a in memory repository
- service: for testing methods of service implementation, also provide concurrent test for thread safety
- rest: for testing rest endpoints, send and response would be json
As document mentioned i obey the rule of simplicity so i did not used heavy frameworks and complex libraries such as H2 in memory database and Jersey Restful webservice and other application servers. so this application is implemented by pure java libs and just a simple and well known Jackson jar for mapping entities to json and junit for test cases.