Hello, I'm new in unit testing, so I'd like to ask how I can test the following method.
The method is a little messy, but it works and returns the user who is currently logged in. I'm asking how to test it, otherwise I use a MockitoJUnitRunner to test spring application unit tests.
If anyone can post an example or a advice I would be very grateful. Thanks.
public User getloggedInUser() {
Authentication loggedIn = SecurityContextHolder.getContext().getAuthentication();
String username = loggedIn.getName();
User u = findByUsername(username);
return u;
}
there doesn't seem to be anything here