use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class RegisterQualityProfileStatusStepTest method register_updated_profile.
@Test
public void register_updated_profile() {
QualityProfile qp1 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1000L));
QualityProfile qp2 = qp(QP_NAME_1, LANGUAGE_KEY_1, new Date(1200L));
mockBaseQPMeasures(treeRootHolder.getRoot(), arrayOf(qp1));
mockRawQProfiles(ImmutableList.of(qp2));
underTest.execute(new TestComputationStepContext());
verify(qProfileStatusRepository).register(qp2.getQpKey(), UPDATED);
verifyNoMoreInteractions(qProfileStatusRepository);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistAnalysisWarningsStepTest method execute_persists_warnings_from_reportReader.
@Test
public void execute_persists_warnings_from_reportReader() {
ScannerReport.AnalysisWarning warning1 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 1").build();
ScannerReport.AnalysisWarning warning2 = ScannerReport.AnalysisWarning.newBuilder().setText("warning 2").build();
ImmutableList<ScannerReport.AnalysisWarning> warnings = of(warning1, warning2);
reportReader.setAnalysisWarnings(warnings);
underTest.execute(new TestComputationStepContext());
verify(ceTaskMessages, times(1)).addAll(argumentCaptor.capture());
assertThat(argumentCaptor.getValue()).extracting(CeTaskMessages.Message::getText, CeTaskMessages.Message::getType).containsExactly(tuple("warning 1", CeTaskMessageType.GENERIC), tuple("warning 2", CeTaskMessageType.GENERIC));
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistCrossProjectDuplicationIndexStepTest method nothing_to_persist_when_no_cpd_text_blocks_in_report.
@Test
public void nothing_to_persist_when_no_cpd_text_blocks_in_report() {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
reportReader.putDuplicationBlocks(FILE_1_REF, Collections.emptyList());
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
assertThat(dbTester.countRowsOfTable("duplications_index")).isZero();
context.getStatistics().assertValue("inserts", 0);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistCrossProjectDuplicationIndexStepTest method nothing_to_do_when_cross_project_duplication_is_disabled.
@Test
public void nothing_to_do_when_cross_project_duplication_is_disabled() {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(false);
reportReader.putDuplicationBlocks(FILE_1_REF, singletonList(CPD_TEXT_BLOCK));
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
assertThat(dbTester.countRowsOfTable("duplications_index")).isZero();
context.getStatistics().assertValue("inserts", null);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class PersistCrossProjectDuplicationIndexStepTest method persist_cpd_text_block.
@Test
public void persist_cpd_text_block() {
when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true);
reportReader.putDuplicationBlocks(FILE_1_REF, singletonList(CPD_TEXT_BLOCK));
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
Map<String, Object> dto = dbTester.selectFirst("select HASH, START_LINE, END_LINE, INDEX_IN_FILE, COMPONENT_UUID, ANALYSIS_UUID from duplications_index");
assertThat(dto).containsEntry("HASH", CPD_TEXT_BLOCK.getHash()).containsEntry("START_LINE", 30L).containsEntry("END_LINE", 45L).containsEntry("INDEX_IN_FILE", 0L).containsEntry("COMPONENT_UUID", FILE_1.getUuid()).containsEntry("ANALYSIS_UUID", ANALYSIS_UUID);
context.getStatistics().assertValue("inserts", 1);
}
Aggregations