Search in sources :

Example 1 with Throwables

use of com.google.common.base.Throwables in project sonarqube by SonarSource.

the class WebhookDeliveryStorage method toDto.

private WebhookDeliveryDto toDto(WebhookDelivery delivery) {
    WebhookDeliveryDto dto = new WebhookDeliveryDto();
    dto.setUuid(uuidFactory.create());
    dto.setComponentUuid(delivery.getWebhook().getComponentUuid());
    dto.setCeTaskUuid(delivery.getWebhook().getCeTaskUuid());
    dto.setName(delivery.getWebhook().getName());
    dto.setUrl(delivery.getWebhook().getUrl());
    dto.setSuccess(delivery.isSuccess());
    dto.setHttpStatus(delivery.getHttpStatus().orElse(null));
    dto.setDurationMs(delivery.getDurationInMs().orElse(null));
    dto.setErrorStacktrace(delivery.getError().map(Throwables::getStackTraceAsString).orElse(null));
    dto.setPayload(delivery.getPayload().getJson());
    dto.setCreatedAt(delivery.getAt());
    return dto;
}
Also used : WebhookDeliveryDto(org.sonar.db.webhook.WebhookDeliveryDto) Throwables(com.google.common.base.Throwables)

Example 2 with Throwables

use of com.google.common.base.Throwables in project sonar-java by SonarSource.

the class JavaRulingTest method prepareDumpOldFolder.

private static void prepareDumpOldFolder() {
    Path allRulesFolder = Paths.get("src/test/resources");
    if (SUBSET_OF_ENABLED_RULES.isEmpty()) {
        effectiveDumpOldFolder = allRulesFolder.toAbsolutePath();
    } else {
        effectiveDumpOldFolder = TMP_DUMP_OLD_FOLDER.getRoot().toPath().toAbsolutePath();
        Try.of(() -> Files.list(allRulesFolder)).orElseThrow(Throwables::propagate).filter(p -> p.toFile().isDirectory()).forEach(srcProjectDir -> copyDumpSubset(srcProjectDir, effectiveDumpOldFolder.resolve(srcProjectDir.getFileName())));
    }
}
Also used : Path(java.nio.file.Path) StringUtils(org.apache.commons.lang.StringUtils) BeforeClass(org.junit.BeforeClass) LoggerFactory(org.slf4j.LoggerFactory) StandardCopyOption(java.nio.file.StandardCopyOption) HashSet(java.util.HashSet) BuildResult(com.sonar.orchestrator.build.BuildResult) Gson(com.google.gson.Gson) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) ClassRule(org.junit.ClassRule) Splitter(com.google.common.base.Splitter) Path(java.nio.file.Path) Nullable(javax.annotation.Nullable) Try(no.finn.lambdacompanion.Try) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) MavenBuild(com.sonar.orchestrator.build.MavenBuild) Files(java.nio.file.Files) SonarClient(org.sonar.wsclient.SonarClient) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Throwables(com.google.common.base.Throwables) FileLocation(com.sonar.orchestrator.locator.FileLocation) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) Fail(org.assertj.core.api.Fail) Server(com.sonar.orchestrator.container.Server) List(java.util.List) Paths(java.nio.file.Paths) Build(com.sonar.orchestrator.build.Build) Orchestrator(com.sonar.orchestrator.Orchestrator) TemporaryFolder(org.junit.rules.TemporaryFolder) Throwables(com.google.common.base.Throwables)

Example 3 with Throwables

use of com.google.common.base.Throwables in project sonarqube by SonarSource.

the class WebhookDeliveryStorage method toDto.

private WebhookDeliveryDto toDto(WebhookDelivery delivery) {
    WebhookDeliveryDto dto = new WebhookDeliveryDto();
    dto.setUuid(uuidFactory.create());
    dto.setWebhookUuid(delivery.getWebhook().getUuid());
    dto.setComponentUuid(delivery.getWebhook().getComponentUuid());
    delivery.getWebhook().getCeTaskUuid().ifPresent(dto::setCeTaskUuid);
    delivery.getWebhook().getAnalysisUuid().ifPresent(dto::setAnalysisUuid);
    dto.setName(delivery.getWebhook().getName());
    dto.setUrl(delivery.getEffectiveUrl().orElse(delivery.getWebhook().getUrl()));
    dto.setSuccess(delivery.isSuccess());
    dto.setHttpStatus(delivery.getHttpStatus().orElse(null));
    dto.setDurationMs(delivery.getDurationInMs().orElse(null));
    dto.setErrorStacktrace(delivery.getError().map(Throwables::getStackTraceAsString).orElse(null));
    dto.setPayload(delivery.getPayload().getJson());
    dto.setCreatedAt(delivery.getAt());
    return dto;
}
Also used : WebhookDeliveryDto(org.sonar.db.webhook.WebhookDeliveryDto) Throwables(com.google.common.base.Throwables)

Aggregations

Throwables (com.google.common.base.Throwables)3 WebhookDeliveryDto (org.sonar.db.webhook.WebhookDeliveryDto)2 Splitter (com.google.common.base.Splitter)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Gson (com.google.gson.Gson)1 Orchestrator (com.sonar.orchestrator.Orchestrator)1 Build (com.sonar.orchestrator.build.Build)1 BuildResult (com.sonar.orchestrator.build.BuildResult)1 MavenBuild (com.sonar.orchestrator.build.MavenBuild)1 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 Server (com.sonar.orchestrator.container.Server)1 FileLocation (com.sonar.orchestrator.locator.FileLocation)1 File (java.io.File)1 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 StandardCopyOption (java.nio.file.StandardCopyOption)1