Hierarchy is a Spring boot application that provides a REST API JSON endpoint that transforms an {<employee_name>: <supervisor_name>} payload in a hierarchical response.
All gradle commands in this repository can be ran using the gradle wrapper present in this repository. Eg:
Windows:
gradle.bat clean
bash:
./gradlew clean
To run the .jar file that comes packed with this repository, run the following command:
java -jar build/libs/hierarchy-0.0.1-SNAPSHOT.jar.
./gradlew bootJar
./gradlew bootRun
The repository layer integration tests will be ran against the H2 database
./gradlew test
After running the application the REST API will then be available at: http://localhost:8080/.
An H2 database in file mode will be created under ~/data/hierarchy . The database will get initialized with the scripts in: src/main/resources/data.sql. These scripts will add a new user that can be used to access the endpoints using Basic Auth. Since the password is encoded in the data.sql here is the username/password needed to access the API:
username: personia
password: password
The application has 2 endpoints:
To test the running app, you can run the following requests:
curl -u personia:password -i -XPOST -H "Content-type: application/json" -d '{
"Pete": "Nick",
"Barbara": "Nick",
"Nick": "Sophie",
"Sophie": "Jonas"
}' 'http://localhost:8080/employee/hierarchy'
curl -u personia:password -i -XGET -H "Content-type: application/json" 'http://localhost:8080/employee?name=Nick'
For further reference, please consider the following sections: