Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.
/ stockdemo Public archive

A simple REST service for managing stock items. Test driven Akka HTTP show case

Notifications You must be signed in to change notification settings

atooni/stockdemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

A simple stock demo

This is a project created within a couple of hours to demonstrate how a simple REST based service can be implemented that manages an imaginary stock of articles.

The outline of the service was specified as follows:

The task is to develop a stock management as a Rest-Microservice in Scala. A stock management maintains the current
stock amount for a product. The stock can be increased (refill) or decreased (client buys a product). The stock
should be maintained on a per-product basis. If you are quick you can also implement a "reserve product" mechanism,
that blocks a product in the stock until the client actually buys it (similar to the seat reservation system for
flight tickets). However this is optional.

The project should be checked into a public code repository of your choice like Github, Bitbucket or Gitlab.
It must contain tests and run out of the box, i.e. it should not require manual installation of other components.
Use a build system of your choice (e.g. Maven, SBT, Gradle).

Technical Details

  • The build system used for the example is SBT 1.1.1

  • The technical stack for the REST service is Akka HTTP for the REST interface and an Actor bases in memory backend for the Stock Manager

  • The specification above has been transformed into a specification based on ScalaTest, first for the backend and then the same test cases for the REST interface.

  • Reservations can be made for available quantities of products for a given amount of time. After that time the reservation can’t be fulfilled any longer.

  • A fulfilled reservation is deducted from the stock without modification of the quantity.

Running and Building

  1. A local installation of SBT is required to execute the project.

  2. Simply checkout the project from github

  3. Switch to the checkout directory and

    1. run sbt test to execute the tests.

    2. run sbt run to execute the server mainline.

Note

The server will start to listen on port 9999 by default. This port can be configured by changing the file src/main/resources/application.conf without modifying the code.

Limitations

  • Exerything runs in memory without any preservation of state across server restarts.

  • The documentation should be improved to document the complete REST interface with JSON document examples. So far, the JSON is created implicitly in the test case for the REST service using the JSON marshalling support.

  • The project is missing a UI, a standard UI for testing REST services can be used, for example Postman


Have fun

Andreas

About

A simple REST service for managing stock items. Test driven Akka HTTP show case

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages