use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_does_not_set_analysisUuid_in_CeActivity_when_CeTaskResult_has_no_analysis_uuid.
@Test
public void remove_does_not_set_analysisUuid_in_CeActivity_when_CeTaskResult_has_no_analysis_uuid() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
Optional<CeTask> peek = underTest.peek();
underTest.remove(peek.get(), CeActivityDto.Status.SUCCESS, newTaskResult(null), null);
// available in history
Optional<CeActivityDto> history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), task.getUuid());
assertThat(history.isPresent()).isTrue();
assertThat(history.get().getAnalysisUuid()).isNull();
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method test_remove.
@Test
public void test_remove() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
Optional<CeTask> peek = underTest.peek();
underTest.remove(peek.get(), CeActivityDto.Status.SUCCESS, null, null);
// queue is empty
assertThat(dbTester.getDbClient().ceQueueDao().selectByUuid(dbTester.getSession(), task.getUuid()).isPresent()).isFalse();
assertThat(underTest.peek().isPresent()).isFalse();
// available in history
Optional<CeActivityDto> history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), task.getUuid());
assertThat(history.isPresent()).isTrue();
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.SUCCESS);
assertThat(history.get().getIsLast()).isTrue();
assertThat(history.get().getAnalysisUuid()).isNull();
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method remove_sets_snapshotId_in_CeActivity_when_CeTaskResult_has_no_snapshot_id.
@Test
public void remove_sets_snapshotId_in_CeActivity_when_CeTaskResult_has_no_snapshot_id() {
CeTask task = submit(CeTaskTypes.REPORT, "PROJECT_1");
Optional<CeTask> peek = underTest.peek();
underTest.remove(peek.get(), CeActivityDto.Status.SUCCESS, newTaskResult(AN_ANALYSIS_UUID), null);
// available in history
Optional<CeActivityDto> history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), task.getUuid());
assertThat(history.isPresent()).isTrue();
assertThat(history.get().getAnalysisUuid()).isEqualTo("U1");
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method cancelAll_pendings_but_not_in_progress.
@Test
public void cancelAll_pendings_but_not_in_progress() throws Exception {
CeTask inProgressTask = submit(CeTaskTypes.REPORT, "PROJECT_1");
CeTask pendingTask1 = submit(CeTaskTypes.REPORT, "PROJECT_2");
CeTask pendingTask2 = submit(CeTaskTypes.REPORT, "PROJECT_3");
underTest.peek();
int canceledCount = underTest.cancelAll();
assertThat(canceledCount).isEqualTo(2);
Optional<CeActivityDto> history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), pendingTask1.getUuid());
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), pendingTask2.getUuid());
assertThat(history.get().getStatus()).isEqualTo(CeActivityDto.Status.CANCELED);
history = dbTester.getDbClient().ceActivityDao().selectByUuid(dbTester.getSession(), inProgressTask.getUuid());
assertThat(history.isPresent()).isFalse();
}
use of org.sonar.db.ce.CeActivityDto in project sonarqube by SonarSource.
the class ComponentActionTest method insertActivity.
private CeActivityDto insertActivity(String taskUuid, String componentUuid, CeActivityDto.Status status) {
CeQueueDto queueDto = new CeQueueDto();
queueDto.setTaskType(CeTaskTypes.REPORT);
queueDto.setComponentUuid(componentUuid);
queueDto.setUuid(taskUuid);
CeActivityDto activityDto = new CeActivityDto(queueDto);
activityDto.setStatus(status);
activityDto.setExecutionTimeMs(500L);
activityDto.setAnalysisUuid("U1");
dbTester.getDbClient().ceActivityDao().insert(dbTester.getSession(), activityDto);
dbTester.getSession().commit();
return activityDto;
}
Aggregations