use of org.sonarqube.ws.Common.User in project sonarqube by SonarSource.
the class ShowActionTest method returns_author_details_when_user_exists.
@Test
public void returns_author_details_when_user_exists() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
UserDto author = dbTester.users().insertUser();
IssueDto hotspot = dbTester.issues().insertHotspot(rule, project, file, t -> t.setAuthorLogin(author.getLogin()));
mockChangelogAndCommentsFormattingContext();
Hotspots.ShowWsResponse response = newRequest(hotspot).executeProtobuf(Hotspots.ShowWsResponse.class);
assertThat(response.getAuthor()).isEqualTo(author.getLogin());
User wsAuthorFromList = response.getUsersList().iterator().next();
assertThat(wsAuthorFromList.getLogin()).isEqualTo(author.getLogin());
assertThat(wsAuthorFromList.getName()).isEqualTo(author.getName());
assertThat(wsAuthorFromList.getActive()).isEqualTo(author.isActive());
assertThat(wsAuthorFromList.getAvatar()).isEqualTo(avatarResolver.create(author));
}
use of org.sonarqube.ws.Common.User in project sonarqube by SonarSource.
the class ShowActionTest method returns_user_of_users_from_ChangelogAndComments_and_assignee_and_author.
@Test
public void returns_user_of_users_from_ChangelogAndComments_and_assignee_and_author() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
UserDto author = dbTester.users().insertUser();
UserDto assignee = dbTester.users().insertUser();
IssueDto hotspot = dbTester.issues().insertHotspot(rule, project, file, t -> t.setAuthorLogin(author.getLogin()).setAssigneeUuid(assignee.getUuid()));
FormattingContext formattingContext = mockChangelogAndCommentsFormattingContext();
Set<UserDto> changeLogAndCommentsUsers = IntStream.range(0, 1 + RANDOM.nextInt(14)).mapToObj(i -> UserTesting.newUserDto()).collect(Collectors.toSet());
when(formattingContext.getUsers()).thenReturn(changeLogAndCommentsUsers);
Hotspots.ShowWsResponse response = newRequest(hotspot).executeProtobuf(Hotspots.ShowWsResponse.class);
assertThat(response.getUsersList()).extracting(User::getLogin, User::getName, User::getActive).containsExactlyInAnyOrder(Stream.concat(Stream.of(author, assignee), changeLogAndCommentsUsers.stream()).map(t -> tuple(t.getLogin(), t.getName(), t.isActive())).toArray(Tuple[]::new));
}
use of org.sonarqube.ws.Common.User in project sonarqube by SonarSource.
the class ShowActionTest method returns_assignee_details_when_user_exists.
@Test
public void returns_assignee_details_when_user_exists() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
UserDto assignee = dbTester.users().insertUser();
IssueDto hotspot = dbTester.issues().insertHotspot(rule, project, file, t -> t.setAssigneeUuid(assignee.getUuid()));
mockChangelogAndCommentsFormattingContext();
Hotspots.ShowWsResponse response = newRequest(hotspot).executeProtobuf(Hotspots.ShowWsResponse.class);
assertThat(response.getAssignee()).isEqualTo(assignee.getLogin());
assertThat(response.getUsersList()).hasSize(1);
User wsAssignee = response.getUsersList().iterator().next();
assertThat(wsAssignee.getLogin()).isEqualTo(assignee.getLogin());
assertThat(wsAssignee.getName()).isEqualTo(assignee.getName());
assertThat(wsAssignee.getActive()).isEqualTo(assignee.isActive());
assertThat(wsAssignee.getAvatar()).isEqualTo(avatarResolver.create(assignee));
}
use of org.sonarqube.ws.Common.User in project sonarqube by SonarSource.
the class SearchResponseFormat method formatUsers.
private Users.Builder formatUsers(SearchResponseData data) {
Users.Builder wsUsers = Users.newBuilder();
List<UserDto> users = data.getUsers();
if (users != null) {
User.Builder builder = User.newBuilder();
for (UserDto user : users) {
wsUsers.addUsers(userFormatter.formatUser(builder, user));
}
}
return wsUsers;
}
use of org.sonarqube.ws.Common.User in project sonarqube by SonarSource.
the class ShowActionTest method returns_user_details_of_users_from_ChangelogAndComments.
@Test
public void returns_user_details_of_users_from_ChangelogAndComments() {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.registerComponents(project);
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
IssueDto hotspot = dbTester.issues().insertHotspot(rule, project, file);
FormattingContext formattingContext = mockChangelogAndCommentsFormattingContext();
Set<UserDto> changeLogAndCommentsUsers = IntStream.range(0, 1 + RANDOM.nextInt(14)).mapToObj(i -> UserTesting.newUserDto()).collect(Collectors.toSet());
when(formattingContext.getUsers()).thenReturn(changeLogAndCommentsUsers);
Hotspots.ShowWsResponse response = newRequest(hotspot).executeProtobuf(Hotspots.ShowWsResponse.class);
assertThat(response.getUsersList()).extracting(User::getLogin, User::getName, User::getActive).containsExactlyInAnyOrder(changeLogAndCommentsUsers.stream().map(t -> tuple(t.getLogin(), t.getName(), t.isActive())).toArray(Tuple[]::new));
}
Aggregations