3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.ce.task.projectanalysis.analysis;
23 import java.util.Optional;
24 import javax.annotation.CheckForNull;
25 import javax.annotation.Nullable;
26 import org.junit.rules.ExternalResource;
27 import org.sonar.core.platform.PlatformEditionProvider;
28 import org.sonar.server.project.Project;
29 import org.sonar.server.qualityprofile.QualityProfile;
31 import static org.mockito.Mockito.mock;
33 public class MutableAnalysisMetadataHolderRule extends ExternalResource implements MutableAnalysisMetadataHolder {
35 private final PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
36 private AnalysisMetadataHolderImpl delegate = new AnalysisMetadataHolderImpl(editionProvider);
39 protected void after() {
40 delegate = new AnalysisMetadataHolderImpl(editionProvider);
43 public MutableAnalysisMetadataHolderRule setUuid(String s) {
49 public String getUuid() {
50 return delegate.getUuid();
53 public MutableAnalysisMetadataHolderRule setAnalysisDate(long date) {
54 delegate.setAnalysisDate(date);
59 public long getAnalysisDate() {
60 return delegate.getAnalysisDate();
64 public boolean hasAnalysisDateBeenSet() {
65 return delegate.hasAnalysisDateBeenSet();
69 public boolean isFirstAnalysis() {
70 return delegate.isFirstAnalysis();
74 public MutableAnalysisMetadataHolderRule setBaseAnalysis(@Nullable Analysis baseAnalysis) {
75 delegate.setBaseAnalysis(baseAnalysis);
81 public Analysis getBaseAnalysis() {
82 return delegate.getBaseAnalysis();
86 public boolean isCrossProjectDuplicationEnabled() {
87 return delegate.isCrossProjectDuplicationEnabled();
91 public MutableAnalysisMetadataHolderRule setCrossProjectDuplicationEnabled(boolean isCrossProjectDuplicationEnabled) {
92 delegate.setCrossProjectDuplicationEnabled(isCrossProjectDuplicationEnabled);
97 public Branch getBranch() {
98 return delegate.getBranch();
102 public MutableAnalysisMetadataHolderRule setBranch(Branch branch) {
103 delegate.setBranch(branch);
108 public String getPullRequestKey() {
109 return delegate.getPullRequestKey();
113 public MutableAnalysisMetadataHolder setPullRequestKey(String pullRequestKey) {
114 delegate.setPullRequestKey(pullRequestKey);
119 public MutableAnalysisMetadataHolderRule setProject(@Nullable Project project) {
120 delegate.setProject(project);
125 public Project getProject() {
126 return delegate.getProject();
130 public MutableAnalysisMetadataHolderRule setRootComponentRef(int rootComponentRef) {
131 delegate.setRootComponentRef(rootComponentRef);
136 public int getRootComponentRef() {
137 return delegate.getRootComponentRef();
141 public MutableAnalysisMetadataHolder setQProfilesByLanguage(Map<String, QualityProfile> qprofilesByLanguage) {
142 delegate.setQProfilesByLanguage(qprofilesByLanguage);
147 public Map<String, QualityProfile> getQProfilesByLanguage() {
148 return delegate.getQProfilesByLanguage();
152 public MutableAnalysisMetadataHolder setScannerPluginsByKey(Map<String, ScannerPlugin> plugins) {
153 delegate.setScannerPluginsByKey(plugins);
158 public Map<String, ScannerPlugin> getScannerPluginsByKey() {
159 return delegate.getScannerPluginsByKey();
163 public MutableAnalysisMetadataHolder setScmRevision(String scmRevisionId) {
164 delegate.setScmRevision(scmRevisionId);
168 @Override public MutableAnalysisMetadataHolder setNewCodeReferenceBranch(String newCodeReferenceBranch) {
169 delegate.setNewCodeReferenceBranch(newCodeReferenceBranch);
174 public Optional<String> getScmRevision() {
175 return delegate.getScmRevision();
178 @Override public Optional<String> getNewCodeReferenceBranch() {
179 return delegate.getNewCodeReferenceBranch();
183 public boolean isBranch() {
184 return delegate.isBranch();
188 public boolean isPullRequest() {
189 return delegate.isPullRequest();