use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class SendIssueNotificationsStepTest method do_not_send_notifications_if_no_subscribers.
@Test
public void do_not_send_notifications_if_no_subscribers() {
analysisMetadataHolder.setProject(new Project(PROJECT.getUuid(), PROJECT.getKey(), PROJECT.getName(), null, emptyList()));
when(notificationService.hasProjectSubscribersForTypes(PROJECT.getUuid(), NOTIF_TYPES)).thenReturn(false);
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
verify(notificationService, never()).deliver(any(Notification.class));
verify(notificationService, never()).deliverEmails(anyCollection());
verifyStatistics(context, 0, 0, 0);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method set_cross_project_duplication_to_true.
@Test
public void set_cross_project_duplication_to_true() {
reportReader.setMetadata(newBatchReportBuilder().setCrossProjectDuplicationActivated(true).build());
underTest.execute(new TestComputationStepContext());
assertThat(analysisMetadataHolder.isCrossProjectDuplicationEnabled()).isTrue();
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method set_analysis_date.
@Test
public void set_analysis_date() {
reportReader.setMetadata(newBatchReportBuilder().setAnalysisDate(ANALYSIS_DATE).build());
underTest.execute(new TestComputationStepContext());
assertThat(analysisMetadataHolder.getAnalysisDate()).isEqualTo(ANALYSIS_DATE);
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_if_main_projectKey_is_null_in_CE_task.
@Test
public void execute_fails_with_MessageException_if_main_projectKey_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
Optional<CeTask.Component> component = Optional.of(new CeTask.Component("main_prj_uuid", null, null));
when(res.getComponent()).thenReturn(component);
when(res.getMainComponent()).thenReturn(component);
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(MessageException.class).hasMessage("Compute Engine task main component key is null. Project with UUID main_prj_uuid must have been deleted since report was uploaded. Can not proceed.");
}
use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_sets_branch_even_if_MessageException_is_thrown_because_projectKey_in_report_is_different_from_componentKey_in_CE_task.
@Test
public void execute_sets_branch_even_if_MessageException_is_thrown_because_projectKey_in_report_is_different_from_componentKey_in_CE_task() {
ComponentDto otherProject = db.components().insertPublicProject();
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().setProjectKey(otherProject.getDbKey()).build());
try {
underTest.execute(new TestComputationStepContext());
} catch (MessageException e) {
assertThat(analysisMetadataHolder.getBranch()).isNotNull();
}
}
Aggregations