I am not able to understand why am I getting this error stating that connection of type Connection is not initialized if anyone could help me out with it.
In your main method, you are writing
Connection connection; // connection is still null
UserService sut = UserService(r, connection);
But as you error message said : you cannot instantiate UserService
with a connection
variable that is null.
You must rework your code so your variable won't be null when you initialize the UserService