GithubHelp home page GithubHelp logo

jullierme / revolut-test Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 4.0 216 KB

Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts. The Spring Framework here is not allowed.

Java 100.00%
java gradle jetty jersey h2 flyway beanutils travisci junit5 mockito

revolut-test's Introduction

Build Status Coverage Status

Revolut test

Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts.

Explicit requirements:

  1. You can use Java, Scala or Kotlin.
  2. Keep it simple and to the point (e.g. no need to implement any authentication).
  3. Assume the API is invoked by multiple systems and services on behalf of end users.
  4. You can use frameworks/libraries if you like (except Spring), but don't forget about
    requirement #2 โ€“ keep it simple and avoid heavy frameworks.
  5. The datastore should run in-memory for the sake of this test.
  6. The final result should be executable as a standalone program (should not require
    a pre-installed container/server).
  7. Demonstrate with tests that the API works as expected.

Implicit requirements:

  1. The code produced by you is expected to be of high quality.
  2. There are no detailed requirements, use common sense.

Information

Libraries

Web container to serve the app

  • Jetty

REST API (JAX-RS)

  • Jersey

In-memory database

  • H2

Database migration

  • Flyway

Load application properties file

  • Commons Configuration2
  • Commons BeanUtils

Unit test

  • JUnit 5
  • Mockito

Hosted continuous integration service

  • Travis CI

Hosted code coverage

  • Coveralls

Local code coverage

  • JaCoCo

RestFul integration test

  • REST Assured

JDBC Connection Pool (Allow get async connections)

  • Tomcat JDBC

Instructions

Test

$ gradlew test

Build

$ gradlew build

Run

$ java -jar revolut-1.0-SNAPSHOT-all.jar

Server

The Application starts a jetty server on localhost port 8080 with two sample accounts

Response:
{
    "id": 18181818,
    "name": "Jullierme Barros",
    "balance": 1000000.00
} 
Response:
{
    "id": 17171717,
    "name": "Manoela Barros",
    "balance": 1000000.00
} 

Available Services

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

Http Status

  • 200 OK
  • 400 Bad Request
  • 404 Not Found
  • 500 Internal Server Error

Sample JSON for Account and Transaction

Account:

Request:
{  
   "name":"Jullierme",
   "balance":100
} 
Response:
Header:
"Location":"http://localhost:8080/api/account/18181819"

Transaction:

Request:
{  
   "fromAccountId":18181818,
   "toAccountId":17171717
   "amount":10,
}
Response:
{
    "id": 1,
    "fromAccountId": 18181818,
    "toAccountId": 17171717,
    "amount": 10.00
}

More information

  • 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

revolut-test's People

Contributors

jullierme avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.