From ba7e66a7f6e96c685a25dfc2def404841b7741f6 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 9 Nov 2016 23:56:12 +0100 Subject: [PATCH] SONAR-8353 add WebhookDeliveryDao --- .../ComputeEngineContainerImplTest.java | 2 +- .../src/main/java/org/sonar/db/DaoModule.java | 4 +- .../src/main/java/org/sonar/db/DbClient.java | 7 + .../src/main/java/org/sonar/db/MyBatis.java | 4 +- .../sonar/db/webhook/WebhookDeliveryDao.java | 42 ++++++ .../sonar/db/webhook/WebhookDeliveryDto.java | 66 ++++++++ .../db/webhook/WebhookDeliveryLiteDto.java | 142 ++++++++++++++++++ .../db/webhook/WebhookDeliveryMapper.java | 33 ++++ .../org/sonar/db/webhook/package-info.java | 24 +++ .../db/webhook/WebhookDeliveryMapper.xml | 58 +++++++ .../test/java/org/sonar/db/DaoModuleTest.java | 2 +- .../db/webhook/WebhookDeliveryDaoTest.java | 131 ++++++++++++++++ 12 files changed, 511 insertions(+), 4 deletions(-) create mode 100644 sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java create mode 100644 sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDto.java create mode 100644 sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryLiteDto.java create mode 100644 sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryMapper.java create mode 100644 sonar-db/src/main/java/org/sonar/db/webhook/package-info.java create mode 100644 sonar-db/src/main/resources/org/sonar/db/webhook/WebhookDeliveryMapper.xml create mode 100644 sonar-db/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index b9b59c7dc48..d070de48002 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -106,7 +106,7 @@ public class ComputeEngineContainerImplTest { assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + 25 // level 1 - + 46 // content of DaoModule + + 47 // content of DaoModule + 2 // content of EsSearchModule + 62 // content of CorePropertyDefinitions + 1 // content of CePropertyDefinitions diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java index 76ac3cb5f18..dcd9b568e2d 100644 --- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java +++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java @@ -66,6 +66,7 @@ import org.sonar.db.user.RoleDao; import org.sonar.db.user.UserDao; import org.sonar.db.user.UserGroupDao; import org.sonar.db.user.UserTokenDao; +import org.sonar.db.webhook.WebhookDeliveryDao; public class DaoModule extends Module { private static final List> classes = ImmutableList.>builder().add( @@ -112,7 +113,8 @@ public class DaoModule extends Module { UserDao.class, UserGroupDao.class, UserPermissionDao.class, - UserTokenDao.class).build(); + UserTokenDao.class, + WebhookDeliveryDao.class).build(); @Override protected void configureModule() { diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java index 1db3feefa48..02744a29ec1 100644 --- a/sonar-db/src/main/java/org/sonar/db/DbClient.java +++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java @@ -66,6 +66,7 @@ import org.sonar.db.user.RoleDao; import org.sonar.db.user.UserDao; import org.sonar.db.user.UserGroupDao; import org.sonar.db.user.UserTokenDao; +import org.sonar.db.webhook.WebhookDeliveryDao; public class DbClient { @@ -115,6 +116,7 @@ public class DbClient { private final ActiveRuleDao activeRuleDao; private final QProfileChangeDao qProfileChangeDao; private final UserPermissionDao userPermissionDao; + private final WebhookDeliveryDao webhookDeliveryDao; public DbClient(Database database, MyBatis myBatis, Dao... daos) { this.database = database; @@ -168,6 +170,7 @@ public class DbClient { activeRuleDao = getDao(map, ActiveRuleDao.class); qProfileChangeDao = getDao(map, QProfileChangeDao.class); userPermissionDao = getDao(map, UserPermissionDao.class); + webhookDeliveryDao = getDao(map, WebhookDeliveryDao.class); } public DbSession openSession(boolean batch) { @@ -358,6 +361,10 @@ public class DbClient { return userPermissionDao; } + public WebhookDeliveryDao webhookDeliveryDao() { + return webhookDeliveryDao; + } + protected K getDao(Map map, Class clazz) { return (K) map.get(clazz); } diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java index cc9b6a98df9..f25bae7c0b2 100644 --- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java +++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java @@ -122,6 +122,7 @@ import org.sonar.db.version.SchemaMigrationMapper; import org.sonar.db.version.v45.Migration45Mapper; import org.sonar.db.version.v50.Migration50Mapper; import org.sonar.db.version.v53.Migration53Mapper; +import org.sonar.db.webhook.WebhookDeliveryMapper; public class MyBatis { @@ -248,7 +249,8 @@ public class MyBatis { UserGroupMapper.class, UserMapper.class, UserPermissionMapper.class, - UserTokenMapper.class + UserTokenMapper.class, + WebhookDeliveryMapper.class }; confBuilder.loadMappers(mappers); diff --git a/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java new file mode 100644 index 00000000000..69af1576d22 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDao.java @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.webhook; + +import java.util.Optional; +import org.sonar.db.Dao; +import org.sonar.db.DbSession; + +public class WebhookDeliveryDao implements Dao { + + public Optional selectByUuid(DbSession dbSession, String uuid) { + return Optional.ofNullable(mapper(dbSession).selectByUuid(uuid)); + } + public void insert(DbSession dbSession, WebhookDeliveryDto dto) { + mapper(dbSession).insert(dto); + } + + public void deleteComponentBeforeDate(DbSession dbSession, String componentUuid, long beforeDate) { + mapper(dbSession).deleteComponentBeforeDate(componentUuid, beforeDate); + } + + private static WebhookDeliveryMapper mapper(DbSession dbSession) { + return dbSession.getMapper(WebhookDeliveryMapper.class); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDto.java b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDto.java new file mode 100644 index 00000000000..75378b2b067 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryDto.java @@ -0,0 +1,66 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.webhook; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class WebhookDeliveryDto extends WebhookDeliveryLiteDto { + /** Error message if HTTP request cannot be sent, else null */ + private String errorStacktrace; + /** The payload that has been sent, cannot be null */ + private String payload; + + @CheckForNull + public String getErrorStacktrace() { + return errorStacktrace; + } + + public WebhookDeliveryDto setErrorStacktrace(@Nullable String s) { + this.errorStacktrace = s; + return this; + } + + @CheckForNull + public String getPayload() { + return payload; + } + + public WebhookDeliveryDto setPayload(@Nullable String s) { + this.payload = s; + return this; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("uuid", uuid) + .append("componentUuid", componentUuid) + .append("name", name) + .append("success", success) + .append("httpStatus", httpStatus) + .append("durationMs", durationMs) + .append("url", url) + .append("createdAt", createdAt) + .append("errorStacktrace", errorStacktrace) + .toString(); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryLiteDto.java b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryLiteDto.java new file mode 100644 index 00000000000..b6b510d2dec --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryLiteDto.java @@ -0,0 +1,142 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.webhook; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; +import org.apache.commons.lang.builder.ToStringBuilder; + +public class WebhookDeliveryLiteDto { + /** Technical unique identifier, can't be null */ + protected String uuid; + /** Component UUID, can't be null */ + protected String componentUuid; + /** Compute Engine task UUID, can't be null */ + protected String ceTaskUuid; + /** Name, can't be null */ + protected String name; + protected boolean success; + /** HTTP response status. Null if HTTP request cannot be sent */ + protected Integer httpStatus; + /** Duration in ms. Null if HTTP request cannot be sent */ + protected Integer durationMs; + /** URL, cannot be null */ + protected String url; + /** Time of delivery */ + protected long createdAt; + + public String getUuid() { + return uuid; + } + + public T setUuid(String s) { + this.uuid = s; + return (T)this; + } + + public String getComponentUuid() { + return componentUuid; + } + + public T setComponentUuid(String s) { + this.componentUuid = s; + return (T)this; + } + + public String getCeTaskUuid() { + return ceTaskUuid; + } + + public T setCeTaskUuid(String s) { + this.ceTaskUuid = s; + return (T)this; + } + + public String getName() { + return name; + } + + public T setName(String s) { + this.name = s; + return (T)this; + } + + public boolean isSuccess() { + return success; + } + + public T setSuccess(boolean b) { + this.success = b; + return (T)this; + } + + @CheckForNull + public Integer getHttpStatus() { + return httpStatus; + } + + public T setHttpStatus(@Nullable Integer i) { + this.httpStatus = i; + return (T)this; + } + + @CheckForNull + public Integer getDurationMs() { + return durationMs; + } + + public T setDurationMs(@Nullable Integer i) { + this.durationMs = i; + return (T)this; + } + + public String getUrl() { + return url; + } + + public T setUrl(String s) { + this.url = s; + return (T)this; + } + + public long getCreatedAt() { + return createdAt; + } + + public T setCreatedAt(long l) { + this.createdAt = l; + return (T)this; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("uuid", uuid) + .append("componentUuid", componentUuid) + .append("ceTaskUuid", ceTaskUuid) + .append("name", name) + .append("success", success) + .append("httpStatus", httpStatus) + .append("durationMs", durationMs) + .append("url", url) + .append("createdAt", createdAt) + .toString(); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryMapper.java b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryMapper.java new file mode 100644 index 00000000000..0d39cc3bfe0 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/webhook/WebhookDeliveryMapper.java @@ -0,0 +1,33 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.webhook; + +import javax.annotation.CheckForNull; +import org.apache.ibatis.annotations.Param; + +public interface WebhookDeliveryMapper { + + @CheckForNull + WebhookDeliveryDto selectByUuid(@Param("uuid") String uuid); + + void insert(WebhookDeliveryDto dto); + + void deleteComponentBeforeDate(@Param("componentUuid") String componentUuid, @Param("beforeDate") long beforeDate); +} diff --git a/sonar-db/src/main/java/org/sonar/db/webhook/package-info.java b/sonar-db/src/main/java/org/sonar/db/webhook/package-info.java new file mode 100644 index 00000000000..9e3b24e5bc8 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/webhook/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.db.webhook; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/resources/org/sonar/db/webhook/WebhookDeliveryMapper.xml b/sonar-db/src/main/resources/org/sonar/db/webhook/WebhookDeliveryMapper.xml new file mode 100644 index 00000000000..ac90c321045 --- /dev/null +++ b/sonar-db/src/main/resources/org/sonar/db/webhook/WebhookDeliveryMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + insert into webhook_deliveries ( + uuid, + component_uuid, + ce_task_uuid, + name, + url, + success, + http_status, + duration_ms, + payload, + error_stacktrace, + created_at + ) values ( + #{uuid,jdbcType=VARCHAR}, + #{componentUuid,jdbcType=VARCHAR}, + #{ceTaskUuid,jdbcType=VARCHAR}, + #{name,jdbcType=VARCHAR}, + #{url,jdbcType=VARCHAR}, + #{success,jdbcType=BOOLEAN}, + #{httpStatus,jdbcType=INTEGER}, + #{durationMs,jdbcType=INTEGER}, + #{payload,jdbcType=VARCHAR}, + #{errorStacktrace,jdbcType=VARCHAR}, + #{createdAt,jdbcType=TIMESTAMP} + ) + + + + delete from webhook_deliveries + where + component_uuid = #{componentUuid,jdbcType=VARCHAR} and + created_at < #{beforeDate,jdbcType=BIGINT} + + diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java index 5ccd64f9158..e666e3a2435 100644 --- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java @@ -29,6 +29,6 @@ public class DaoModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new DaoModule().configure(container); - assertThat(container.size()).isEqualTo(2 + 44); + assertThat(container.size()).isEqualTo(2 + 45); } } diff --git a/sonar-db/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java b/sonar-db/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java new file mode 100644 index 00000000000..96f36540154 --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java @@ -0,0 +1,131 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.webhook; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbClient; +import org.sonar.db.DbSession; +import org.sonar.db.DbTester; + +import static org.assertj.core.api.Assertions.assertThat; + + +public class WebhookDeliveryDaoTest { + + private static final long DATE_1 = 1_999_000L; + + @Rule + public final DbTester dbTester = DbTester.create(System2.INSTANCE).setDisableDefaultOrganization(true); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private final DbClient dbClient = dbTester.getDbClient(); + private final DbSession dbSession = dbTester.getSession(); + private final WebhookDeliveryDao underTest = dbClient.webhookDeliveryDao(); + + @Test + public void insert_row_with_only_mandatory_columns() { + WebhookDeliveryDto dto = newDto("DELIVERY_1", "COMPONENT_1", "TASK_1"); + + underTest.insert(dbSession, dto); + + WebhookDeliveryDto stored = selectByUuid(dto.getUuid()); + verifyMandatoryFields(dto, stored); + + // optional fields are null + assertThat(stored.getHttpStatus()).isNull(); + assertThat(stored.getDurationMs()).isNull(); + assertThat(stored.getErrorStacktrace()).isNull(); + } + + @Test + public void insert_row_with_all_columns() { + WebhookDeliveryDto dto = newDto("DELIVERY_1", "COMPONENT_1", "TASK_1") + .setDurationMs(10000) + .setHttpStatus(200) + .setErrorStacktrace("timeout") + .setPayload("{json}"); + + underTest.insert(dbSession, dto); + + WebhookDeliveryDto stored = selectByUuid(dto.getUuid()); + verifyMandatoryFields(dto, stored); + assertThat(stored.getHttpStatus()).isEqualTo(dto.getHttpStatus()); + assertThat(stored.getDurationMs()).isEqualTo(dto.getDurationMs()); + assertThat(stored.getErrorStacktrace()).isEqualTo(dto.getErrorStacktrace()); + } + + @Test + public void delete_rows_before_date() { + underTest.insert(dbSession, newDto("DELIVERY_1", "COMPONENT_1", "TASK_1").setCreatedAt(1_000_000L)); + underTest.insert(dbSession, newDto("DELIVERY_2", "COMPONENT_1", "TASK_2").setCreatedAt(2_000_000L)); + underTest.insert(dbSession, newDto("DELIVERY_3", "COMPONENT_2", "TASK_3").setCreatedAt(1_000_000L)); + + // should delete the old delivery on COMPONENT_1 and keep the one of COMPONENT_2 + underTest.deleteComponentBeforeDate(dbSession, "COMPONENT_1", 1_500_000L); + + List uuids = dbTester.select(dbSession, "select uuid as \"uuid\" from webhook_deliveries") + .stream() + .map(columns -> columns.get("uuid")) + .collect(Collectors.toList()); + assertThat(uuids).containsOnly("DELIVERY_2", "DELIVERY_3"); + + } + + private void verifyMandatoryFields(WebhookDeliveryDto expected, WebhookDeliveryDto actual) { + assertThat(actual.getUuid()).isEqualTo(expected.getUuid()); + assertThat(actual.getComponentUuid()).isEqualTo(expected.getComponentUuid()); + assertThat(actual.getCeTaskUuid()).isEqualTo(expected.getCeTaskUuid()); + assertThat(actual.getName()).isEqualTo(expected.getName()); + assertThat(actual.getUrl()).isEqualTo(expected.getUrl()); + assertThat(actual.isSuccess()).isEqualTo(expected.isSuccess()); + assertThat(actual.getPayload()).isEqualTo(expected.getPayload()); + assertThat(actual.getCreatedAt()).isEqualTo(expected.getCreatedAt()); + } + + /** + * Build a {@link WebhookDeliveryDto} with all mandatory fields. + * Optional fields are kept null. + */ + private static WebhookDeliveryDto newDto(String uuid, String componentUuid, String ceTaskUuid) { + return new WebhookDeliveryDto() + .setUuid(uuid) + .setComponentUuid(componentUuid) + .setCeTaskUuid(ceTaskUuid) + .setName("Jenkins") + .setUrl("http://jenkins") + .setSuccess(true) + .setPayload("{json}") + .setCreatedAt(DATE_1); + } + + private WebhookDeliveryDto selectByUuid(String uuid) { + Optional dto = underTest.selectByUuid(dbSession, uuid); + assertThat(dto).isPresent(); + return dto.get(); + } +}