use of org.sonar.ce.task.projectanalysis.filemove.MovedFilesRepository.OriginalFile in project sonarqube by SonarSource.
the class RemoveProcessedComponentsVisitorTest method also_remove_moved_files.
@Test
public void also_remove_moved_files() {
String uuid2 = "uuid2";
OriginalFile movedFile = new OriginalFile(uuid2, "key");
when(movedFilesRepository.getOriginalFile(any(Component.class))).thenReturn(Optional.of(movedFile));
underTest.afterComponent(component);
verify(movedFilesRepository).getOriginalFile(component);
verify(componentsWithUnprocessedIssues).remove(UUID);
verify(componentsWithUnprocessedIssues).remove(uuid2);
verifyNoMoreInteractions(componentsWithUnprocessedIssues);
}
use of org.sonar.ce.task.projectanalysis.filemove.MovedFilesRepository.OriginalFile in project sonarqube by SonarSource.
the class MovedIssueVisitor method onIssue.
@Override
public void onIssue(Component component, DefaultIssue issue) {
if (component.getType() != Component.Type.FILE || component.getUuid().equals(issue.componentUuid())) {
return;
}
Optional<OriginalFile> originalFileOptional = movedFilesRepository.getOriginalFile(component);
checkState(originalFileOptional.isPresent(), "Issue %s for component %s has a different component key but no original file exist in MovedFilesRepository", issue, component);
OriginalFile originalFile = originalFileOptional.get();
checkState(originalFile.getUuid().equals(issue.componentUuid()), "Issue %s doesn't belong to file %s registered as original file of current file %s", issue, originalFile.getUuid(), component);
// changes the issue's component uuid, add a change and set issue as changed to enforce it is persisted to DB
issueUpdater.setIssueMoved(issue, component.getUuid(), IssueChangeContext.createUser(new Date(analysisMetadataHolder.getAnalysisDate()), null));
// other fields (such as module, modulePath, componentKey) are read-only and set/reset for consistency only
issue.setComponentKey(component.getKey());
issue.setModuleUuid(null);
issue.setModuleUuidPath(null);
}
Aggregations