use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class PurgeDaoTest method delete_row_in_ce_task_input_referring_to_a_row_in_ce_queue_when_deleting_project.
@Test
public void delete_row_in_ce_task_input_referring_to_a_row_in_ce_queue_when_deleting_project() {
ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeQueueDto projectTask = insertCeQueue(project);
insertCeTaskInput(projectTask.getUuid());
CeQueueDto branchTask = insertCeQueue(branch);
insertCeTaskInput(branchTask.getUuid());
CeQueueDto anotherBranchTask = insertCeQueue(anotherBranch);
insertCeTaskInput(anotherBranchTask.getUuid());
CeQueueDto anotherProjectTask = insertCeQueue(anotherProject);
insertCeTaskInput(anotherProjectTask.getUuid());
insertCeTaskInput("non existing task");
dbSession.commit();
underTest.deleteProject(dbSession, branch.uuid(), branch.qualifier(), project.name(), project.getKey());
dbSession.commit();
assertThat(uuidsIn("ce_queue")).containsOnly(projectTask.getUuid(), anotherBranchTask.getUuid(), anotherProjectTask.getUuid());
assertThat(taskUuidsIn("ce_task_input")).containsOnly(projectTask.getUuid(), anotherBranchTask.getUuid(), anotherProjectTask.getUuid(), "non existing task");
underTest.deleteProject(dbSession, project.uuid(), project.qualifier(), project.name(), project.getKey());
dbSession.commit();
assertThat(uuidsIn("ce_queue")).containsOnly(anotherProjectTask.getUuid());
assertThat(taskUuidsIn("ce_task_input")).containsOnly(anotherProjectTask.getUuid(), "non existing task");
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class PurgeDaoTest method delete_row_in_ce_scanner_context_referring_to_a_row_in_ce_queue_when_deleting_project.
@Test
public void delete_row_in_ce_scanner_context_referring_to_a_row_in_ce_queue_when_deleting_project() {
ComponentDto project = ComponentTesting.newPrivateProjectDto();
ComponentDto branch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherBranch = ComponentTesting.newBranchComponent(project, newBranchDto(project));
ComponentDto anotherProject = ComponentTesting.newPrivateProjectDto();
dbClient.componentDao().insert(dbSession, project, branch, anotherBranch, anotherProject);
CeQueueDto projectTask = insertCeQueue(project);
insertCeScannerContext(projectTask.getUuid());
CeQueueDto branchTask = insertCeQueue(branch);
insertCeScannerContext(branchTask.getUuid());
CeQueueDto anotherBranchTask = insertCeQueue(anotherBranch);
insertCeScannerContext(anotherBranchTask.getUuid());
CeQueueDto anotherProjectTask = insertCeQueue(anotherProject);
insertCeScannerContext(anotherProjectTask.getUuid());
insertCeScannerContext("non existing task");
dbSession.commit();
underTest.deleteProject(dbSession, branch.uuid(), branch.qualifier(), project.name(), project.getKey());
dbSession.commit();
assertThat(uuidsIn("ce_queue")).containsOnly(projectTask.getUuid(), anotherBranchTask.getUuid(), anotherProjectTask.getUuid());
assertThat(taskUuidsIn("ce_scanner_context")).containsOnly(projectTask.getUuid(), anotherBranchTask.getUuid(), anotherProjectTask.getUuid(), "non existing task");
underTest.deleteProject(dbSession, project.uuid(), project.qualifier(), project.name(), project.getKey());
dbSession.commit();
assertThat(uuidsIn("ce_queue")).containsOnly(anotherProjectTask.getUuid());
assertThat(taskUuidsIn("ce_scanner_context")).containsOnly(anotherProjectTask.getUuid(), "non existing task");
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class PurgeDaoTest method insertCeQueue.
private CeQueueDto insertCeQueue(ComponentDto component) {
CeQueueDto res = new CeQueueDto().setUuid(UuidFactoryFast.getInstance().create()).setTaskType("foo").setComponentUuid(component.uuid()).setMainComponentUuid(firstNonNull(component.getMainBranchProjectUuid(), component.uuid())).setStatus(Status.PENDING).setCreatedAt(1_2323_222L).setUpdatedAt(1_2323_222L);
dbClient.ceQueueDao().insert(dbSession, res);
dbSession.commit();
return res;
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class PurgeDaoTest method createCeQueue.
private CeQueueDto createCeQueue(ComponentDto component, Status status) {
CeQueueDto queueDto = new CeQueueDto();
queueDto.setUuid(Uuids.create());
queueDto.setTaskType(REPORT);
queueDto.setComponentUuid(component.uuid());
queueDto.setMainComponentUuid(firstNonNull(component.getMainBranchProjectUuid(), component.uuid()));
queueDto.setSubmitterUuid("submitter uuid");
queueDto.setCreatedAt(1_300_000_000_000L);
queueDto.setStatus(status);
return queueDto;
}
use of org.sonar.db.ce.CeQueueDto in project sonarqube by SonarSource.
the class PurgeDaoTest method insertCeActivityAndChildDataWithDate.
@SafeVarargs
private final void insertCeActivityAndChildDataWithDate(String ceActivityUuid, LocalDateTime dateTime, Consumer<CeQueueDto>... queueDtoConsumers) {
long date = dateTime.toInstant(UTC).toEpochMilli();
CeQueueDto queueDto = new CeQueueDto();
queueDto.setUuid(ceActivityUuid);
queueDto.setTaskType(CeTaskTypes.REPORT);
Arrays.stream(queueDtoConsumers).forEach(t -> t.accept(queueDto));
CeActivityDto dto = new CeActivityDto(queueDto);
dto.setStatus(CeActivityDto.Status.SUCCESS);
when(system2.now()).thenReturn(date);
insertCeTaskInput(dto.getUuid());
insertCeTaskCharacteristics(dto.getUuid(), 1);
insertCeScannerContext(dto.getUuid());
insertCeTaskMessages(dto.getUuid(), 2);
db.getDbClient().ceActivityDao().insert(db.getSession(), dto);
db.getSession().commit();
}
Aggregations