Well, I guess I am just being dumb on Monday, still recovering from ending of weekends.
The problem is simple and obvious. I am creating a bean that is not managed by Spring since I wrote UserService service = new UserService();
in the test calss. In order for a bean to be injected by spring, spring has to be aware of it and has relevant information of it. In my case, I have the config ready (relevant info), but the bean is not injected by Spring (not @Autowired
).
In conclusion, changing UserService service = new UserService();
to
@Autowired UserService service;
solved the problem.