Search in sources :

Example 1 with SonarQubeServer

use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.

the class GlobalConfigurationListenerTest method testApplied.

@Test
public void testApplied() {
    List<SonarQubeServer> servers = new LinkedList<>();
    AtomicBoolean bool = new AtomicBoolean(false);
    GlobalConfigurationListener listener = new GlobalConfigurationListener.Adapter() {

        @Override
        public void applied(SonarLintGlobalSettings settings) {
            servers.addAll(settings.getSonarQubeServers());
            bool.set(settings.isAutoTrigger());
        }
    };
    project.getMessageBus().connect().subscribe(GlobalConfigurationListener.TOPIC, listener);
    SonarLintGlobalSettings settings = new SonarLintGlobalSettings();
    settings.setSonarQubeServers(testList);
    settings.setAutoTrigger(true);
    project.getMessageBus().syncPublisher(GlobalConfigurationListener.TOPIC).applied(settings);
    assertThat(servers).isEqualTo(testList);
    assertThat(bool.get()).isTrue();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings) SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) LinkedList(java.util.LinkedList) SonarTest(org.sonarlint.intellij.SonarTest) Test(org.junit.Test)

Example 2 with SonarQubeServer

use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.

the class WizardModelTest method testExportToConfig.

@Test
public void testExportToConfig() {
    WizardModel model = new WizardModel();
    model.setName("name");
    model.setOrganization("org");
    model.setServerUrl("url");
    model.setLogin("login");
    model.setProxyEnabled(true);
    model.setPassword(new char[] { 'p', 'a', 's', 's' });
    model.setServerType(WizardModel.ServerType.SONARQUBE);
    SonarQubeServer server = model.createServer();
    assertThat(server.getHostUrl()).isEqualTo("url");
    assertThat(server.enableProxy()).isTrue();
    assertThat(server.getLogin()).isEqualTo("login");
    assertThat(server.getPassword()).isEqualTo("pass");
    assertThat(server.getToken()).isNull();
    assertThat(server.getOrganizationKey()).isEqualTo("org");
}
Also used : SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) Test(org.junit.Test)

Example 3 with SonarQubeServer

use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.

the class WizardModelTest method testCreateFromConfig.

@Test
public void testCreateFromConfig() {
    SonarQubeServer server = SonarQubeServer.newBuilder().setName("name").setToken("token").setOrganizationKey("org").setEnableProxy(true).setHostUrl("url").build();
    WizardModel model = new WizardModel(server);
    assertThat(model.getLogin()).isNull();
    assertThat(model.getPassword()).isNull();
    assertThat(model.getToken()).isEqualTo("token");
    assertThat(model.getOrganization()).isEqualTo("org");
    assertThat(model.getOrganizationList()).isNull();
    assertThat(model.getName()).isEqualTo("name");
    assertThat(model.getServerUrl()).isEqualTo("url");
}
Also used : SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) Test(org.junit.Test)

Example 4 with SonarQubeServer

use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.

the class WizardModelTest method testMigrationSonarCloud.

@Test
public void testMigrationSonarCloud() {
    SonarQubeServer server = SonarQubeServer.newBuilder().setName("name").setToken("token").setOrganizationKey("org").setEnableProxy(true).setHostUrl("https://www.sonarqube.com").build();
    WizardModel model = new WizardModel(server);
    server = model.createServer();
    assertThat(server.enableProxy()).isTrue();
    assertThat(server.getHostUrl()).isEqualTo("https://sonarcloud.io");
}
Also used : SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) Test(org.junit.Test)

Example 5 with SonarQubeServer

use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.

the class ProjectBindingManagerTest method should_find_sq_server.

@Test
public void should_find_sq_server() throws InvalidBindingException {
    settings.setBindingEnabled(true);
    settings.setProjectKey("project1");
    settings.setServerId("server1");
    SonarQubeServer server = SonarQubeServer.newBuilder().setName("server1").build();
    globalSettings.setSonarQubeServers(Collections.singletonList(server));
    assertThat(projectBindingManager.getSonarQubeServer()).isEqualTo(server);
}
Also used : SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) Test(org.junit.Test)

Aggregations

SonarQubeServer (org.sonarlint.intellij.config.global.SonarQubeServer)21 Test (org.junit.Test)12 SonarTest (org.sonarlint.intellij.SonarTest)6 InvalidBindingException (org.sonarlint.intellij.exception.InvalidBindingException)6 ConnectedSonarLintEngine (org.sonarsource.sonarlint.core.client.api.connected.ConnectedSonarLintEngine)6 SonarApplication (org.sonarlint.intellij.SonarApplication)4 ServerConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ServerConfiguration)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Project (com.intellij.openapi.project.Project)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 SonarLintProjectSettings (org.sonarlint.intellij.config.project.SonarLintProjectSettings)3 SonarLintConsole (org.sonarlint.intellij.ui.SonarLintConsole)3 CommitStepException (com.intellij.ide.wizard.CommitStepException)2 FileUtil (com.intellij.openapi.util.io.FileUtil)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Collections (java.util.Collections)2 Before (org.junit.Before)2