Backend-Tech-Challenge

Part 1

A dockerized 'Hello World' web service with the following input/output

curl http://localhost:8080/hello?name=$name must produce: {"Message": { "content": "hello $name"}} It uses the following technologies:

Technologies

  • Java
  • Maven for building to a war file
  • Jetty for webserver
  • Jersey for REST interface
  • It has a HelloWorldResource exposing the REST api and a HelloWorldService, that performs the logic.
  • Spring for injecting a singleton HelloService into the HelloResource
  • JAX RS / Jackson for serializing objects
  • Built as a docker image using a Dockerfile starting with FROM ubuntu:trusty, and run as a docker container.

Need to install(if not on linux)

  • Boot2docker

RUN Boot2docker and Add commands

  • boot2docker init
  • boot2docker start
  • eval "$(boot2docker shellinit)"
  • then on the project directory
  • mvn clean package (will take some time to create the docker image)
  • docker run -p 80:8080 tradeshift/codechallenge
  • After the jetty runs just go to http://(Insert the IP from the boot2docker logs--without port)/hello?name=taso

Part 2

  • The messages are stored now in a postgres database
  • The database is accessed using Spring JDBC
  • The project build runs JUnit tests using Mockito for mock objects
  • Test coverage must be measuerd using Jacoco, and if the line coverage falls below 60%, the build must fail.

RUN Boot2docker and Add commands

  • Run a postgres image:
  • docker run --name some-postgres -e POSTGRES_PASSWORD=password -e POSTGRES_USER=messagesdb -d postgres
  • Link the webservice image with the postgres
  • docker run -p 80:8080 --link some-postgres:db tradeshift/codechallenge
  • Add a name to DB:
  • curl -X POST http://{Insert the IP from the boot2docker logs--without port}/messages/names/$name
  • Get 10 recent results from DB
  • curl -X GET http://{Insert the IP from the boot2docker logs--without port}/messages/recent