Commit 43719934 by Gabriel Allaigre

Up to SC 7.0

parent 86c74420
Pipeline #13308 passed with stages
in 2 minutes 8 seconds
......@@ -605,7 +605,9 @@ Restart your SonarQube instance.
- On a private project, with the provided command line upper in this document, you'll got an "IllegalStateException: Unable found project for" Exception.
- It's necessary to create a "Personal Access Tokens". It needs a user with the "developper" right in the project. The token can be created in the profile menu, check the api checkbox.
- Then, use the following command line to run sonar thought gitlab-ci
```mvn --batch-mode verify sonar:sonar
``` batch
mvn --batch-mode verify sonar:sonar
-Dsonar.gitlab.api_version=v4
-Dsonar.host.url=http://<your_sonar_url>:9000
-Dsonar.login=<your_sonar_login>
......@@ -614,5 +616,10 @@ Restart your SonarQube instance.
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.gitlab.project_id=$CI_PROJECT_ID
-Dsonar.gitlab.url=http://<your_gitlab_url>
-Dsonar.gitlab.user_token=<your_user_token>```
-Dsonar.gitlab.user_token=<your_user_token>
```
## Version 3.1.0-SNAPSHOT
- UP to Sonarqube API 7.0
......@@ -23,7 +23,7 @@
<license.mailto>gabriel.allaigre@talanlabs.com</license.mailto>
<license.owner>Talanlabs</license.owner>
<sonar.version>6.7</sonar.version>
<sonar.version>7.0</sonar.version>
<sonar.pluginName>GitLab</sonar.pluginName>
<sonar.pluginClass>com.talanlabs.sonar.plugins.gitlab.GitLabPlugin</sonar.pluginClass>
......@@ -196,4 +196,4 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
......@@ -20,8 +20,8 @@
package com.talanlabs.sonar.plugins.gitlab;
import com.talanlabs.sonar.plugins.gitlab.models.JsonMode;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.log.Logger;
......@@ -41,7 +41,7 @@ import java.nio.file.StandardOpenOption;
* Facade for all WS interaction with GitLab.
*/
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
@BatchSide
@ScannerSide
public class CommitFacade {
private static final Logger LOG = Loggers.get(CommitFacade.class);
......
......@@ -138,7 +138,7 @@ public class GitLabPlugin implements Plugin {
PropertyDefinition.builder(GITLAB_QUERY_MAX_RETRY).name("Query max retry").description("Max retry for wait finish analyse for publish mode").category(CATEGORY).subCategory(SUBCATEGORY)
.type(PropertyType.INTEGER).defaultValue(String.valueOf(50)).index(28).build(),
PropertyDefinition.builder(GITLAB_QUERY_WAIT).name("Query waiting between retry").description("Max retry for wait finish analyse for publish mode (millisecond)").category(CATEGORY).subCategory(SUBCATEGORY)
.type(PropertyType.LONG).defaultValue(String.valueOf(1000)).index(29).build(),
.type(PropertyType.INTEGER).defaultValue(String.valueOf(1000)).index(29).build(),
PropertyDefinition.builder(GITLAB_QUALITY_GATE_FAIL_MODE).name("Quality Gate fail mode").description("Quality gate fail mode: error or warn")
.category(CATEGORY).subCategory(SUBCATEGORY).type(PropertyType.SINGLE_SELECT_LIST)
.options(QualityGateFailMode.WARN.getMeaning(), QualityGateFailMode.ERROR.getMeaning()).defaultValue(QualityGateFailMode.ERROR.getMeaning())
......
......@@ -23,10 +23,10 @@ import com.talanlabs.sonar.plugins.gitlab.models.JsonMode;
import com.talanlabs.sonar.plugins.gitlab.models.QualityGateFailMode;
import com.talanlabs.sonar.plugins.gitlab.models.StatusNotificationsMode;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.Settings;
import org.sonar.api.config.Configuration;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
......@@ -37,7 +37,7 @@ import java.util.Arrays;
import java.util.List;
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
@BatchSide
@ScannerSide
public class GitLabPluginConfiguration {
public static final String HTTP_PROXY_HOSTNAME = "http.proxyHost";
......@@ -48,17 +48,17 @@ public class GitLabPluginConfiguration {
public static final String HTTP_PROXY_USER = "http.proxyUser";
public static final String HTTP_PROXY_PASS = "http.proxyPassword";
private static final Logger LOG = Loggers.get(GitLabPluginConfiguration.class);
private final Settings settings;
private final Configuration configuration;
private final System2 system2;
private final String baseUrl;
public GitLabPluginConfiguration(Settings settings, System2 system2) {
public GitLabPluginConfiguration(Configuration configuration, System2 system2) {
super();
this.settings = settings;
this.configuration = configuration;
this.system2 = system2;
String tempBaseUrl = settings.hasKey(CoreProperties.SERVER_BASE_URL) ? settings.getString(CoreProperties.SERVER_BASE_URL) : settings.getString("sonar.host.url");
String tempBaseUrl = configuration.hasKey(CoreProperties.SERVER_BASE_URL) ? configuration.get(CoreProperties.SERVER_BASE_URL).orElse(null) : configuration.get("sonar.host.url").orElse(null);
if (tempBaseUrl == null) {
tempBaseUrl = "http://localhost:9090";
}
......@@ -69,140 +69,140 @@ public class GitLabPluginConfiguration {
}
public String projectId() {
return settings.getString(GitLabPlugin.GITLAB_PROJECT_ID);
return configuration.get(GitLabPlugin.GITLAB_PROJECT_ID).orElse(null);
}
public List<String> commitSHA() {
return Arrays.asList(settings.getStringArray(GitLabPlugin.GITLAB_COMMIT_SHA));
return Arrays.asList(configuration.getStringArray(GitLabPlugin.GITLAB_COMMIT_SHA));
}
@CheckForNull
public String refName() {
return settings.getString(GitLabPlugin.GITLAB_REF_NAME);
return configuration.get(GitLabPlugin.GITLAB_REF_NAME).orElse(null);
}
@CheckForNull
public String userToken() {
return settings.getString(GitLabPlugin.GITLAB_USER_TOKEN);
return configuration.get(GitLabPlugin.GITLAB_USER_TOKEN).orElse(null);
}
public boolean isEnabled() {
return settings.hasKey(GitLabPlugin.GITLAB_COMMIT_SHA);
return configuration.hasKey(GitLabPlugin.GITLAB_COMMIT_SHA);
}
@CheckForNull
public String url() {
return settings.getString(GitLabPlugin.GITLAB_URL);
return configuration.get(GitLabPlugin.GITLAB_URL).orElseGet(null);
}
public boolean ignoreCertificate() {
return settings.getBoolean(GitLabPlugin.GITLAB_IGNORE_CERT);
return configuration.getBoolean(GitLabPlugin.GITLAB_IGNORE_CERT).orElse(false);
}
public int maxGlobalIssues() {
return settings.getInt(GitLabPlugin.GITLAB_MAX_GLOBAL_ISSUES);
return configuration.getInt(GitLabPlugin.GITLAB_MAX_GLOBAL_ISSUES).orElse(10);
}
public int maxBlockerIssuesGate() {
return settings.getInt(GitLabPlugin.GITLAB_MAX_BLOCKER_ISSUES_GATE);
return configuration.getInt(GitLabPlugin.GITLAB_MAX_BLOCKER_ISSUES_GATE).orElse(0);
}
public int maxCriticalIssuesGate() {
return settings.getInt(GitLabPlugin.GITLAB_MAX_CRITICAL_ISSUES_GATE);
return configuration.getInt(GitLabPlugin.GITLAB_MAX_CRITICAL_ISSUES_GATE).orElse(0);
}
public int maxMajorIssuesGate() {
return settings.getInt(GitLabPlugin.GITLAB_MAX_MAJOR_ISSUES_GATE);
return configuration.getInt(GitLabPlugin.GITLAB_MAX_MAJOR_ISSUES_GATE).orElse(-1);
}
public int maxMinorIssuesGate() {
return settings.getInt(GitLabPlugin.GITLAB_MAX_MINOR_ISSUES_GATE);
return configuration.getInt(GitLabPlugin.GITLAB_MAX_MINOR_ISSUES_GATE).orElse(-1);
}
public int maxInfoIssuesGate() {
return settings.getInt(GitLabPlugin.GITLAB_MAX_INFO_ISSUES_GATE);
return configuration.getInt(GitLabPlugin.GITLAB_MAX_INFO_ISSUES_GATE).orElse(-1);
}
public boolean tryReportIssuesInline() {
return !settings.getBoolean(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS);
return !configuration.getBoolean(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS).orElse(true);
}
public boolean onlyIssueFromCommitFile() {
return settings.getBoolean(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_FILE);
return configuration.getBoolean(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_FILE).orElse(false);
}
public boolean onlyIssueFromCommitLine() {
return settings.getBoolean(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_LINE);
return configuration.getBoolean(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_LINE).orElse(false);
}
public BuildInitState buildInitState() {
BuildInitState b = BuildInitState.of(settings.getString(GitLabPlugin.GITLAB_BUILD_INIT_STATE));
BuildInitState b = BuildInitState.of(configuration.get(GitLabPlugin.GITLAB_BUILD_INIT_STATE).orElse(null));
return b != null ? b : BuildInitState.PENDING;
}
public boolean disableGlobalComment() {
return settings.getBoolean(GitLabPlugin.GITLAB_DISABLE_GLOBAL_COMMENT);
return configuration.getBoolean(GitLabPlugin.GITLAB_DISABLE_GLOBAL_COMMENT).orElse(false);
}
public StatusNotificationsMode statusNotificationsMode() {
StatusNotificationsMode s = StatusNotificationsMode.of(settings.getString(GitLabPlugin.GITLAB_STATUS_NOTIFICATION_MODE));
StatusNotificationsMode s = StatusNotificationsMode.of(configuration.get(GitLabPlugin.GITLAB_STATUS_NOTIFICATION_MODE).orElse(null));
return s != null ? s : StatusNotificationsMode.COMMIT_STATUS;
}
public QualityGateFailMode qualityGateFailMode() {
QualityGateFailMode s = QualityGateFailMode.of(settings.getString(GitLabPlugin.GITLAB_QUALITY_GATE_FAIL_MODE));
QualityGateFailMode s = QualityGateFailMode.of(configuration.get(GitLabPlugin.GITLAB_QUALITY_GATE_FAIL_MODE).orElse(null));
return s != null ? s : QualityGateFailMode.ERROR;
}
@CheckForNull
public String globalTemplate() {
return settings.getString(GitLabPlugin.GITLAB_GLOBAL_TEMPLATE);
return configuration.get(GitLabPlugin.GITLAB_GLOBAL_TEMPLATE).orElse(null);
}
@CheckForNull
public String inlineTemplate() {
return settings.getString(GitLabPlugin.GITLAB_INLINE_TEMPLATE);
return configuration.get(GitLabPlugin.GITLAB_INLINE_TEMPLATE).orElse(null);
}
public boolean commentNoIssue() {
return settings.getBoolean(GitLabPlugin.GITLAB_COMMENT_NO_ISSUE);
return configuration.getBoolean(GitLabPlugin.GITLAB_COMMENT_NO_ISSUE).orElse(false);
}
public boolean pingUser() {
return settings.getBoolean(GitLabPlugin.GITLAB_PING_USER);
return configuration.getBoolean(GitLabPlugin.GITLAB_PING_USER).orElse(false);
}
public boolean uniqueIssuePerInline() {
return settings.getBoolean(GitLabPlugin.GITLAB_UNIQUE_ISSUE_PER_INLINE);
return configuration.getBoolean(GitLabPlugin.GITLAB_UNIQUE_ISSUE_PER_INLINE).orElse(false);
}
public String prefixDirectory() {
return settings.getString(GitLabPlugin.GITLAB_PREFIX_DIRECTORY);
return configuration.get(GitLabPlugin.GITLAB_PREFIX_DIRECTORY).orElse(null);
}
public String apiVersion() {
return settings.getString(GitLabPlugin.GITLAB_API_VERSION);
return configuration.get(GitLabPlugin.GITLAB_API_VERSION).orElse(GitLabPlugin.V4_API_VERSION);
}
public boolean allIssues() {
return settings.getBoolean(GitLabPlugin.GITLAB_ALL_ISSUES);
return configuration.getBoolean(GitLabPlugin.GITLAB_ALL_ISSUES).orElse(false);
}
public JsonMode jsonMode() {
JsonMode s = JsonMode.of(settings.getString(GitLabPlugin.GITLAB_JSON_MODE));
JsonMode s = JsonMode.of(configuration.get(GitLabPlugin.GITLAB_JSON_MODE).orElse(null));
return s != null ? s : JsonMode.NONE;
}
public int queryMaxRetry() {
return settings.getInt(GitLabPlugin.GITLAB_QUERY_MAX_RETRY);
return configuration.getInt(GitLabPlugin.GITLAB_QUERY_MAX_RETRY).orElse(50);
}
public long queryWait() {
return settings.getLong(GitLabPlugin.GITLAB_QUERY_WAIT);
public int queryWait() {
return configuration.getInt(GitLabPlugin.GITLAB_QUERY_WAIT).orElse(1000);
}
public Severity issueFilter() {
String name = settings.getString(GitLabPlugin.GITLAB_ISSUE_FILTER);
String name = configuration.get(GitLabPlugin.GITLAB_ISSUE_FILTER).orElse(null);
if (name == null) {
return Severity.INFO;
}
......@@ -214,7 +214,7 @@ public class GitLabPluginConfiguration {
}
public boolean loadRule() {
return settings.getBoolean(GitLabPlugin.GITLAB_LOAD_RULES);
return configuration.getBoolean(GitLabPlugin.GITLAB_LOAD_RULES).orElse(false);
}
/**
......
......@@ -19,14 +19,14 @@
*/
package com.talanlabs.sonar.plugins.gitlab;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.rule.Severity;
import javax.annotation.Nullable;
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
@BatchSide
@ScannerSide
public class MarkDownUtils {
private static final String IMAGES_ROOT_URL = "https://github.com/gabrie-allaigre/sonar-gitlab-plugin/raw/master/images/";
......
......@@ -22,7 +22,7 @@ package com.talanlabs.sonar.plugins.gitlab;
import com.talanlabs.sonar.plugins.gitlab.models.*;
import org.sonar.api.ExtensionPoint;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.BatchSide;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
......@@ -34,7 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
@BatchSide
@ScannerSide
@ExtensionPoint
public class ReporterBuilder {
......
......@@ -26,7 +26,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.bootstrap.ProjectBuilder;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -43,14 +42,14 @@ public class CommitProjectBuilderTest {
private CommitProjectBuilder commitProjectBuilder;
private SonarFacade sonarFacade;
private CommitFacade commitFacade;
private Settings settings;
private MapSettings settings;
@Before
public void prepare() {
settings = new MapSettings(new PropertyDefinitions(GitLabPlugin.definitions()));
sonarFacade = mock(SonarFacade.class);
commitFacade = mock(CommitFacade.class);
commitProjectBuilder = new CommitProjectBuilder(new GitLabPluginConfiguration(settings, new System2()), sonarFacade, commitFacade);
commitProjectBuilder = new CommitProjectBuilder(new GitLabPluginConfiguration(settings.asConfig(), new System2()), sonarFacade, commitFacade);
}
@Test
......
......@@ -35,7 +35,6 @@ import org.sonar.api.batch.postjob.issue.PostJobIssue;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
......@@ -52,7 +51,7 @@ import static org.mockito.Mockito.when;
public class CommitPublishPostJobTest {
private ReporterBuilder reporterBuilder;
private Settings settings;
private MapSettings settings;
private CommitFacade commitFacade;
private SonarFacade sonarFacade;
private CommitPublishPostJob commitPublishPostJob;
......@@ -79,7 +78,7 @@ public class CommitPublishPostJobTest {
context = Mockito.mock(PostJobContext.class);
when(context.analysisMode()).thenReturn(analysisMode);
GitLabPluginConfiguration config = new GitLabPluginConfiguration(settings, new System2());
GitLabPluginConfiguration config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
commitPublishPostJob = new CommitPublishPostJob(config, sonarFacade, commitFacade, reporterBuilder);
}
......
......@@ -31,7 +31,6 @@ import org.mockito.Mockito;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -42,14 +41,14 @@ public class GitLabPluginConfigurationTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
private Settings settings;
private MapSettings settings;
private GitLabPluginConfiguration config;
@Before
public void before() {
settings = new MapSettings(new PropertyDefinitions(GitLabPlugin.definitions()));
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
config = new GitLabPluginConfiguration(settings, new System2());
config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
}
@Test
......@@ -153,9 +152,9 @@ public class GitLabPluginConfigurationTest {
settings.setProperty(GitLabPlugin.GITLAB_QUERY_MAX_RETRY, "10");
Assertions.assertThat(config.queryMaxRetry()).isEqualTo(10);
Assertions.assertThat(config.queryWait()).isEqualTo(1000L);
Assertions.assertThat(config.queryWait()).isEqualTo(1000);
settings.setProperty(GitLabPlugin.GITLAB_QUERY_WAIT, "2000");
Assertions.assertThat(config.queryWait()).isEqualTo(2000L);
Assertions.assertThat(config.queryWait()).isEqualTo(2000);
Assertions.assertThat(config.issueFilter()).isEqualTo(Severity.INFO);
settings.setProperty(GitLabPlugin.GITLAB_ISSUE_FILTER, Severity.MAJOR.name());
......@@ -202,7 +201,7 @@ public class GitLabPluginConfigurationTest {
@Test
public void testProxyConfiguration() {
System2 system2 = Mockito.mock(System2.class);
config = new GitLabPluginConfiguration(settings, system2);
config = new GitLabPluginConfiguration(settings.asConfig(), system2);
Assertions.assertThat(config.isProxyConnectionEnabled()).isFalse();
Mockito.when(system2.property("http.proxyHost")).thenReturn("foo");
Assertions.assertThat(config.isProxyConnectionEnabled()).isTrue();
......
......@@ -29,7 +29,6 @@ import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
......@@ -44,7 +43,7 @@ public class GlobalCommentBuilderTest {
private static final String GITLAB_URL = "https://gitlab.com/test/test";
private Settings settings;
private MapSettings settings;
private GitLabPluginConfiguration config;
private AnalysisMode analysisMode;
......@@ -57,7 +56,7 @@ public class GlobalCommentBuilderTest {
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
settings.setProperty(GitLabPlugin.GITLAB_COMMIT_SHA, "123");
config = new GitLabPluginConfiguration(settings, new System2());
config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
analysisMode = Mockito.mock(AnalysisMode.class);
when(analysisMode.isIssues()).thenReturn(false);
......
......@@ -29,7 +29,6 @@ import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -105,7 +104,7 @@ public class GlobalTemplateTest {
" </#if>\n" +
"</#if>";
private Settings settings;
private MapSettings settings;
private GitLabPluginConfiguration config;
private AnalysisMode analysisMode;
......@@ -123,7 +122,7 @@ public class GlobalTemplateTest {
when(analysisMode.isPreview()).thenReturn(true);
when(analysisMode.isPublish()).thenReturn(false);
config = new GitLabPluginConfiguration(settings, new System2());
config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
settings.setProperty(GitLabPlugin.GITLAB_GLOBAL_TEMPLATE, TEMPLATE);
}
......
......@@ -29,7 +29,6 @@ import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
......@@ -45,7 +44,7 @@ public class InlineCommentBuilderTest {
private static final String GITLAB_URL = "https://gitlab.com/test/test";
private Settings settings;
private MapSettings settings;
private GitLabPluginConfiguration config;
private AnalysisMode analysisMode;
......@@ -58,7 +57,7 @@ public class InlineCommentBuilderTest {
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
settings.setProperty(GitLabPlugin.GITLAB_COMMIT_SHA, "abc123");
config = new GitLabPluginConfiguration(settings, new System2());
config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
analysisMode = Mockito.mock(AnalysisMode.class);
when(analysisMode.isIssues()).thenReturn(false);
......
......@@ -29,7 +29,6 @@ import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -45,7 +44,7 @@ public class InlineTemplateTest {
private static final String TEMPLATE = "<#list issues() as issue>\n" + "<@p issue=issue/>\n" + "</#list>\n" + "<#macro p issue>\n"
+ "${emojiSeverity(issue.severity)} ${issue.message} [:blue_book:](${ruleLink(issue.ruleKey)})\n" + "</#macro>";
private Settings settings;
private MapSettings settings;
private GitLabPluginConfiguration config;
private AnalysisMode analysisMode;
......@@ -58,7 +57,7 @@ public class InlineTemplateTest {
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
settings.setProperty(GitLabPlugin.GITLAB_COMMIT_SHA, "abc123");
config = new GitLabPluginConfiguration(settings, new System2());
config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
settings.setProperty(GitLabPlugin.GITLAB_INLINE_TEMPLATE, TEMPLATE);
......
......@@ -19,7 +19,10 @@
*/
package com.talanlabs.sonar.plugins.gitlab;
import com.talanlabs.sonar.plugins.gitlab.models.*;
import com.talanlabs.sonar.plugins.gitlab.models.Issue;
import com.talanlabs.sonar.plugins.gitlab.models.JsonMode;
import com.talanlabs.sonar.plugins.gitlab.models.QualityGate;
import com.talanlabs.sonar.plugins.gitlab.models.StatusNotificationsMode;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
......@@ -31,7 +34,6 @@ import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -48,7 +50,7 @@ import static org.mockito.Mockito.when;
public class ReporterBuilderTest {
private Settings settings;
private MapSettings settings;
private ReporterBuilder reporterBuilder;
private SonarFacade sonarFacade;
private CommitFacade commitFacade;
......@@ -69,7 +71,7 @@ public class ReporterBuilderTest {
when(analysisMode.isPreview()).thenReturn(true);
when(analysisMode.isPublish()).thenReturn(false);
GitLabPluginConfiguration config = new GitLabPluginConfiguration(settings, new System2());
GitLabPluginConfiguration config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
reporterBuilder = new ReporterBuilder(config, sonarFacade, commitFacade, new MarkDownUtils(), analysisMode);
}
......
......@@ -27,7 +27,6 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -35,7 +34,7 @@ public class ReporterTest {
private static final String GITLAB_URL = "https://gitlab.com/test/test";
private Settings settings;
private MapSettings settings;
private GitLabPluginConfiguration config;
private Reporter reporter;
......@@ -47,7 +46,7 @@ public class ReporterTest {
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
settings.setProperty(GitLabPlugin.GITLAB_COMMIT_SHA, "abc123");
config = new GitLabPluginConfiguration(settings, new System2());
config = new GitLabPluginConfiguration(settings.asConfig(), new System2());
reporter = new Reporter(config);
}
......
......@@ -30,7 +30,6 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import java.util.Collections;
......@@ -43,10 +42,10 @@ public class PrintTemplateMethodModelExTest {
private PrintTemplateMethodModelEx printTemplateMethodModelEx;
@Before
public void setUp() throws Exception {
Settings settings = new MapSettings(new PropertyDefinitions(PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL).name("Server base URL")
public void setUp() {
MapSettings settings = new MapSettings(new PropertyDefinitions(PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL).name("Server base URL")
.description("HTTP URL of this SonarQube server, such as <i>http://yourhost.yourdomain/sonar</i>. This value is used i.e. to create links in emails.")
.category(CoreProperties.CATEGORY_GENERAL).defaultValue(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE).build()).addComponents(GitLabPlugin.definitions()));
.category(CoreProperties.CATEGORY_GENERAL).defaultValue("http://localhost:9000").build()).addComponents(GitLabPlugin.definitions()));
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
......
......@@ -29,7 +29,6 @@ import org.junit.Test;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
......@@ -41,14 +40,14 @@ public class RuleLinkTemplateMethodModelExTest {
private RuleLinkTemplateMethodModelEx ruleLinkTemplateMethodModelEx;
@Before
public void setUp() throws Exception {
Settings settings = new MapSettings(new PropertyDefinitions(PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL).name("Server base URL")
public void setUp() {
MapSettings settings = new MapSettings(new PropertyDefinitions(PropertyDefinition.builder(CoreProperties.SERVER_BASE_URL).name("Server base URL")
.description("HTTP URL of this SonarQube server, such as <i>http://yourhost.yourdomain/sonar</i>. This value is used i.e. to create links in emails.")
.category(CoreProperties.CATEGORY_GENERAL).defaultValue(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE).build()).addComponents(GitLabPlugin.definitions()));
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://myserver");
GitLabPluginConfiguration gitLabPluginConfiguration = new GitLabPluginConfiguration(settings,new System2());
GitLabPluginConfiguration gitLabPluginConfiguration = new GitLabPluginConfiguration(settings.asConfig(),new System2());
ruleLinkTemplateMethodModelEx = new RuleLinkTemplateMethodModelEx(gitLabPluginConfiguration);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment