### Question:
LocationService implements PluginLocationService { public List<UserInfo> getUsersViewing(Entity entity) { List<UserInfo> viewList = new ArrayList<>(); UserInfo currentUser = securityService.getCurrentUserBasicInfo(); if (currentUser != null) { registerUserMap.put(currentUser, entity.getUuid()); } for (Object o : sessionRegistry.getAllPrincipals()) { UserInfo user = (UserInfo) o; if (entity.getUuid().equals(registerUserMap.get(user))) { viewList.add(user); } } return viewList; } LocationService(SecurityService securityService, SessionRegistry sessionRegistry); List<UserInfo> getUsersViewing(Entity entity); void clearUserLocation(); void clearUserLocation(Object user);  }### Answer:
@Test public void shouldContainUsersViewingTheTopic() { userInfo = new UserInfo(user); when(securityService.getCurrentUserBasicInfo()).thenReturn(userInfo); when(sessionRegistry.getAllPrincipals()).thenReturn(Collections.<Object>singletonList(userInfo)); List<UserInfo> usersViewing = locationService.getUsersViewing(topic); assertEquals(usersViewing.size(), 1); assertTrue(usersViewing.contains(userInfo)); }
@Test public void shouldNotContainAnonymousUsers() { when(securityService.getCurrentUserBasicInfo()).thenReturn(null); when(sessionRegistry.getAllPrincipals()).thenReturn(Collections.<Object>singletonList(new UserInfo(user))); List<UserInfo> usersViewing = locationService.getUsersViewing(topic); assertEquals(usersViewing.size(), 0); }