*/
package org.sonar.server.organization.ws;
+import org.sonar.api.config.Configuration;
import org.sonar.core.platform.Module;
+import static org.sonar.core.config.WebConstants.SONARCLOUD_ENABLED;
+
public class OrganizationsWsModule extends Module {
+ private final Configuration config;
+
+ public OrganizationsWsModule(Configuration config) {
+ this.config = config;
+ }
+
@Override
protected void configureModule() {
add(
OrganizationsWs.class,
OrganizationsWsSupport.class,
// actions
- AddMemberAction.class,
- CreateAction.class,
- DeleteAction.class,
- EnableSupportAction.class,
- RemoveMemberAction.class,
SearchAction.class,
SearchMembersAction.class,
- SearchMyOrganizationsAction.class,
- UpdateAction.class,
- UpdateProjectVisibilityAction.class);
+ SearchMyOrganizationsAction.class);
+ if (config.getBoolean(SONARCLOUD_ENABLED).orElse(false)) {
+ add(
+ EnableSupportAction.class,
+ AddMemberAction.class,
+ CreateAction.class,
+ DeleteAction.class,
+ RemoveMemberAction.class,
+ UpdateAction.class,
+ UpdateProjectVisibilityAction.class);
+ }
}
}
package org.sonar.server.organization.ws;
import org.junit.Test;
+import org.sonar.api.config.internal.MapSettings;
import org.sonar.core.platform.ComponentContainer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
public class OrganizationsWsModuleTest {
- private OrganizationsWsModule underTest = new OrganizationsWsModule();
+
+ private ComponentContainer container = new ComponentContainer();
+ private MapSettings mapSettings = new MapSettings();
+ private OrganizationsWsModule underTest = new OrganizationsWsModule(mapSettings.asConfig());
+
+ @Test
+ public void verify_component_count_when_not_on_sonar_cloud() {
+ mapSettings.setProperty("sonar.sonarcloud.enabled", false);
+
+ underTest.configure(container);
+
+ assertThat(container.getPicoContainer().getComponentAdapters())
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 5);
+ }
@Test
- public void verify_component_count() {
- ComponentContainer container = new ComponentContainer();
+ public void verify_component_count_when_on_sonar_cloud() {
+ mapSettings.setProperty("sonar.sonarcloud.enabled", true);
+
underTest.configure(container);
+
assertThat(container.getPicoContainer().getComponentAdapters())
.hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12);
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.html5.WebStorage;
-import org.sonarqube.pageobjects.measures.MeasuresPage;
-import org.sonarqube.tests.Tester;
import org.sonarqube.pageobjects.issues.IssuesPage;
+import org.sonarqube.pageobjects.measures.MeasuresPage;
import org.sonarqube.pageobjects.organization.MembersPage;
import org.sonarqube.pageobjects.projects.ProjectsPage;
import org.sonarqube.pageobjects.settings.SettingsPage;
+import org.sonarqube.tests.Tester;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
clearStorage(d -> d.getLocalStorage().clear());
clearStorage(d -> d.getSessionStorage().clear());
clearStorage(d -> clearBrowserLocalStorage());
- return Selenide.open("/", Navigation.class);
+ return Selenide.open("/projects", Navigation.class);
}
private static void clearStorage(Consumer<WebStorage> cleaner) {
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.sonarqube.tests.authorisation.PermissionTemplateTest;
-import org.sonarqube.tests.issue.IssueNotificationsTest;
import org.sonarqube.tests.ce.ReportFailureNotificationTest;
+import org.sonarqube.tests.issue.IssueNotificationsTest;
import org.sonarqube.tests.issue.IssueTagsTest;
import org.sonarqube.tests.issue.OrganizationIssueAssignTest;
import org.sonarqube.tests.issue.OrganizationIssuesPageTest;
// reduce memory for Elasticsearch to 128M
.setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+ .setServerProperty("sonar.sonarcloud.enabled", "true")
+
.build();
}
.getOrchestratorBuilder()
.addPlugin(ItUtils.xooPlugin())
.setServerProperty("sonar.search.httpPort", "" + esHttpPort)
+ .setServerProperty("sonar.sonarcloud.enabled", "true")
.build();
}
package org.sonarqube.tests.issue;
import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
+import org.sonarqube.pageobjects.issues.IssuesPage;
+import org.sonarqube.tests.Category6Suite;
import org.sonarqube.tests.Tester;
import org.sonarqube.ws.Issues;
import org.sonarqube.ws.Issues.Issue;
import org.sonarqube.ws.client.issue.SearchWsRequest;
import org.sonarqube.ws.client.project.CreateRequest;
import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
-import org.sonarqube.pageobjects.issues.IssuesPage;
import util.issue.IssueRule;
import static java.lang.String.format;
private User user;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
org1 = tester.organizations().generate();
org2 = tester.organizations().generate();
user = tester.users().generate();
.getOrchestratorBuilder()
.setServerProperty("sonar.search.recovery.delayInMs", "1000")
.setServerProperty("sonar.search.recovery.minAgeInMs", "3000")
+ .setServerProperty("sonar.sonarcloud.enabled", "true")
.addPlugin(ItUtils.xooPlugin())
.build();
}
"/organization/OrganizationQualityProfilesUiTest/should_display_profile_inheritance.html",
"/organization/OrganizationQualityProfilesUiTest/should_display_profile_exporters.html");
- tester.openBrowser().openHome().logIn().submitCredentials(user.getLogin())
+ tester.openBrowser().logIn().submitCredentials(user.getLogin())
.openQualityProfile("xoo", "sample", organization.getKey())
.shouldHaveAssociatedProject("Sample")
.shouldAllowToChangeProjects();