use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistLiveMeasuresStepTest method delete_measures_from_db_if_no_longer_computed.
@Test
public void delete_measures_from_db_if_no_longer_computed() {
prepareProject();
// measure to be updated
LiveMeasureDto measureOnFileInProject = insertMeasure("file-uuid", "project-uuid", INT_METRIC);
// measure to be deleted because not computed anymore
LiveMeasureDto otherMeasureOnFileInProject = insertMeasure("file-uuid", "project-uuid", STRING_METRIC);
// measure in another project, not touched
LiveMeasureDto measureInOtherProject = insertMeasure("other-file-uuid", "other-project-uuid", INT_METRIC);
db.commit();
measureRepository.addRawMeasure(REF_4, INT_METRIC.getKey(), newMeasureBuilder().create(42));
TestComputationStepContext context = new TestComputationStepContext();
step().execute(context);
assertThatMeasureHasValue(measureOnFileInProject, 42);
assertThatMeasureDoesNotExist(otherMeasureOnFileInProject);
assertThatMeasureHasValue(measureInOtherProject, (int) measureInOtherProject.getValue().doubleValue());
verifyStatistics(context, 1);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistProjectLinksStepTest method add_links_on_project.
@Test
public void add_links_on_project() {
mockBranch(true);
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build());
// project
reportReader.putComponent(ScannerReport.Component.newBuilder().setRef(1).setType(ComponentType.PROJECT).addChildRef(2).addLink(ScannerReport.ComponentLink.newBuilder().setType(HOME).setHref("http://www.sonarqube.org").build()).addLink(ScannerReport.ComponentLink.newBuilder().setType(SCM).setHref("https://github.com/SonarSource/sonar").build()).addLink(ScannerReport.ComponentLink.newBuilder().setType(ISSUE).setHref("http://jira.sonarsource.com/").build()).addLink(ScannerReport.ComponentLink.newBuilder().setType(CI).setHref("http://bamboo.ci.codehaus.org/browse/SONAR").build()).build());
underTest.execute(new TestComputationStepContext());
assertThat(db.getDbClient().projectLinkDao().selectByProjectUuid(db.getSession(), "ABCD")).extracting(ProjectLinkDto::getType, ProjectLinkDto::getHref, ProjectLinkDto::getName).containsExactlyInAnyOrder(tuple("homepage", "http://www.sonarqube.org", null), tuple("scm", "https://github.com/SonarSource/sonar", null), tuple("issue", "http://jira.sonarsource.com/", null), tuple("ci", "http://bamboo.ci.codehaus.org/browse/SONAR", null));
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method no_period_date_if_not_branch.
@Test
public void no_period_date_if_not_branch() {
when(analysisMetadataHolder.isBranch()).thenReturn(false);
underTest.execute(new TestComputationStepContext());
verify(analysisMetadataHolder).isBranch();
assertThat(periodsHolder.hasPeriod()).isFalse();
verifyNoMoreInteractions(analysisMetadataHolder);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method load_reference_branch_without_fork_date_in_report.
@Test
public void load_reference_branch_without_fork_date_in_report() {
ComponentDto branch = dbTester.components().insertProjectBranch(project);
setupRoot(branch);
setProjectPeriod(project.uuid(), NewCodePeriodType.REFERENCE_BRANCH, "master");
underTest.execute(new TestComputationStepContext());
assertPeriod(NewCodePeriodType.REFERENCE_BRANCH, "master", null);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadQualityProfilesStepTest method ignore_rules_with_status_REMOVED.
@Test
public void ignore_rules_with_status_REMOVED() {
ruleRepository.add(new DumbRule(XOO_X1).setStatus(RuleStatus.REMOVED));
ScannerReport.ActiveRule.Builder batch1 = ScannerReport.ActiveRule.newBuilder().setRuleRepository(XOO_X1.repository()).setRuleKey(XOO_X1.rule()).setSeverity(Constants.Severity.BLOCKER);
batchReportReader.putActiveRules(asList(batch1.build()));
underTest.execute(new TestComputationStepContext());
assertThat(activeRulesHolder.getAll()).isEmpty();
}
Aggregations