Institute of Computer Science
  1. Courses
  2. 2023/24 spring
  3. Enterprise System Integration (MTAT.03.229)
ET
Log in

Enterprise System Integration 2023/24 spring

  • Home
  • Lectures
  • Practicals
  • Assignements
  • Project and exam
  • Message Board

Session 3.1: Spring Boot – REST - CRUD - II

Clone the following repository

$ git clone https://github.com/M-Gharib/ESI-W3-CRUD2.git

Note: if you want to create a new Spring Boot project from scratch, you need to install the following dependency:

  • Spring Web;
  • Spring Data JPA SQL;
  • PostgresSQL Driver SQL;
  • lombok;
  • springdoc.

Your teacher will describe the new structure and code to you.

The application should be working just fine. However, only the code related to the Product entity has been refactored following the best practices.

Test the application by sending some of the requests in RestClientFile.rest. Try to add some orders to products, fetch these orders, modify and delete some of them. Note: modify the request to add an order to a product that already exists in your database.

Testing with @WebMvcTest

ProductControllerTests.java contains several test cases concerning the ProductController, which can be found in

src
└── main
└── test/~/esi-w3-crud2
                 └── ProductControllerTests.java

Your teacher will describe most of these tests work, and based on what you'll learn, you have to write a test case for the PUT product controller.

Do it yourself: try to write some test cases for the OrderController relying on what you learned.

Do it yourself: As mentioned earlier, only the code related to the Product entity has been refactored. Try to refactor the code related to the Order entity following the same style (e.g., structure the code classes, use dtos, refactor the order controller and service classes).

While refactoring the code, it is advised

  • to refactor the services that your API provides one by one, i.e., refactor the GET all request, then, GET by ID, etc.
  • to start refactoring the related function in the @service, then, refactor the related method handler code in the @RestConttroller.
  • to keep a working copy of any code snippet you are refactoring so you can refer to it if something went wrong, i.e., just keep a commented-out version of the code snippet. Then, delete it when everything is working as expected.
  • to test your modifications when required by sending the related request in RestClientFile.rest
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment