aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorGuillaume Jambet <guillaume.jambet@sonarsource.com>2018-02-08 15:50:43 +0100
committerGuillaume Jambet <guillaume.jambet@gmail.com>2018-03-01 15:21:05 +0100
commita5a65a2c81c6f44b1eb37d5630bd37ffb46c085a (patch)
tree95a1881d785bd678cdee65a0faeefd9c8562a3db /server/sonar-db-dao
parent07a20e83c4037ab7853c57aa92e614d47be74cf4 (diff)
downloadsonarqube-a5a65a2c81c6f44b1eb37d5630bd37ffb46c085a.tar.gz
sonarqube-a5a65a2c81c6f44b1eb37d5630bd37ffb46c085a.zip
SONAR-10345 Add Webhooks delete ws
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java5
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java11
4 files changed, 23 insertions, 1 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java
index b972edbe665..0711adecf5c 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookDao.java
@@ -63,8 +63,11 @@ public class WebhookDao implements Dao {
mapper(dbSession).update(dto.setUpdatedAt(system2.now()));
}
+ public void delete(DbSession dbSession, String uuid) {
+ mapper(dbSession).delete(uuid);
+ }
+
private static WebhookMapper mapper(DbSession dbSession) {
return dbSession.getMapper(WebhookMapper.class);
}
-
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java
index 3b5706c62bc..354f0d2de5d 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/webhook/WebhookMapper.java
@@ -36,4 +36,6 @@ public interface WebhookMapper {
void update(WebhookDto dto);
+ void delete(@Param("uuid") String uuid);
+
}
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
index 0eb69994650..33171e72276 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/webhook/WebhookMapper.xml
@@ -63,4 +63,10 @@
where uuid=#{uuid, jdbcType=VARCHAR}
</update>
+ <delete id="delete" parameterType="String">
+ delete from webhooks
+ where
+ uuid = #{uuid,jdbcType=VARCHAR}
+ </delete>
+
</mapper>
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java
index 01e8ef62225..2dafd3b90a9 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoTest.java
@@ -116,6 +116,17 @@ public class WebhookDaoTest {
assertThat(new Date(reloaded.getUpdatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
}
+ @Test
+ public void delete() {
+
+ OrganizationDto organization = organizationDbTester.insert();
+ WebhookDto dto = webhookDbTester.insertForOrganizationUuid(organization.getUuid());
+
+ underTest.delete(dbSession, dto.getUuid());
+
+ Optional<WebhookDto> reloaded = underTest.selectByUuid(dbSession, dto.uuid);
+ assertThat(reloaded).isEmpty();
+ }
@Test
public void fail_if_webhook_does_not_have_an_organization_nor_a_project() {