You can find the following examples:
- How to mock DB for tests. There is configured MySQL DB for main project and in memory H2 DB for tests.
- How to send POST request to you controller and validate the response
- How to send GET request, receive the response object and validate the response
- How to test custom repository method. See
UserRepositoryTest
class
- Replace your MySQL connection properties in the
src/main/resources/application.properties
- Run project
- Run all tests from `src/test/java
- PLease note we are not using service layer in this example. This example is required to show of how to test the controller layer.
- Please note we are performing the
business logic
in the controller. Don't do it in your test tasks or in real projects.