use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class IndexIssuesStepTest method fail_if_missing_component_in_task.
@Test
public void fail_if_missing_component_in_task() {
CeTask ceTask = new CeTask.Builder().setType("type").setUuid("uuid").setComponent(null).setMainComponent(null).build();
IndexIssuesStep underTest = new IndexIssuesStep(ceTask, dbClient, issueIndexer);
assertThatThrownBy(() -> underTest.execute(() -> null)).isInstanceOf(UnsupportedOperationException.class).hasMessage("component not found in task");
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task.
@Test
public void execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task() {
CeTask res = mock(CeTask.class);
Optional<CeTask.Component> component = Optional.of(new CeTask.Component("prj_uuid", null, null));
when(res.getComponent()).thenReturn(component);
when(res.getMainComponent()).thenReturn(Optional.of(new CeTask.Component("main_prj_uuid", "main_prj_key", null)));
reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build());
ComputationStep underTest = createStep(res);
assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext())).isInstanceOf(MessageException.class).hasMessage("Compute Engine task component key is null. Project with UUID prj_uuid must have been deleted since report was uploaded. Can not proceed.");
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class SubmitAction method handle.
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY);
String projectName = abbreviate(defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey), MAX_COMPONENT_NAME_LENGTH);
Map<String, String> characteristics = parseTaskCharacteristics(wsRequest);
try (InputStream report = new BufferedInputStream(wsRequest.mandatoryParamAsPart(PARAM_REPORT_DATA).getInputStream())) {
CeTask task = reportSubmitter.submit(projectKey, projectName, characteristics, report);
Ce.SubmitResponse submitResponse = Ce.SubmitResponse.newBuilder().setTaskId(task.getUuid()).setProjectId(task.getComponent().get().getUuid()).build();
WsUtils.writeProtobuf(submitResponse, wsRequest, wsResponse);
}
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeTaskLoggingTest method createCeTask.
private CeTask createCeTask(String uuid) {
CeTask ceTask = Mockito.mock(CeTask.class);
when(ceTask.getUuid()).thenReturn(uuid);
return ceTask;
}
use of org.sonar.ce.task.CeTask in project sonarqube by SonarSource.
the class CeTaskMessagesImplTest method addAll_has_no_effect_if_arg_is_empty.
@Test
public void addAll_has_no_effect_if_arg_is_empty() {
DbClient dbClientMock = mock(DbClient.class);
UuidFactory uuidFactoryMock = mock(UuidFactory.class);
CeTask ceTaskMock = mock(CeTask.class);
CeTaskMessagesImpl underTest = new CeTaskMessagesImpl(dbClientMock, uuidFactoryMock, ceTaskMock);
underTest.addAll(Collections.emptyList());
verifyZeroInteractions(dbClientMock, uuidFactoryMock, ceTaskMock);
}
Aggregations