use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DuplicationRepositoryRule method addDuplication.
public DuplicationRepositoryRule addDuplication(int fileRef, TextBlock original, String otherFileKey, TextBlock duplicate) {
ensureComponentProviderInitialized();
Component component = componentProvider.getByRef(fileRef);
checkArgument(!componentRefsWithCrossProjectDuplications.containsEntry(component, original), "CrossProject duplications for file %s and original %s already set", fileRef);
componentRefsWithCrossProjectDuplications.put(component, original);
delegate.add(componentProvider.getByRef(fileRef), new Duplication(original, Arrays.<Duplicate>asList(new CrossProjectDuplicate(otherFileKey, duplicate))));
return this;
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ComponentIssuesRepositoryRule method setIssues.
public void setIssues(int componentRef, List<DefaultIssue> issues) {
this.issues = requireNonNull(issues, "issues cannot be null");
Component component = treeRootHolder.getComponentByRef(componentRef);
checkArgument(component != null, String.format("Component '%s' does not exists in the report ", componentRef));
this.component = component;
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FillComponentIssuesVisitorRule method setIssues.
public void setIssues(int componentRef, DefaultIssue... issues) {
Component component = treeRootHolder.getComponentByRef(componentRef);
checkArgument(component != null, String.format("Component '%s' does not exists in the report ", componentRef));
this.issues.get(component).clear();
this.issues.putAll(component, asList(issues));
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class LastCommitVisitorTest method aggregate_date_of_last_commit_to_directories_and_project.
@Test
public void aggregate_date_of_last_commit_to_directories_and_project() {
final long FILE_1_DATE = 1_100_000_000_000L;
// FILE_2 is the most recent file in DIR_1
final long FILE_2_DATE = 1_200_000_000_000L;
// FILE_3 is the most recent file in the project
final long FILE_3_DATE = 1_300_000_000_000L;
// simulate the output of visitFile()
LastCommitVisitor visitor = new LastCommitVisitor(metricRepository, measureRepository, scmInfoRepository) {
@Override
public void visitFile(Component file, Path<LastCommit> path) {
long fileDate;
switch(file.getReportAttributes().getRef()) {
case FILE_1_REF:
fileDate = FILE_1_DATE;
break;
case FILE_2_REF:
fileDate = FILE_2_DATE;
break;
case FILE_3_REF:
fileDate = FILE_3_DATE;
break;
default:
throw new IllegalArgumentException();
}
path.parent().addDate(fileDate);
}
};
// project with 1 module, 2 directories and 3 files
ReportComponent project = ReportComponent.builder(PROJECT, PROJECT_REF).addChildren(ReportComponent.builder(MODULE, MODULE_REF).addChildren(ReportComponent.builder(DIRECTORY, DIR_1_REF).addChildren(createFileComponent(FILE_1_REF), createFileComponent(FILE_2_REF)).build(), ReportComponent.builder(DIRECTORY, DIR_2_REF).addChildren(createFileComponent(FILE_3_REF)).build()).build()).build();
treeRootHolder.setRoot(project);
VisitorsCrawler underTest = new VisitorsCrawler(Lists.<ComponentVisitor>newArrayList(visitor));
underTest.visit(project);
assertDate(DIR_1_REF, FILE_2_DATE);
assertDate(DIR_2_REF, FILE_3_DATE);
// module = most recent commit date of directories
assertDate(MODULE_REF, FILE_3_DATE);
// project
assertDate(PROJECT_REF, FILE_3_DATE);
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class IndexAnalysisStepTest method call_indexByProjectUuid_of_indexer_for_view.
@Test
public void call_indexByProjectUuid_of_indexer_for_view() {
Component view = ViewsComponent.builder(VIEW, PROJECT_KEY).setUuid(PROJECT_UUID).build();
treeRootHolder.setRoot(view);
underTest.execute();
verify(componentIndexer).indexProject(PROJECT_UUID, ProjectIndexer.Cause.NEW_ANALYSIS);
}
Aggregations