@@ -34,10 +34,6 @@ public class WebhookDao implements Dao { | |||
this.system2 = system2; | |||
} | |||
public List<WebhookDto> selectAll(DbSession dbSession) { | |||
return mapper(dbSession).selectAllOrderedByName(); | |||
} | |||
public List<WebhookDto> selectGlobalWebhooks(DbSession dbSession) { | |||
return mapper(dbSession).selectGlobalWebhooksOrderedByName(); | |||
} |
@@ -28,8 +28,6 @@ public interface WebhookMapper { | |||
@CheckForNull | |||
WebhookDto selectByUuid(@Param("webhookUuid") String webhookUuid); | |||
List<WebhookDto> selectAllOrderedByName(); | |||
List<WebhookDto> selectGlobalWebhooksOrderedByName(); | |||
List<WebhookDto> selectForProjectUuidOrderedByName(@Param("projectUuid") String projectUuid); |
@@ -20,12 +20,6 @@ | |||
where uuid = #{webhookUuid,jdbcType=VARCHAR} | |||
</select> | |||
<select id="selectAllOrderedByName" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto"> | |||
select <include refid="sqlColumns" /> | |||
from webhooks | |||
order by name asc | |||
</select> | |||
<select id="selectGlobalWebhooksOrderedByName" parameterType="String" resultType="org.sonar.db.webhook.WebhookDto"> | |||
select <include refid="sqlColumns" /> | |||
from webhooks |
@@ -50,26 +50,6 @@ public class WebhookDaoTest { | |||
assertThat(underTest.selectByUuid(dbSession, "missing")).isEmpty(); | |||
} | |||
@Test | |||
public void select_all_webhooks() { | |||
ProjectDto projectDto = componentDbTester.insertPrivateProjectDto(); | |||
webhookDbTester.insertGlobalWebhook(); | |||
webhookDbTester.insertGlobalWebhook(); | |||
webhookDbTester.insertWebhook(projectDto); | |||
webhookDbTester.insertWebhook(projectDto); | |||
List<WebhookDto> results = underTest.selectAll(dbSession); | |||
assertThat(results).hasSize(4); | |||
} | |||
@Test | |||
public void select_all_webhooks_returns_empty_list_if_there_are_no_webhooks() { | |||
List<WebhookDto> results = underTest.selectAll(dbSession); | |||
assertThat(results).isEmpty(); | |||
} | |||
@Test | |||
public void select_global_webhooks() { | |||
ProjectDto projectDto = componentDbTester.insertPrivateProjectDto(); |
@@ -101,7 +101,7 @@ public class ListAction implements WebhooksWsAction { | |||
return dbClient.webhookDao().selectByProject(dbSession, projectDto); | |||
} else { | |||
webhookSupport.checkPermission(); | |||
return dbClient.webhookDao().selectAll(dbSession); | |||
return dbClient.webhookDao().selectGlobalWebhooks(dbSession); | |||
} | |||
} | |||
@@ -168,6 +168,9 @@ public class ListActionTest { | |||
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() | |||
@@ -175,7 +178,7 @@ public class ListActionTest { | |||
assertThat(response.getWebhooksList()) | |||
.extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl) | |||
.contains(tuple(dto1.getName(), dto1.getUrl()), | |||
.containsExactlyInAnyOrder(tuple(dto1.getName(), dto1.getUrl()), | |||
tuple(dto2.getName(), dto2.getUrl())); | |||
} |