Search in sources :

Example 16 with WebhookDeliveryDto

use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.

the class WebhookDeliveryStorageTest method persist_effective_url_if_present.

@Test
public void persist_effective_url_if_present() {
    when(uuidFactory.create()).thenReturn(DELIVERY_UUID);
    String effectiveUrl = randomAlphabetic(15);
    WebhookDelivery delivery = newBuilderTemplate().setEffectiveUrl(effectiveUrl).build();
    underTest.persist(delivery);
    WebhookDeliveryDto dto = dbClient.webhookDeliveryDao().selectByUuid(dbSession, DELIVERY_UUID).get();
    assertThat(dto.getUrl()).isEqualTo(effectiveUrl);
}
Also used : WebhookDeliveryDto(org.sonar.db.webhook.WebhookDeliveryDto) Test(org.junit.Test)

Example 17 with WebhookDeliveryDto

use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.

the class WebhookDeliveryAction method loadFromDatabase.

private Data loadFromDatabase(String deliveryUuid) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        WebhookDeliveryDto delivery = dbClient.webhookDeliveryDao().selectByUuid(dbSession, deliveryUuid).orElseThrow(() -> new NotFoundException("Webhook delivery not found"));
        ProjectDto project = componentFinder.getProjectByUuid(dbSession, delivery.getComponentUuid());
        return new Data(project, delivery);
    }
}
Also used : ProjectDto(org.sonar.db.project.ProjectDto) DbSession(org.sonar.db.DbSession) WebhookDeliveryDto(org.sonar.db.webhook.WebhookDeliveryDto) NotFoundException(org.sonar.server.exceptions.NotFoundException)

Aggregations

WebhookDeliveryDto (org.sonar.db.webhook.WebhookDeliveryDto)17 Test (org.junit.Test)14 Webhooks (org.sonarqube.ws.Webhooks)4 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)3 Throwables (com.google.common.base.Throwables)2 IOException (java.io.IOException)2 WebhookDbTesting.newWebhookDeliveryDto (org.sonar.db.webhook.WebhookDbTesting.newWebhookDeliveryDto)2 TestRequest (org.sonar.server.ws.TestRequest)2 DbSession (org.sonar.db.DbSession)1 ProjectDto (org.sonar.db.project.ProjectDto)1 NotFoundException (org.sonar.server.exceptions.NotFoundException)1