- There is and should have only one CEO on the top level. If there is no CEO, the service will return an error with status code of 500.
- The manager ID with the CEO is set to 0
- A invalid employee has an employee ID of less than 0
src/main/java/: Serves as the java back-end src/main/resources/static/: Serves as the Angular 2+ front-end (This is a build version. To view the front-end source code: https://github.com/yliu138/employee-hierarchy-coding-challenge-client)
- Spring boot
- Web
- H2 (In-memory DB) in production, H2 is designed for testing only but in this example, for demonstration, this is used for the runtime database as well.
- JPA
- JUnit, Mockito, Jacoco
- Maven
- Angular 4
- Protractor, Jasmine, Karma
- Webpack
- Install maven
- Use this code to start the back end
mvn spring-boot:run -q
- Make sure maven is in the environment path.
- Import this project into Eclipse
- In the quick access, normally on the top right corner, type in run Spring Boot app.
- You will be able to run the application
After server is running, you can view the employee hierarchy visually by accessing the root path: http://localhost:8080(or other ports)
- tools: Jacoc and Sonar
-
Eclipse (Recommended): JUnit test
-
Terminal
mvn clean test
There are some pre-populated data in data.sql under the folder resources/. Please feel free to add more tests or modified the tests manually as well by accessing the h2 console: http://localhost:8080/h2-console.
Remember to put jdbc:h2:mem:testdb
in the JDBC URL field, and hit "Connect" directly
Add more data running e.g.,
insert into employee(employeeId, name, managerId)
values(600, 'Andy', 190);
- IoC: mainly depedency injection
- Factory
- Singleton