本文整理了Java中org.sonar.db.webhook.WebhookDeliveryDao
类的一些代码示例,展示了WebhookDeliveryDao
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebhookDeliveryDao
类的具体详情如下:
包路径:org.sonar.db.webhook.WebhookDeliveryDao
类名称:WebhookDeliveryDao
暂无
代码示例来源:origin: SonarSource/sonarqube
public void persist(WebhookDelivery delivery) {
WebhookDeliveryDao dao = dbClient.webhookDeliveryDao();
try (DbSession dbSession = dbClient.openSession(false)) {
dao.insert(dbSession, toDto(delivery));
dbSession.commit();
}
}
代码示例来源:origin: SonarSource/sonarqube
private WebhookDeliveryDto selectByUuid(String uuid) {
Optional<WebhookDeliveryDto> dto = underTest.selectByUuid(dbSession, uuid);
assertThat(dto).isPresent();
return dto.get();
}
}
代码示例来源:origin: SonarSource/sonarqube
private Data loadFromDatabase(@Nullable String webhookUuid, @Nullable String ceTaskId, @Nullable String componentKey, int page, int pageSize) {
ComponentDto component;
List<WebhookDeliveryLiteDto> deliveries;
int totalElements;
try (DbSession dbSession = dbClient.openSession(false)) {
if (isNotBlank(webhookUuid)) {
totalElements = dbClient.webhookDeliveryDao().countDeliveriesByWebhookUuid(dbSession, webhookUuid);
deliveries = dbClient.webhookDeliveryDao().selectByWebhookUuid(dbSession, webhookUuid, offset(page, pageSize), pageSize);
component = getComponentDto(dbSession, deliveries);
} else if (componentKey != null) {
component = componentFinder.getByKey(dbSession, componentKey);
totalElements = dbClient.webhookDeliveryDao().countDeliveriesByComponentUuid(dbSession, component.uuid());
deliveries = dbClient.webhookDeliveryDao().selectOrderedByComponentUuid(dbSession, component.uuid(), offset(page, pageSize), pageSize);
} else {
totalElements = dbClient.webhookDeliveryDao().countDeliveriesByCeTaskUuid(dbSession, ceTaskId);
deliveries = dbClient.webhookDeliveryDao().selectOrderedByCeTaskUuid(dbSession, ceTaskId, offset(page, pageSize), pageSize);
component = getComponentDto(dbSession, deliveries);
}
}
return new Data(component, deliveries).withPagingInfo(page, pageSize, totalElements);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectByWebhookUuid_returns_empty_if_no_records() {
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("D1", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1"));
List<WebhookDeliveryLiteDto> deliveries = underTest.selectByWebhookUuid(dbSession, "a-webhook-uuid", 0, 10);
assertThat(deliveries).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectOrderedByComponentUuid_returns_empty_if_no_records() {
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("D1", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1"));
List<WebhookDeliveryLiteDto> deliveries = underTest.selectOrderedByComponentUuid(dbSession, "ANOTHER_COMPONENT", 0, 10);
assertThat(deliveries).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectOrderedByCeTaskUuid_returns_empty_if_no_records() {
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("D1", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1"));
List<WebhookDeliveryLiteDto> deliveries = underTest.selectOrderedByCeTaskUuid(dbSession, "ANOTHER_TASK", 0, 10);
assertThat(deliveries).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectLatestDelivery_of_a_webhook() {
WebhookDto webhook1 = dbWebhooks.insert(newProjectWebhook("COMPONENT_1"));
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH1-DELIVERY-1-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH1-DELIVERY-2-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
WebhookDto webhook2 = dbWebhooks.insert(newProjectWebhook("COMPONENT_1"));
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH2-DELIVERY-1-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH2-DELIVERY-2-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
Map<String, WebhookDeliveryLiteDto> map = underTest.selectLatestDeliveries(dbSession, of(webhook1, webhook2));
assertThat(map).containsKeys(webhook1.getUuid());
assertThat(map.get(webhook1.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).contains("WH1-DELIVERY-2-UUID");
assertThat(map).containsKeys(webhook2.getUuid());
assertThat(map.get(webhook2.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).contains("WH2-DELIVERY-2-UUID");
}
代码示例来源:origin: SonarSource/sonarqube
public Map<String, WebhookDeliveryLiteDto> selectLatestDeliveries(DbSession dbSession, List<WebhookDto> webhooks) {
return webhooks.stream()
.flatMap(webhook -> selectByWebhookUuid(dbSession, webhook.getUuid(),0,1).stream())
.collect(toMap(WebhookDeliveryLiteDto::getWebhookUuid, identity()));
}
代码示例来源:origin: SonarSource/sonarqube
private void deleteWebhook(DbSession dbSession, WebhookDto webhookDto) {
dbClient.webhookDeliveryDao().deleteByWebhook(dbSession, webhookDto);
dbClient.webhookDao().delete(dbSession, webhookDto.getUuid());
}
代码示例来源:origin: SonarSource/sonarqube
private Map<String, WebhookDeliveryLiteDto> loadLastDeliveriesOf(DbSession dbSession, List<WebhookDto> webhookDtos) {
return dbClient.webhookDeliveryDao().selectLatestDeliveries(dbSession, webhookDtos);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void delete_a_project_webhook() {
ComponentDto project = componentDbTester.insertPrivateProject();
WebhookDto dto = webhookDbTester.insertWebhook(project);
webhookDeliveryDbTester.insert(newDto().setWebhookUuid(dto.getUuid()));
webhookDeliveryDbTester.insert(newDto().setWebhookUuid(dto.getUuid()));
userSession.logIn().addProjectPermission(ADMIN, project);
TestResponse response = wsActionTester.newRequest()
.setParam(KEY_PARAM, dto.getUuid())
.execute();
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
assertThat(reloaded).isEmpty();
int deliveriesCount = deliveryDao.countDeliveriesByWebhookUuid(dbSession, dto.getUuid());
assertThat(deliveriesCount).isEqualTo(0);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectByWebhookUuid_returns_records_ordered_by_date() {
WebhookDto webhookDto = dbWebhooks.insert(WebhookTesting.newProjectWebhook("COMPONENT_1"));
WebhookDeliveryDto dto1 = WebhookDeliveryTesting.newDto("D1", webhookDto.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE);
WebhookDeliveryDto dto2 = WebhookDeliveryTesting.newDto("D2", webhookDto.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW);
WebhookDeliveryDto dto3 = WebhookDeliveryTesting.newDto("D3", "fake-webhook-uuid", "COMPONENT_2", "TASK_1").setCreatedAt(NOW);
underTest.insert(dbSession, dto3);
underTest.insert(dbSession, dto2);
underTest.insert(dbSession, dto1);
List<WebhookDeliveryLiteDto> deliveries = underTest.selectByWebhookUuid(dbSession, webhookDto.getUuid(), 0, 10);
assertThat(deliveries).extracting(WebhookDeliveryLiteDto::getUuid).containsExactly("D2", "D1");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectOrderedByComponentUuid_returns_records_ordered_by_date() {
WebhookDeliveryDto dto1 = WebhookDeliveryTesting.newDto("D1", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE);
WebhookDeliveryDto dto2 = WebhookDeliveryTesting.newDto("D2", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1").setCreatedAt(NOW);
WebhookDeliveryDto dto3 = WebhookDeliveryTesting.newDto("D3", "WEBHOOK_UUID_1", "COMPONENT_2", "TASK_1").setCreatedAt(NOW);
underTest.insert(dbSession, dto3);
underTest.insert(dbSession, dto2);
underTest.insert(dbSession, dto1);
List<WebhookDeliveryLiteDto> deliveries = underTest.selectOrderedByComponentUuid(dbSession, "COMPONENT_1", 0, 10);
assertThat(deliveries).extracting(WebhookDeliveryLiteDto::getUuid).containsExactly("D2", "D1");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectOrderedByCeTaskUuid_returns_records_ordered_by_date() {
WebhookDeliveryDto dto1 = WebhookDeliveryTesting.newDto("D1", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE);
WebhookDeliveryDto dto2 = WebhookDeliveryTesting.newDto("D2", "WEBHOOK_UUID_1", "COMPONENT_1", "TASK_1").setCreatedAt(NOW);
WebhookDeliveryDto dto3 = WebhookDeliveryTesting.newDto("D3", "WEBHOOK_UUID_1", "COMPONENT_2", "TASK_2").setCreatedAt(NOW);
underTest.insert(dbSession, dto3);
underTest.insert(dbSession, dto2);
underTest.insert(dbSession, dto1);
List<WebhookDeliveryLiteDto> deliveries = underTest.selectOrderedByCeTaskUuid(dbSession, "TASK_1", 0, 10);
assertThat(deliveries).extracting(WebhookDeliveryLiteDto::getUuid).containsExactly("D2", "D1");
}
代码示例来源:origin: SonarSource/sonarqube
private void deleteOrganization(DbSession dbSession, OrganizationDto organization) {
Collection<String> uuids = dbClient.organizationMemberDao().selectUserUuidsByOrganizationUuid(dbSession, organization.getUuid());
dbClient.organizationMemberDao().deleteByOrganizationUuid(dbSession, organization.getUuid());
dbClient.organizationDao().deleteByUuid(dbSession, organization.getUuid());
dbClient.userDao().cleanHomepage(dbSession, organization);
dbClient.webhookDao().selectByOrganizationUuid(dbSession, organization.getUuid())
.forEach(wh -> dbClient.webhookDeliveryDao().deleteByWebhook(dbSession, wh));
dbClient.webhookDao().deleteByOrganization(dbSession, organization);
List<UserDto> users = dbClient.userDao().selectByUuids(dbSession, uuids);
userIndexer.commitAndIndex(dbSession, users);
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
private Map<String, WebhookDeliveryLiteDto> loadLastDeliveriesOf(DbSession dbSession, List<WebhookDto> webhookDtos) {
return dbClient.webhookDeliveryDao().selectLatestDeliveries(dbSession, webhookDtos);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void delete_an_organization_webhook() {
OrganizationDto organization = organizationDbTester.insert();
WebhookDto dto = webhookDbTester.insertWebhook(organization);
webhookDeliveryDbTester.insert(newDto().setWebhookUuid(dto.getUuid()));
webhookDeliveryDbTester.insert(newDto().setWebhookUuid(dto.getUuid()));
userSession.logIn().addPermission(ADMINISTER, organization.getUuid());
TestResponse response = wsActionTester.newRequest()
.setParam(KEY_PARAM, dto.getUuid())
.execute();
assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
assertThat(reloaded).isEmpty();
int deliveriesCount = deliveryDao.countDeliveriesByWebhookUuid(dbSession, dto.getUuid());
assertThat(deliveriesCount).isEqualTo(0);
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
private Data loadFromDatabase(@Nullable String webhookUuid, @Nullable String ceTaskId, @Nullable String componentKey, int page, int pageSize) {
ComponentDto component;
List<WebhookDeliveryLiteDto> deliveries;
int totalElements;
try (DbSession dbSession = dbClient.openSession(false)) {
if (isNotBlank(webhookUuid)) {
totalElements = dbClient.webhookDeliveryDao().countDeliveriesByWebhookUuid(dbSession, webhookUuid);
deliveries = dbClient.webhookDeliveryDao().selectByWebhookUuid(dbSession, webhookUuid, offset(page, pageSize), pageSize);
component = getComponentDto(dbSession, deliveries);
} else if (componentKey != null) {
component = componentFinder.getByKey(dbSession, componentKey);
totalElements = dbClient.webhookDeliveryDao().countDeliveriesByComponentUuid(dbSession, component.uuid());
deliveries = dbClient.webhookDeliveryDao().selectOrderedByComponentUuid(dbSession, component.uuid(), offset(page, pageSize), pageSize);
} else {
totalElements = dbClient.webhookDeliveryDao().countDeliveriesByCeTaskUuid(dbSession, ceTaskId);
deliveries = dbClient.webhookDeliveryDao().selectOrderedByCeTaskUuid(dbSession, ceTaskId, offset(page, pageSize), pageSize);
component = getComponentDto(dbSession, deliveries);
}
}
return new Data(component, deliveries).withPagingInfo(page, pageSize, totalElements);
}
代码示例来源:origin: SonarSource/sonarqube
@SafeVarargs
public final WebhookDeliveryLiteDto insert(Consumer<WebhookDeliveryDto>... dtoPopulators) {
WebhookDeliveryDto dto = newDto();
stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(dto));
dbTester.getDbClient().webhookDeliveryDao().insert(dbTester.getSession(), dto);
dbTester.getSession().commit();
return dto;
}
代码示例来源:origin: SonarSource/sonarqube
private Data loadFromDatabase(String deliveryUuid) {
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<WebhookDeliveryDto> delivery = dbClient.webhookDeliveryDao().selectByUuid(dbSession, deliveryUuid);
checkFoundWithOptional(delivery, "Webhook delivery not found");
ComponentDto component = componentFinder.getByUuid(dbSession, delivery.get().getComponentUuid());
return new Data(component, delivery.get());
}
}
内容来源于网络,如有侵权,请联系作者删除!