use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class ListActionTest method list_global_webhooks.
@Test
public void list_global_webhooks() {
WebhookDto dto1 = webhookDbTester.insertGlobalWebhook();
WebhookDto dto2 = webhookDbTester.insertGlobalWebhook();
// insert a project-specific webhook, that should not be returned when listing global webhooks
webhookDbTester.insertWebhook(componentDbTester.insertPrivateProjectDto());
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
assertThat(response.getWebhooksList()).extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl).containsExactlyInAnyOrder(tuple(dto1.getName(), dto1.getUrl()), tuple(dto2.getName(), dto2.getUrl()));
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class ListActionTest method list_project_webhooks_when_project_key_param_is_provided.
@Test
public void list_project_webhooks_when_project_key_param_is_provided() {
ProjectDto project1 = componentDbTester.insertPrivateProjectDto();
userSession.logIn().addProjectPermission(ADMIN, project1);
WebhookDto dto1 = webhookDbTester.insertWebhook(project1);
WebhookDto dto2 = webhookDbTester.insertWebhook(project1);
ListResponse response = wsActionTester.newRequest().setParam(PROJECT_KEY_PARAM, project1.getKey()).executeProtobuf(ListResponse.class);
assertThat(response.getWebhooksList()).extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl).contains(tuple(dto1.getName(), dto1.getUrl()), tuple(dto2.getName(), dto2.getUrl()));
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class PurgeDaoTest method delete_webhooks_from_project.
@Test
public void delete_webhooks_from_project() {
ProjectDto project1 = db.components().insertPrivateProjectDto();
WebhookDto webhook = db.webhooks().insertWebhook(project1);
db.webhookDelivery().insert(webhook);
ProjectDto projectNotToBeDeleted = db.components().insertPrivateProjectDto();
WebhookDto webhookNotDeleted = db.webhooks().insertWebhook(projectNotToBeDeleted);
WebhookDeliveryLiteDto webhookDeliveryNotDeleted = db.webhookDelivery().insert(webhookNotDeleted);
underTest.deleteProject(dbSession, project1.getUuid(), project1.getQualifier(), project1.getName(), project1.getKey());
assertThat(uuidsIn("webhooks")).containsOnly(webhookNotDeleted.getUuid());
assertThat(uuidsIn("webhook_deliveries")).containsOnly(webhookDeliveryNotDeleted.getUuid());
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class ListActionTest method list_webhooks_and_their_latest_delivery.
@Test
public void list_webhooks_and_their_latest_delivery() {
WebhookDto webhook1 = webhookDbTester.insert(newGlobalWebhook("aaa"), null, null);
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-1-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
webhookDeliveryDbTester.insert(newDto("WH1-DELIVERY-2-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
WebhookDto webhook2 = webhookDbTester.insert(newGlobalWebhook("bbb"), null, null);
webhookDeliveryDbTester.insert(newDto("WH2-DELIVERY-1-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
webhookDeliveryDbTester.insert(newDto("WH2-DELIVERY-2-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
assertThat(elements.size()).isEqualTo(2);
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid());
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa");
assertThat(elements.get(0).getLatestDelivery()).isNotNull();
assertThat(elements.get(0).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).isEqualTo("WH1-DELIVERY-2-UUID");
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook2.getUuid());
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("bbb");
assertThat(elements.get(1).getLatestDelivery()).isNotNull();
assertThat(elements.get(1).getLatestDelivery()).extracting(Webhooks.LatestDelivery::getId).isEqualTo("WH2-DELIVERY-2-UUID");
}
use of org.sonar.db.webhook.WebhookDto in project sonarqube by SonarSource.
the class ListActionTest method list_webhooks_when_no_delivery.
@Test
public void list_webhooks_when_no_delivery() {
WebhookDto webhook1 = webhookDbTester.insert(newGlobalWebhook("aaa"), null, null);
WebhookDto webhook2 = webhookDbTester.insert(newGlobalWebhook("bbb"), null, null);
userSession.logIn().addPermission(ADMINISTER);
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
assertThat(elements.size()).isEqualTo(2);
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid());
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa");
assertThat(elements.get(0).hasLatestDelivery()).isFalse();
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook2.getUuid());
assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("bbb");
assertThat(elements.get(1).hasLatestDelivery()).isFalse();
}
Aggregations