gpt4 book ai didi

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

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

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

WebhookDto.getProjectUuid介绍

暂无

代码示例

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

public void insert(DbSession dbSession, WebhookDto dto) {
 checkState(dto.getOrganizationUuid() != null || dto.getProjectUuid() != null,
  "A webhook can not be created if not linked to an organization or a project.");
 checkState(dto.getOrganizationUuid() == null || dto.getProjectUuid() == null,
  "A webhook can not be linked to both an organization and a project.");
 mapper(dbSession).insert(dto.setCreatedAt(system2.now()).setUpdatedAt(system2.now()));
}

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

@Test
public void update_a_project_webhook() {
 ComponentDto project = componentDbTester.insertPrivateProject();
 WebhookDto dto = webhookDbTester.insertWebhook(project);
 userSession.logIn().addProjectPermission(ADMIN, project);
 TestResponse response = wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, URL_WEBHOOK_EXAMPLE_001)
  .execute();
 assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
 Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
 assertThat(reloaded.get()).isNotNull();
 assertThat(reloaded.get().getName()).isEqualTo(NAME_WEBHOOK_EXAMPLE_001);
 assertThat(reloaded.get().getUrl()).isEqualTo(URL_WEBHOOK_EXAMPLE_001);
 assertThat(reloaded.get().getOrganizationUuid()).isNull();
 assertThat(reloaded.get().getProjectUuid()).isEqualTo(dto.getProjectUuid());
}

代码示例来源: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 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 update_an_organization_webhook() {
 OrganizationDto organization = organizationDbTester.insert();
 WebhookDto dto = webhookDbTester.insertWebhook(organization);
 userSession.logIn().addPermission(ADMINISTER, organization.getUuid());
 TestResponse response = wsActionTester.newRequest()
  .setParam(KEY_PARAM, dto.getUuid())
  .setParam(NAME_PARAM, NAME_WEBHOOK_EXAMPLE_001)
  .setParam(URL_PARAM, URL_WEBHOOK_EXAMPLE_001)
  .execute();
 assertThat(response.getStatus()).isEqualTo(HTTP_NO_CONTENT);
 Optional<WebhookDto> reloaded = webhookDbTester.selectWebhook(dto.getUuid());
 assertThat(reloaded.get()).isNotNull();
 assertThat(reloaded.get().getName()).isEqualTo(NAME_WEBHOOK_EXAMPLE_001);
 assertThat(reloaded.get().getUrl()).isEqualTo(URL_WEBHOOK_EXAMPLE_001);
 assertThat(reloaded.get().getOrganizationUuid()).isEqualTo(dto.getOrganizationUuid());
 assertThat(reloaded.get().getProjectUuid()).isNull();
}

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

@Test
public void insert_row_with_project() {
 WebhookDto dto = new WebhookDto()
  .setUuid("UUID_1")
  .setName("NAME_1")
  .setUrl("URL_1")
  .setProjectUuid("UUID_2");
 underTest.insert(dbSession, dto);
 WebhookDto reloaded = selectByUuid(dto.getUuid());
 assertThat(reloaded.getUuid()).isEqualTo(dto.getUuid());
 assertThat(reloaded.getName()).isEqualTo(dto.getName());
 assertThat(reloaded.getUrl()).isEqualTo(dto.getUrl());
 assertThat(reloaded.getOrganizationUuid()).isNull();
 assertThat(reloaded.getProjectUuid()).isEqualTo(dto.getProjectUuid());
 assertThat(new Date(reloaded.getCreatedAt())).isInSameMinuteWindowAs(new Date(system2.now()));
 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

@Override
public void handle(Request request, Response response) throws Exception {
 userSession.checkLoggedIn();
 String webhookKey = request.param(KEY_PARAM);
 try (DbSession dbSession = dbClient.openSession(false)) {
  Optional<WebhookDto> dtoOptional = dbClient.webhookDao().selectByUuid(dbSession, webhookKey);
  WebhookDto webhookDto = checkFoundWithOptional(dtoOptional, "No webhook with key '%s'", webhookKey);
  String organizationUuid = webhookDto.getOrganizationUuid();
  if (organizationUuid != null) {
   Optional<OrganizationDto> optionalDto = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid);
   OrganizationDto organizationDto = checkStateWithOptional(optionalDto, "the requested organization '%s' was not found", organizationUuid);
   webhookSupport.checkPermission(organizationDto);
   deleteWebhook(dbSession, webhookDto);
  }
  String projectUuid = webhookDto.getProjectUuid();
  if (projectUuid != null) {
   Optional<ComponentDto> optionalDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orElse(null));
   ComponentDto componentDto = checkStateWithOptional(optionalDto, "the requested project '%s' was not found", projectUuid);
   webhookSupport.checkPermission(componentDto);
   deleteWebhook(dbSession, webhookDto);
  }
  dbSession.commit();
 }
 response.noContent();
}

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

