This is a simple REST API, built using Java Spring
- JDK 8 - Java Development Kit
- STS - Spring Tool Suite (Eclipse IDE)
- Docker CE - Docker Community Edition
Launch STS and open the code folder. There will be errors, please follow the following steps to prepare the IDE:
- Run
docker-compose up -d es-candidate-test
from the repository to get the elastic container up and running. - Within STS go to
Help > Eclipse Marketplace
and find and install "Buildship Gradle Integration 2.0" - Right-click the root in the project explorer and select
Configure > Add Gradle Nature
- Once complete, right-click the root project again and select
Gradle > Refresh Gradle Project
Once the development environment is prepared the application can be launched from STS:
- Right-click the root folder and select 'Run As > Spring Boot Application'.
- The console will open and show a few lines of build report and finally a line similar to the following show that the application is ready to test on
localhost:8080
:
2018-02-15 13:58:32.543 INFO 13556 --- [ main] candidatetest.main.Application : Started Application in 5.659 seconds (JVM running for 6.509)
The application will prepare all required indices in ElasticSearch and populate an administrator user which you may use to interact with the API initially. The credentials for this user are:
User: administrator
Pass: @dministr8or
This user should be used to call a special end point for building development POST /api/development
data. This can be done with the following cURL command (or equivilant):
curl -X POST \
http://localhost:8080/api/development/ \
-H 'accept: application/json' \
-H 'authorization: Basic YWRtaW5pc3RyYXRvcjpAZG1pbmlzdHI4b3I='
This will populate the Users mapping with 3 additional users. You can access the details for any of these users with their user ids ("jbloggs", "aother", "jdoe"). E.g:
curl -X GET \
http://localhost:8080/api/user/jbloggs \
-H 'Accept: application/json' \
-H 'Authorization: Basic YWRtaW5pc3RyYXRvcjpAZG1pbmlzdHI4b3I='