use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.
the class WebhookDeliveryStorageTest method persist_error_stacktrace.
@Test
public void persist_error_stacktrace() {
when(uuidFactory.create()).thenReturn(DELIVERY_UUID);
WebhookDelivery delivery = newBuilderTemplate().setError(new IOException("fail to connect")).build();
underTest.persist(delivery);
WebhookDeliveryDto dto = dbClient.webhookDeliveryDao().selectByUuid(dbSession, DELIVERY_UUID).get();
assertThat(dto.getErrorStacktrace()).contains("java.io.IOException", "fail to connect");
}
use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.
the class WebhookDeliveryStorageTest method persist_error_stacktrace.
@Test
public void persist_error_stacktrace() {
when(uuidFactory.create()).thenReturn(DELIVERY_UUID);
WebhookDelivery delivery = newBuilderTemplate().setError(new IOException("fail to connect")).build();
underTest.persist(delivery);
WebhookDeliveryDto dto = dbClient.webhookDeliveryDao().selectByUuid(dbSession, DELIVERY_UUID).get();
assertThat(dto.getErrorStacktrace()).contains("java.io.IOException", "fail to connect");
}
use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.
the class WebhookDeliveriesActionTest method search_by_component_and_return_records_of_example.
@Test
public void search_by_component_and_return_records_of_example() {
WebhookDeliveryDto dto = newDto().setUuid("d1").setComponentUuid(project.uuid()).setCeTaskUuid("task-1").setName("Jenkins").setUrl("http://jenkins").setCreatedAt(1_500_000_000_000L).setSuccess(true).setDurationMs(10).setHttpStatus(200);
dbClient.webhookDeliveryDao().insert(db.getSession(), dto);
db.commit();
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
String json = ws.newRequest().setParam("componentKey", project.getDbKey()).execute().getInput();
assertJson(json).isSimilarTo(ws.getDef().responseExampleAsString());
}
use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.
the class WebhookDeliveriesActionTest method search_by_task_and_return_records.
@Test
public void search_by_task_and_return_records() {
WebhookDeliveryDto dto1 = newDto().setComponentUuid(project.uuid()).setCeTaskUuid("t1");
WebhookDeliveryDto dto2 = newDto().setComponentUuid(project.uuid()).setCeTaskUuid("t1");
WebhookDeliveryDto dto3 = newDto().setComponentUuid(project.uuid()).setCeTaskUuid("t2");
dbClient.webhookDeliveryDao().insert(db.getSession(), dto1);
dbClient.webhookDeliveryDao().insert(db.getSession(), dto2);
dbClient.webhookDeliveryDao().insert(db.getSession(), dto3);
db.commit();
userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
Webhooks.DeliveriesWsResponse response = ws.newRequest().setParam("ceTaskId", "t1").executeProtobuf(Webhooks.DeliveriesWsResponse.class);
assertThat(response.getDeliveriesCount()).isEqualTo(2);
assertThat(response.getDeliveriesList()).extracting(Webhooks.Delivery::getId).containsOnly(dto1.getUuid(), dto2.getUuid());
}
use of org.sonar.db.webhook.WebhookDeliveryDto in project sonarqube by SonarSource.
the class WebhookDeliveriesActionTest method search_by_task_and_throw_ForbiddenException_if_not_admin_of_project.
@Test
public void search_by_task_and_throw_ForbiddenException_if_not_admin_of_project() {
WebhookDeliveryDto dto = newDto().setComponentUuid(project.uuid());
dbClient.webhookDeliveryDao().insert(db.getSession(), dto);
db.commit();
userSession.logIn().addProjectPermission(UserRole.USER, project);
TestRequest request = ws.newRequest().setParam("ceTaskId", dto.getCeTaskUuid());
assertThatThrownBy(request::execute).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
}
Aggregations