Quarkus – Simple REST API and Unit Tests with JUnit 5, Java and Quarkus Framework with JUnit 5.
Enhance your knowledge of the Java Ecosystem – Discover the Quarku Framework Features
A quick and objective course, straight to the point!
In this course you will learn in an objective and practical way how to create a simple REST API that uses GET and POST methods and you will also learn how to create Unit Tests for your Controller and Service layer classes.
Let’s use as an example the creation of a Company Entity with some sample data, for this we will make use of JPA/Hibernate annotations that are inserted in the context of the Quarkus Framework.
In the following steps, we will separate the REST API into controller and service layers, respecting the MVC model (Model View Controller) and finally, we will use Postman to make requests to this REST API.
Then, we move on to the unit testing phase using the updated version of JUnit, the most widely used Testing Framework in the Java world.
In this phase we will create unit tests that validate the paths of our endpoints and the responses received.
Finally, let’s create unit tests for our Service layer. Here we test data processing and business rules and also create a test that simulates data persistence in the database.
Topics:
- Understanding the importance of Unit Testing;
- Creating a simple REST API with Java + Quarkus Framework;
- Testing the API with Postman;
- Creating unit tests for REST API endpoints;
- Creating unit tests for Service classes;
- Creating tests that validate data in the database.