From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Test Spring data repositories
From the course: Complete Guide To Java Testing with JUnit 5 & Mockito
Test Spring data repositories
- [Instructor] When developing an application, it's likely you'll need to save data in a database. Spring repositories provide an abstraction layer over data access. They simplify data access operations and reduce boilerplate code needed for performing common tasks such as create, read, update, and delete. Let's take a look at an example. This is a RESTful web service that handles users. There's a user controller with two endpoints, one for post where you can create a user, and the other is a get where you can retrieve a user. Both of these leverage the userService. Let's take a look. This class acts as a passthrough to the userRepository. The userRepository extends the Jpa interface provided by Spring Data JPA. This allows it to inherit several methods for working with user persistence, including methods for saving, deleting, and finding user entities. That's why in the Service class, we're able to use the find by id and save methods. Spring Data JPA is added to our application as a…
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Walk through a basic Spring Boot application3m 53s
-
(Locked)
Write your first Spring Boot test3m 43s
-
(Locked)
Test Spring data repositories6m 1s
-
(Locked)
Test Spring services4m 9s
-
(Locked)
Test Spring controllers5m 58s
-
(Locked)
Integration testing with Spring Boot10m 40s
-
(Locked)
Best practices and tips for testing Spring Applications2m 9s
-
(Locked)
Challenge: Test a Spring weather application1m 8s
-
(Locked)
Solution: Test a Spring weather application16m 37s
-
(Locked)
-