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 25,500 courses taught by industry experts.

Refactoring the data layer

Refactoring the data layer

- [Instructor] Now that we've implemented our code, it's time to go ahead and move on to refactoring the data layer. This is all still rather simple code, since the repository only requires an interface. But let's look for opportunities to improve our code. In other words, let's refactor our code. Perhaps I notice that my task class has repetitive getters and setters, and it might be bugging me. So what I'm going to do, I'm actually going to delete all the getters and setters and use Lombok instead. In order to be able to do this, we must have Lombok in our pom.xml. And in order for all of this to work, we need to also go to our settings in IntelliJ and make sure that have the Lombok plugin enabled. Then on my task, I'm going to annotate this with @Data. Now I have my getters and setters available. What I also want to do, because if I look at my test, this is bugging me a little bit, that I need three lines to create a new task, so I'm going to add a constructor. Well, I do want to…

Contents