diff --git a/web/src/test/java/org/openmrs/web/filter/update/util/CurrentUsersTest.java b/web/src/test/java/org/openmrs/web/filter/update/util/CurrentUsersTest.java index 942698d278db..fe729792ada5 100644 --- a/web/src/test/java/org/openmrs/web/filter/update/util/CurrentUsersTest.java +++ b/web/src/test/java/org/openmrs/web/filter/update/util/CurrentUsersTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.api.Test; import org.openmrs.User; import org.openmrs.api.UserService; +import org.openmrs.api.context.Context; import org.openmrs.web.filter.util.CurrentUsers; import org.openmrs.web.test.BaseWebContextSensitiveTest; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +32,10 @@ public void getCurrentUsernames_shoulReturnAllCurrentUserNames() { executeDataSet(USER_SET); MockHttpSession session = new MockHttpSession(); User user = userService.getUser(5508); - CurrentUsers.addUser(session,user); + Context.authenticate(user.getUsername(),"User12345"); + Assert.assertEquals(Context.getAuthenticatedUser().getUsername(),user.getUsername()); + User loggedInUser = Context.getAuthenticatedUser(); + CurrentUsers.addUser(session,loggedInUser); List currentUserNames = CurrentUsers.getCurrentUsernames(session); Assert.assertTrue(currentUserNames.contains("firstaccount"));