This implementation uses Dropwizard as the main dependency to develop a RESTful web service. Dropwizard itself already contains lots of useful dependencies like Jersey to deal with the HTTP protocol, Jetty as a servlet engine, Jackson to deal with JSON object and Logback as the logging framework. For the dependency injection I've used Dagger. For testing purposes Junit, Mockito and Hamcrest have been used.
This application contains some "Hello world" end points as a minimum working example using Dropwizard, it also contains the actual useful endpoints that deal with the Quandl API.
$ gradle --refresh-dependencies
$ gradle idea
$ gradle clean jar
$ gradle clean test
To be sure all the test (both unit tests and integration tests) won't fail they need to be run from the command line using gradle
.
Some of the tests will fail if executed inside an IDE (e.g. IntelliJ IDEA), the reason is that there is some code missing
because of the Dagger dependency injection framework that needs to generate the source code according to the annotations found in the code.
$ java -jar build/libs/java-implementation-1.0.jar server src/main/resources/apiConfigurations.yml
The YAML configuration file is currently inside the resources
folder as per Maven requirements, but that's not mandatory.
In fact it is currently used only at runtime with the java -jar
command.
Inside the docker container this is the command:
java -jar build/libs/app-1.0.jar server src/main/resources/apiConfigurations.yml
The reason why the JAR name is different is because of the folder where the source code is contained in (this is because of how Dropwizard works by default).
http://localhost:8080/ticker?tickerCode=AAPL
http://localhost:8080/ticker/AAPL
http://localhost:8081/
$ docker build -t java_i .
$ docker stop java_c ; docker rm java_c
$ docker run -d -p 8083:8080 -p 8084:8081 --name java_c -i -t java_i ; docker logs -f java_c
$ docker exec -it java_c bash