use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class TaskFormatterTest method formatActivity_with_both_error_message_and_stacktrace.
@Test
public void formatActivity_with_both_error_message_and_stacktrace() {
CeActivityDto dto = newActivity("UUID", "COMPONENT_UUID", CeActivityDto.Status.FAILED).setErrorMessage("error msg").setErrorStacktrace("error stacktrace");
WsCe.Task task = underTest.formatActivity(db.getSession(), Collections.singletonList(dto)).iterator().next();
assertThat(task.getErrorMessage()).isEqualTo(dto.getErrorMessage());
assertThat(task.getErrorStacktrace()).isEqualTo(dto.getErrorStacktrace());
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class TaskFormatterTest method formatActivity.
@Test
public void formatActivity() {
CeActivityDto dto = newActivity("UUID", "COMPONENT_UUID", CeActivityDto.Status.FAILED);
WsCe.Task wsTask = underTest.formatActivity(db.getSession(), dto);
assertThat(wsTask.getType()).isEqualTo(CeTaskTypes.REPORT);
assertThat(wsTask.getId()).isEqualTo("UUID");
assertThat(wsTask.getStatus()).isEqualTo(WsCe.TaskStatus.FAILED);
assertThat(wsTask.getSubmittedAt()).isEqualTo(DateUtils.formatDateTime(new Date(1_450_000_000_000L)));
assertThat(wsTask.getExecutionTimeMs()).isEqualTo(500L);
assertThat(wsTask.getAnalysisId()).isEqualTo("U1");
assertThat(wsTask.getLogs()).isFalse();
assertThat(wsTask.hasScannerContext()).isFalse();
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class TaskFormatterTest method formatActivities.
@Test
public void formatActivities() {
CeActivityDto dto1 = newActivity("UUID1", "COMPONENT_UUID", CeActivityDto.Status.FAILED);
CeActivityDto dto2 = newActivity("UUID2", "COMPONENT_UUID", CeActivityDto.Status.SUCCESS);
Iterable<WsCe.Task> wsTasks = underTest.formatActivity(db.getSession(), asList(dto1, dto2));
assertThat(wsTasks).extracting("id").containsExactly("UUID1", "UUID2");
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method cancel_pending.
@Test
public void cancel_pending() throws Exception {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
// ignore
boolean canceled = underTest.cancel("UNKNOWN");
assertThat(canceled).isFalse();
canceled = underTest.cancel(task.getUuid());
assertThat(canceled).isTrue();
Optional<CeActivityDto> activity = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), task.getUuid());
assertThat(activity.isPresent()).isTrue();
assertThat(activity.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_saves_error_message_and_stacktrace_when_exception_is_provided.
@Test
public void remove_saves_error_message_and_stacktrace_when_exception_is_provided() {
Throwable error = new NullPointerException("Fake NPE to test persistence to DB");
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
Optional<CeTask> peek = underTest.peek();
underTest.remove(peek.get(), CeActivityDto.Status.FAILED, null, error);
Optional<CeActivityDto> activityDto = dbTester.getDbClient().ceActivityDao().selectByUuid(session, task.getUuid());
assertThat(activityDto).isPresent();
assertThat(activityDto.get().getErrorMessage()).isEqualTo(error.getMessage());
assertThat(activityDto.get().getErrorStacktrace()).isEqualToIgnoringWhitespace(stacktraceToString(error));
}
Aggregations