Giter Site home page Giter Site logo

radwannizam / banking-service Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 34 KB

A simple service to demonstrate how to use Java Lock to make safe transfer between accounts with support for multi-threading

Java 100.00%
java lock multithreading rest-api dropwizard swagger

banking-service's Introduction

Banking Service

A simple service to demonstrate how to user Java Lock to make safe transfer between accounts with support for multi-threading.

NOTE

You can create multiple accounts using the same owner name; however, the generated account id is unique

Technology Stack

  • Java 1.8
  • dropwizard
  • guice: In this release, dependency injection is used in the test code only

Build & Run the project

  • mvn package
  • cd target
  • java -jar banking-1.0-SNAPSHOT.jar server /banking-service.yml

Swagger URL

http://localhost:8080/swagger

Test Scenario

####Create Account1: #####curl -X POST "http://localhost:8080/api/v1/account" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"ownerFirstName\": \"Radwan\", \"ownerLastName\": \"Nizam\", \"balance\": 100}"

Response:

' { "id": "1", "ownerFirstName": "Radwan", "ownerLastName": "Nizam", "balance": 100, "creationDate": 1570432944587 } '

####Create Account2: #####curl -X POST "http://localhost:8080/api/v1/account" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"ownerFirstName\": \"George\", \"ownerLastName\": \"Brown\", \"balance\": 100}"

Response:

' { "id": "2", "ownerFirstName": "George", "ownerLastName": "Brown", "balance": 100, "creationDate": 1570432945587 } '

####Transfer Money (success):

curl -X POST "http://localhost:8080/api/v1/account/actions/transfer/invoke" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"source\": \"1\", \"target\": \"2\", \"amount\": 100}"
Response:

code 202

####Transfer Money (failed):

curl -X POST "http://localhost:8080/api/v1/account/actions/transfer/invoke" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"source\": \"1\", \"target\": \"2\", \"amount\": 100}"
Response:

code 500 { "code": 5, "message": "insufficient funds" }

banking-service's People

Contributors

qadrawel avatar radwannizam avatar

Watchers

 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.