Search in sources :

Example 6 with ListResponse

use of org.sonarqube.ws.Webhooks.ListResponse in project sonarqube by SonarSource.

the class ListActionTest method list_webhooks_when_no_delivery.

@Test
public void list_webhooks_when_no_delivery() {
    WebhookDto webhook1 = webhookDbTester.insert(newGlobalWebhook("aaa"), null, null);
    WebhookDto webhook2 = webhookDbTester.insert(newGlobalWebhook("bbb"), null, null);
    userSession.logIn().addPermission(ADMINISTER);
    ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
    List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
    assertThat(elements.size()).isEqualTo(2);
    assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid());
    assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa");
    assertThat(elements.get(0).hasLatestDelivery()).isFalse();
    assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook2.getUuid());
    assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("bbb");
    assertThat(elements.get(1).hasLatestDelivery()).isFalse();
}
Also used : WebhookDto(org.sonar.db.webhook.WebhookDto) ListResponse(org.sonarqube.ws.Webhooks.ListResponse) Webhooks(org.sonarqube.ws.Webhooks) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 WebhookDto (org.sonar.db.webhook.WebhookDto)6 Webhooks (org.sonarqube.ws.Webhooks)6 ListResponse (org.sonarqube.ws.Webhooks.ListResponse)6 ProjectDto (org.sonar.db.project.ProjectDto)2 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 AssertionsForClassTypes.tuple (org.assertj.core.api.AssertionsForClassTypes.tuple)1 Rule (org.junit.Rule)1 Mockito.mock (org.mockito.Mockito.mock)1 Configuration (org.sonar.api.config.Configuration)1 ResourceTypes (org.sonar.api.resources.ResourceTypes)1 WebService (org.sonar.api.server.ws.WebService)1 Param (org.sonar.api.server.ws.WebService.Param)1 ADMIN (org.sonar.api.web.UserRole.ADMIN)1 DbClient (org.sonar.db.DbClient)1 DbTester (org.sonar.db.DbTester)1 DbTester.create (org.sonar.db.DbTester.create)1 ComponentDbTester (org.sonar.db.component.ComponentDbTester)1