Employee Management System Web Layer

Learn via video courses
Topics Covered

Overview

The web/presentation tier is the user interface and communication layer of the application, where the end-user interacts with the application using the HTTP protocol. Its main purpose is to display and collect information from the user. Web presentation tiers are usually developed using HTML, CSS, and JavaScript on the front end and a set of controllers on the back end.

Create Controllers

Creating a controller layer is simple using spring boot. We can directly focus on the action if we know the right annotation. We need two controllers.

  1. An employee controller - Contains mapping allowed for employee
  2. An admin controller - Contains mapping allowed for admin.

EmployeeController

Let's write EmployeeController first.

EmployeeControllerTest

AdminController

Admin can perform the additional task of creating, deleting, and searching employees.

AdminControllerTest

Testing Using Postman

We will now run the application and verify the endpoints. Currently, we don't have any employees in our database.

We will operate in the order of Create, Read, Update, Search and delete.

Create New Employee

Create New Employee

An employee is created with employee id EMP-10000497.

Get an Employee

Get an Employee

Update an Employee

Update an Employee

The employee is updated with the new email address.

Search Employee

Search employees with a first name starting with "To". Search Employee

Delete an Employee

Should delete record in DB. Delete an Employee

The source code is available in the GitHub repository and postman collection under tag number version_6.0.0.

Conclusion

In this article, we covered

  • Building a web layer for the employee management system.
  • Unit testing web layer by mocking the service layer fully.
  • Verified all our endpoints using postman.