gpt4 book ai didi

org.sonar.db.webhook.WebhookDto.getUuid()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 07:45:05 27 4
gpt4 key购买 nike

本文整理了Java中org.sonar.db.webhook.WebhookDto.getUuid()方法的一些代码示例,展示了WebhookDto.getUuid()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebhookDto.getUuid()方法的具体详情如下:
包路径:org.sonar.db.webhook.WebhookDto
类名称:WebhookDto
方法名:getUuid

WebhookDto.getUuid介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

public Map<String, WebhookDeliveryLiteDto> selectLatestDeliveries(DbSession dbSession, List<WebhookDto> webhooks) {
 return webhooks.stream()
  .flatMap(webhook -> selectByWebhookUuid(dbSession, webhook.getUuid(),0,1).stream())
  .collect(toMap(WebhookDeliveryLiteDto::getWebhookUuid, identity()));
}

代码示例来源:origin: SonarSource/sonarqube

public void deleteByWebhook(DbSession dbSession, WebhookDto webhook) {
  mapper(dbSession).deleteByWebhookUuid(webhook.getUuid());
 }
}

代码示例来源:origin: SonarSource/sonarqube

private void deleteWebhook(DbSession dbSession, WebhookDto webhookDto) {
 dbClient.webhookDeliveryDao().deleteByWebhook(dbSession, webhookDto);
 dbClient.webhookDao().delete(dbSession, webhookDto.getUuid());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void selectLatestDelivery_of_a_webhook() {
 WebhookDto webhook1 = dbWebhooks.insert(newProjectWebhook("COMPONENT_1"));
 underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH1-DELIVERY-1-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
 underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH1-DELIVERY-2-UUID", webhook1.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
 WebhookDto webhook2 = dbWebhooks.insert(newProjectWebhook("COMPONENT_1"));
 underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH2-DELIVERY-1-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE));
 underTest.insert(dbSession, WebhookDeliveryTesting.newDto("WH2-DELIVERY-2-UUID", webhook2.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW));
 Map<String, WebhookDeliveryLiteDto> map = underTest.selectLatestDeliveries(dbSession, of(webhook1, webhook2));
 assertThat(map).containsKeys(webhook1.getUuid());
 assertThat(map.get(webhook1.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).contains("WH1-DELIVERY-2-UUID");
 assertThat(map).containsKeys(webhook2.getUuid());
 assertThat(map.get(webhook2.getUuid())).extracting(WebhookDeliveryLiteDto::getUuid).contains("WH2-DELIVERY-2-UUID");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void delete() {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 underTest.delete(dbSession, dto.getUuid());
 Optional<WebhookDto> reloaded = underTest.selectByUuid(dbSession, dto.getUuid());
 assertThat(reloaded).isEmpty();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void update() {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 underTest.update(dbSession, dto.setName("a-fancy-webhook").setUrl("http://www.fancy-webhook.io"));
 WebhookDto reloaded = underTest.selectByUuid(dbSession, dto.getUuid()).get();
 assertThat(reloaded.getUuid()).isEqualTo(dto.getUuid());
 assertThat(reloaded.getName()).isEqualTo("a-fancy-webhook");
 assertThat(reloaded.getUrl()).isEqualTo("http://www.fancy-webhook.io");
 assertThat(reloaded.getProjectUuid()).isNull();
 assertThat(reloaded.getOrganizationUuid()).isEqualTo(dto.getOrganizationUuid());
 assertThat(reloaded.getCreatedAt()).isEqualTo(dto.getCreatedAt());
 assertThat(new Date(reloaded.getUpdatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void insert_row_with_organization() {
 WebhookDto dto = new WebhookDto()
  .setUuid("UUID_1")
  .setName("NAME_1")
  .setUrl("URL_1")
  .setOrganizationUuid("UUID_2");
 underTest.insert(dbSession, dto);
 WebhookDto stored = selectByUuid(dto.getUuid());
 assertThat(stored.getUuid()).isEqualTo(dto.getUuid());
 assertThat(stored.getName()).isEqualTo(dto.getName());
 assertThat(stored.getUrl()).isEqualTo(dto.getUrl());
 assertThat(stored.getOrganizationUuid()).isEqualTo(dto.getOrganizationUuid());
 assertThat(stored.getProjectUuid()).isNull();
 assertThat(new Date(stored.getCreatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
 assertThat(new Date(stored.getUpdatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
}

代码示例来源:origin: SonarSource/sonarqube

private static void writeResponse(Request request, Response response, List<WebhookDto> webhookDtos, Map<String, WebhookDeliveryLiteDto> lastDeliveries) {
 ListResponse.Builder responseBuilder = ListResponse.newBuilder();
 webhookDtos
  .forEach(webhook -> {
   ListResponseElement.Builder responseElementBuilder = responseBuilder.addWebhooksBuilder();
   responseElementBuilder
    .setKey(webhook.getUuid())
    .setName(webhook.getName())
    .setUrl(obfuscateCredentials(webhook.getUrl()));
   addLastDelivery(responseElementBuilder, webhook, lastDeliveries);
  });
 writeProtobuf(responseBuilder.build(), request, response);
}

代码示例来源:origin: SonarSource/sonarqube

@SafeVarargs
public final WebhookDeliveryLiteDto insert(WebhookDto webhook, Consumer<WebhookDeliveryDto>... dtoPopulators) {
 WebhookDeliveryDto dto = newDto();
 stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(dto));
 String projectUuid = webhook.getProjectUuid();
 dto.setComponentUuid(Objects.requireNonNull(projectUuid, "Project uuid of webhook cannot be null"));
 dto.setWebhookUuid(webhook.getUuid());
 dbTester.getDbClient().webhookDeliveryDao().insert(dbTester.getSession(), dto);
 dbTester.getSession().commit();
 return dto;
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void list_webhooks_when_no_delivery() {
 WebhookDto webhook1 = webhookDbTester.insert(newOrganizationWebhook("aaa", defaultOrganizationProvider.get().getUuid()));
 WebhookDto webhook2 = webhookDbTester.insert(newOrganizationWebhook("bbb", defaultOrganizationProvider.get().getUuid()));
 userSession.logIn().addPermission(ADMINISTER, db.getDefaultOrganization().getUuid());
 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).containsExactly(webhook1.getUuid());
 assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).containsExactly("aaa");
 assertThat(elements.get(0).hasLatestDelivery()).isFalse();
 assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getKey).containsExactly(webhook2.getUuid());
 assertThat(elements.get(1)).extracting(Webhooks.ListResponseElement::getName).containsExactly("bbb");
 assertThat(elements.get(1).hasLatestDelivery()).isFalse();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void selectByWebhookUuid_returns_records_ordered_by_date() {
 WebhookDto webhookDto = dbWebhooks.insert(WebhookTesting.newProjectWebhook("COMPONENT_1"));
 WebhookDeliveryDto dto1 = WebhookDeliveryTesting.newDto("D1", webhookDto.getUuid(), "COMPONENT_1", "TASK_1").setCreatedAt(BEFORE);
 WebhookDeliveryDto dto2 = WebhookDeliveryTesting.newDto("D2", webhookDto.getUuid(), "COMPONENT_1", "TASK_2").setCreatedAt(NOW);
 WebhookDeliveryDto dto3 = WebhookDeliveryTesting.newDto("D3", "fake-webhook-uuid", "COMPONENT_2", "TASK_1").setCreatedAt(NOW);
 underTest.insert(dbSession, dto3);
 underTest.insert(dbSession, dto2);
 underTest.insert(dbSession, dto1);
 List<WebhookDeliveryLiteDto> deliveries = underTest.selectByWebhookUuid(dbSession, webhookDto.getUuid(), 0, 10);
 assertThat(deliveries).extracting(WebhookDeliveryLiteDto::getUuid).containsExactly("D2", "D1");
}

代码示例来源:origin: SonarSource/sonarqube

private static void writeResponse(Request request, Response response, WebhookDto element) {
 Webhooks.CreateWsResponse.Builder responseBuilder = newBuilder();
 responseBuilder.setWebhook(Webhook.newBuilder()
  .setKey(element.getUuid())
  .setName(element.getName())
  .setUrl(element.getUrl()));
 writeProtobuf(responseBuilder.build(), request, response);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_not_logged_in() throws Exception {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 userSession.anonymous();
 expectedException.expect(UnauthorizedException.class);
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_no_permission_on_webhook_scope_project() {
 ComponentDto project = componentDbTester.insertPrivateProject();
 WebhookDto dto = webhookDbTester.insertWebhook(project);
 userSession.logIn();
 expectedException.expect(ForbiddenException.class);
 expectedException.expectMessage("Insufficient privileges");
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_no_permission_on_webhook_scope_organization() {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 userSession.logIn();
 expectedException.expect(ForbiddenException.class);
 expectedException.expectMessage("Insufficient privileges");
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_not_logged_in() throws Exception {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 userSession.anonymous();
 expectedException.expect(UnauthorizedException.class);
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, URL_WEBHOOK_EXAMPLE_001)
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_no_permission_on_webhook_scope_organization() {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 userSession.logIn();
 expectedException.expect(ForbiddenException.class);
 expectedException.expectMessage("Insufficient privileges");
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, URL_WEBHOOK_EXAMPLE_001)
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_url_is_not_valid() throws Exception {
 ComponentDto project = componentDbTester.insertPrivateProject();
 WebhookDto dto = webhookDbTester.insertWebhook(project);
 userSession.logIn().addProjectPermission(ADMIN, project);
 expectedException.expect(IllegalArgumentException.class);
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, "htp://www.wrong-protocol.com/")
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_credential_in_url_is_have_a_wrong_format() throws Exception {
 ComponentDto project = componentDbTester.insertPrivateProject();
 WebhookDto dto = webhookDbTester.insertWebhook(project);
 userSession.logIn().addProjectPermission(ADMIN, project);
 expectedException.expect(IllegalArgumentException.class);
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, "http://:www.wrong-protocol.com/")
  .execute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_no_permission_on_webhook_scope_project() {
 ComponentDto project = componentDbTester.insertPrivateProject();
 WebhookDto dto = webhookDbTester.insertWebhook(project);
 userSession.logIn();
 expectedException.expect(ForbiddenException.class);
 expectedException.expectMessage("Insufficient privileges");
 wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, URL_WEBHOOK_EXAMPLE_001)
  .execute();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com