use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NotificationFactoryTest method newIssuesChangesNotification_creates_assignee_from_UserDto.
@Test
public void newIssuesChangesNotification_creates_assignee_from_UserDto() {
RuleKey ruleKey = RuleKey.of("foo", "bar");
String assigneeUuid = randomAlphabetic(40);
DefaultIssue issue = new DefaultIssue().setRuleKey(ruleKey).setKey("issueKey").setStatus(STATUS_OPEN).setAssigneeUuid(assigneeUuid);
UserDto userDto = UserTesting.newUserDto();
Map<String, UserDto> assigneesByUuid = ImmutableMap.of(assigneeUuid, userDto);
ReportComponent project = ReportComponent.builder(PROJECT, 1).build();
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(new Random().nextLong());
analysisMetadata.setBranch(newNonMainBranch(BranchType.BRANCH, randomAlphabetic(12)));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
IssuesChangesNotification notification = underTest.newIssuesChangesNotification(ImmutableSet.of(issue), assigneesByUuid);
assertThat(notification).isSameAs(expected);
IssuesChangesNotificationBuilder builder = verifyAndCaptureIssueChangeNotificationBuilder();
assertThat(builder.getIssues()).hasSize(1);
ChangedIssue changeIssue = builder.getIssues().iterator().next();
assertThat(changeIssue.getAssignee()).isPresent();
IssuesChangesNotificationBuilder.User assignee = changeIssue.getAssignee().get();
assertThat(assignee.getUuid()).isEqualTo(userDto.getUuid());
assertThat(assignee.getName()).contains(userDto.getName());
assertThat(assignee.getLogin()).isEqualTo(userDto.getLogin());
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class SourceLinesHashCacheTest method get_throws_ISE_if_not_cached.
@Test
public void get_throws_ISE_if_not_cached() {
Component component = createComponent(1);
assertThatThrownBy(() -> underTest.get(component)).isInstanceOf(IllegalStateException.class).hasMessage("Source line hashes for component ReportComponent{ref=1, key='FILE_KEY', type=FILE} not cached");
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class PersistFileSourcesStepTest method initBasicReport.
private void initBasicReport(int numberOfLines) {
ReportComponent root = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(fileComponent().setFileAttributes(new FileAttributes(false, null, numberOfLines)).build()).build();
treeRootHolder.setRoots(root, root);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NotificationFactoryTest method newIssuesChangesNotification_creates_project_from_TreeRootHolder_and_branch_name_from_branch.
@Test
public void newIssuesChangesNotification_creates_project_from_TreeRootHolder_and_branch_name_from_branch() {
RuleKey ruleKey = RuleKey.of("foo", "bar");
DefaultIssue issue = new DefaultIssue().setRuleKey(ruleKey).setKey("issueKey").setStatus(STATUS_OPEN);
Map<String, UserDto> assigneesByUuid = nonEmptyAssigneesByUuid();
ReportComponent project = ReportComponent.builder(PROJECT, 1).build();
String branchName = randomAlphabetic(12);
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(new Random().nextLong());
analysisMetadata.setBranch(newNonMainBranch(BranchType.BRANCH, branchName));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
IssuesChangesNotification notification = underTest.newIssuesChangesNotification(ImmutableSet.of(issue), assigneesByUuid);
assertThat(notification).isSameAs(expected);
IssuesChangesNotificationBuilder builder = verifyAndCaptureIssueChangeNotificationBuilder();
assertThat(builder.getIssues()).hasSize(1);
ChangedIssue changeIssue = builder.getIssues().iterator().next();
assertThat(changeIssue.getProject().getUuid()).isEqualTo(project.getUuid());
assertThat(changeIssue.getProject().getKey()).isEqualTo(project.getKey());
assertThat(changeIssue.getProject().getProjectName()).isEqualTo(project.getName());
assertThat(changeIssue.getProject().getBranchName()).contains(branchName);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class FileSourceDataWarningsTest method create_highlighting_warning_when_any_number_of_read_error_for_one_file.
@Test
public void create_highlighting_warning_when_any_number_of_read_error_for_one_file() {
ReportComponent file = ReportComponent.builder(Component.Type.FILE, 1).setUuid("uuid").setName(path).build();
LineReader.ReadError[] readErrors = IntStream.range(0, 1 + random.nextInt(10)).mapToObj(i -> new LineReader.ReadError(HIGHLIGHTING, line + i)).toArray(LineReader.ReadError[]::new);
when(system2.now()).thenReturn(timeStamp);
Arrays.stream(readErrors).forEach(readError -> underTest.addWarning(file, readError));
verifyZeroInteractions(taskMessages);
underTest.commitWarnings();
verify(taskMessages, times(1)).add(new CeTaskMessages.Message("Inconsistent highlighting data detected on file '" + path + "'. " + "File source may have been modified while analysis was running.", timeStamp));
}
Aggregations