From the course: Advanced Spring: Effective Integration Testing with Spring Boot

Unlock the full course today

Join today to access over 24,200 courses taught by industry experts.

Solution: Write tests for a custom query

Solution: Write tests for a custom query

(upbeat music) - [Instructor] Welcome back. How did you make out with the challenge? I hope you were successful. I will walk you through my solution. Now, it might look different than yours but that's fine as long as the outcome is the same. First, we want to extend our student class with new attributes. Boolean active and int grade. If you don't have desired constructor what I like to use is builder (indistinct) that can be simply enabled with Project Lombok, by adding ed builder with (indistinct) students class. Also in previous tests, we have used construct through which accepts ID and name, which is now missing. So let's add that one as well. Now, we are ready to write our failing tests. We will name it getAvgGrade for active students calculatesAvg. Again, I will structure my test with given, when, then. In the given part, we want to create a couple of students. First, we want to create student Mark, which is active and has grade 80. Similar to Mark, we have students Susan that is…

Contents