Loading lesson…
Level 1 · Apprentice0 XP
Constructor injection, controller to service to repository, and where @Transactional belongs.
Step 1 / 5
ProblemThe controller reads the request, queries the database, applies the rules and saves. It works, but you cannot test the rule without HTTP and you cannot reuse it from a scheduled job.
← → step
Before this: Network performance for the web
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Take a controller that calls a repository directly. Move the logic into a @Service with constructor injection, then write a plain unit test for the service using a fake repository, with no Spring context.