use of org.sonar.server.tester.MockUserSession in project sonarqube by SonarSource.
the class ThreadLocalUserSessionTest method get_session_for_user.
@Test
public void get_session_for_user() {
GroupDto group = GroupTesting.newGroupDto();
MockUserSession expected = new MockUserSession("karadoc").setUserId(123).setGroups(group);
threadLocalUserSession.set(expected);
UserSession session = threadLocalUserSession.get();
assertThat(session).isSameAs(expected);
assertThat(threadLocalUserSession.getUserId()).isEqualTo(123);
assertThat(threadLocalUserSession.getLogin()).isEqualTo("karadoc");
assertThat(threadLocalUserSession.isLoggedIn()).isTrue();
assertThat(threadLocalUserSession.getGroups()).extracting(GroupDto::getId).containsOnly(group.getId());
}
Aggregations