diff options
Diffstat (limited to 'server/sonar-alm-client')
2 files changed, 129 insertions, 1 deletions
diff --git a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java index 7a8513153e7..d136e221917 100644 --- a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java +++ b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubBinding.java @@ -22,7 +22,7 @@ package org.sonar.alm.client.github; import com.google.gson.annotations.SerializedName; import java.util.List; -import static org.sonar.alm.client.github.GithubApplicationClient.*; +import static org.sonar.alm.client.github.GithubApplicationClient.Repository; public class GithubBinding { @@ -154,4 +154,92 @@ public class GithubBinding { this.htmlUrl, this.defaultBranch); } } + + public static class GsonGithubCodeScanningAlert { + @SerializedName("number") + long id; + @SerializedName("state") + GithubCodeScanningAlertState state; + @SerializedName("dismissed_reason") + String dismissedReason; + @SerializedName("dismissed_comment") + String dismissedComment; + @SerializedName("most_recent_instance") + GithubCodeScanningAlertInstance mostRecentInstance; + + public GsonGithubCodeScanningAlert() { + // even if empty constructor is not required for Gson, it is strongly + // recommended: + // http://stackoverflow.com/a/18645370/229031 + } + + public long getId() { + return id; + } + + public GithubCodeScanningAlertState getState() { + return state; + } + + public String getDismissedReason() { + return dismissedReason; + } + + public String getDismissedComment() { + return dismissedComment; + } + + public GithubCodeScanningAlertInstance getInstance() { + return mostRecentInstance; + } + + public String getMessageText() { + return getInstance().getMessageText(); + } + } + + public static class GithubCodeScanningAlertInstance { + @SerializedName("state") + GithubCodeScanningAlertState state; + @SerializedName("message") + Message message; + + public GithubCodeScanningAlertInstance() { + // even if empty constructor is not required for Gson, it is strongly + // recommended: + // http://stackoverflow.com/a/18645370/229031 + } + + public Message getMessage() { + return message; + } + + public String getMessageText() { + return getMessage().getText(); + } + } + + public enum GithubCodeScanningAlertState { + @SerializedName("open") + OPEN, + @SerializedName("fixed") + FIXED, + @SerializedName("dismissed") + DISMISSED; + } + + public static class Message { + @SerializedName("text") + String text; + + public Message() { + // even if empty constructor is not required for Gson, it is strongly + // recommended: + // http://stackoverflow.com/a/18645370/229031 + } + + public String getText() { + return text; + } + } } diff --git a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/scanning/alert/GithubScanningAlertState.java b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/scanning/alert/GithubScanningAlertState.java new file mode 100644 index 00000000000..625799d34fd --- /dev/null +++ b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/scanning/alert/GithubScanningAlertState.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.alm.client.github.scanning.alert; + +import com.google.gson.annotations.SerializedName; +import javax.annotation.Nullable; + +public class GithubScanningAlertState { + protected static final String GH_OPEN = "open"; + protected static final String GH_DISMISSED = "dismissed"; + protected static final String GH_WONTFIX = "won't fix"; + protected static final String GH_FALSE_POSITIVE = "false positive"; + + @SerializedName("state") + private String state; + @SerializedName("dismissed_reason") + private String dismissedReason; + + public GithubScanningAlertState(String state, @Nullable String dismissedReason) { + this.state = state; + this.dismissedReason = dismissedReason; + } +} |