@Override
public void handle(Request request, Response response) throws Exception {
 userSession.checkLoggedIn();
 String webhookKey = request.param(KEY_PARAM);
 String name = request.mandatoryParam(NAME_PARAM);
 String url = request.mandatoryParam(URL_PARAM);
 webhookSupport.checkUrlPattern(url, "Url parameter with value '%s' is not a valid url", url);
 try (DbSession dbSession = dbClient.openSession(false)) {
  Optional<WebhookDto> dtoOptional = dbClient.webhookDao().selectByUuid(dbSession, webhookKey);
  WebhookDto webhookDto = checkFoundWithOptional(dtoOptional, "No webhook with key '%s'", webhookKey);
  String organizationUuid = webhookDto.getOrganizationUuid();
  if (organizationUuid != null) {
   Optional<OrganizationDto> optionalDto = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid);
   OrganizationDto organizationDto = checkStateWithOptional(optionalDto, "the requested organization '%s' was not found", organizationUuid);
   webhookSupport.checkPermission(organizationDto);
   updateWebhook(dbSession, webhookDto, name, url);
  }
  String projectUuid = webhookDto.getProjectUuid();
  if (projectUuid != null) {
   Optional<ComponentDto> optionalDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orElse(null));
   ComponentDto componentDto = checkStateWithOptional(optionalDto, "the requested project '%s' was not found", projectUuid);
   webhookSupport.checkPermission(componentDto);
   updateWebhook(dbSession, webhookDto, name, url);
  }
  dbSession.commit();
 }
 response.noContent();
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public void handle(Request request, Response response) throws Exception {
 userSession.checkLoggedIn();
 String webhookKey = request.param(KEY_PARAM);
 try (DbSession dbSession = dbClient.openSession(false)) {
  Optional<WebhookDto> dtoOptional = dbClient.webhookDao().selectByUuid(dbSession, webhookKey);
  WebhookDto webhookDto = checkFoundWithOptional(dtoOptional, "No webhook with key '%s'", webhookKey);
  String organizationUuid = webhookDto.getOrganizationUuid();
  if (organizationUuid != null) {
   Optional<OrganizationDto> optionalDto = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid);
   OrganizationDto organizationDto = checkStateWithOptional(optionalDto, "the requested organization '%s' was not found", organizationUuid);
   webhookSupport.checkPermission(organizationDto);
   deleteWebhook(dbSession, webhookDto);
  }
  String projectUuid = webhookDto.getProjectUuid();
  if (projectUuid != null) {
   Optional<ComponentDto> optionalDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orNull());
   ComponentDto componentDto = checkStateWithOptional(optionalDto, "the requested project '%s' was not found", projectUuid);
   webhookSupport.checkPermission(componentDto);
   deleteWebhook(dbSession, webhookDto);
  }
  dbSession.commit();
 }
 response.noContent();
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public void handle(Request request, Response response) throws Exception {
 userSession.checkLoggedIn();
 String webhookKey = request.param(KEY_PARAM);
 String name = request.mandatoryParam(NAME_PARAM);
 String url = request.mandatoryParam(URL_PARAM);
 webhookSupport.checkUrlPattern(url, "Url parameter with value '%s' is not a valid url", url);
 try (DbSession dbSession = dbClient.openSession(false)) {
  Optional<WebhookDto> dtoOptional = dbClient.webhookDao().selectByUuid(dbSession, webhookKey);
  WebhookDto webhookDto = checkFoundWithOptional(dtoOptional, "No webhook with key '%s'", webhookKey);
  String organizationUuid = webhookDto.getOrganizationUuid();
  if (organizationUuid != null) {
   Optional<OrganizationDto> optionalDto = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid);
   OrganizationDto organizationDto = checkStateWithOptional(optionalDto, "the requested organization '%s' was not found", organizationUuid);
   webhookSupport.checkPermission(organizationDto);
   updateWebhook(dbSession, webhookDto, name, url);
  }
  String projectUuid = webhookDto.getProjectUuid();
  if (projectUuid != null) {
   Optional<ComponentDto> optionalDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orNull());
   ComponentDto componentDto = checkStateWithOptional(optionalDto, "the requested project '%s' was not found", projectUuid);
   webhookSupport.checkPermission(componentDto);
   updateWebhook(dbSession, webhookDto, name, url);
  }
  dbSession.commit();
 }
 response.noContent();
}

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