From the course: Test-Driven Development in Spring Boot with JUnit and Mockito
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Implementing the method of the controller
From the course: Test-Driven Development in Spring Boot with JUnit and Mockito
Implementing the method of the controller
- [Instructor] In this video, I'm going to implement the endpoint for getting all the tasks in our controller. So our green phase, I'm going to implement just enough code to make our task pass again. So my controller is going to heavily depend on the task surface. And again, I'm going to implement the minimal amount of code. So I'll leave some room for improvement here, going to make this auto wired, and of course I'll import our task service. And then the thing I'm going to do, I'm going to create a method for getting all the tasks, get all tasks, there we go. Importing our task model as well as our list. And I'm just going to say, list of tasks, tasks, equals task surface, get all tasks, and that's what I'll return. Return. Yes. So here's what's happening in this class. The class is annotate with address controller and that indicates it's a rest controller. And that means that what the method is returning is going to be automatically of type json as a response body. What I should…