aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorAurelien Poscia <aurelien.poscia@sonarsource.com>2022-12-21 09:15:42 +0100
committersonartech <sonartech@sonarsource.com>2022-12-23 20:02:51 +0000
commitc3f0febf8d6c2e1baa376e28c212c6feb9f30525 (patch)
tree7637ba7ef02af9b02beb8e7daa1f089f56123301 /server/sonar-webserver-webapi
parent6bf8a78f319ad666cb31d2100910dd34e5fcaf13 (diff)
downloadsonarqube-c3f0febf8d6c2e1baa376e28c212c6feb9f30525.tar.gz
sonarqube-c3f0febf8d6c2e1baa376e28c212c6feb9f30525.zip
SONAR-14128 Renamed WebServer to NodeInformation
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java14
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java42
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java18
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java12
15 files changed, 95 insertions, 95 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java
index 44b24091b9f..f3841d4bcac 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/health/HealthCheckerImpl.java
@@ -25,7 +25,7 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.process.cluster.health.NodeHealth;
import org.sonar.process.cluster.health.SharedHealthState;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.springframework.beans.factory.annotation.Autowired;
import static com.google.common.base.Preconditions.checkState;
@@ -36,7 +36,7 @@ import static com.google.common.collect.ImmutableList.copyOf;
* available in the container.
*/
public class HealthCheckerImpl implements HealthChecker {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
private final List<NodeHealthCheck> nodeHealthChecks;
private final List<ClusterHealthCheck> clusterHealthChecks;
@CheckForNull
@@ -46,17 +46,17 @@ public class HealthCheckerImpl implements HealthChecker {
* Constructor used by the ioc container in standalone mode and in safe mode.
*/
@Autowired(required = false)
- public HealthCheckerImpl(WebServer webServer, NodeHealthCheck[] nodeHealthChecks) {
- this(webServer, nodeHealthChecks, new ClusterHealthCheck[0], null);
+ public HealthCheckerImpl(NodeInformation nodeInformation, NodeHealthCheck[] nodeHealthChecks) {
+ this(nodeInformation, nodeHealthChecks, new ClusterHealthCheck[0], null);
}
/**
* Constructor used by the ioc container in cluster mode.
*/
@Autowired(required = false)
- public HealthCheckerImpl(WebServer webServer, NodeHealthCheck[] nodeHealthChecks, ClusterHealthCheck[] clusterHealthChecks,
+ public HealthCheckerImpl(NodeInformation nodeInformation, NodeHealthCheck[] nodeHealthChecks, ClusterHealthCheck[] clusterHealthChecks,
@Nullable SharedHealthState sharedHealthState) {
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
this.nodeHealthChecks = copyOf(nodeHealthChecks);
this.clusterHealthChecks = copyOf(clusterHealthChecks);
this.sharedHealthState = sharedHealthState;
@@ -71,7 +71,7 @@ public class HealthCheckerImpl implements HealthChecker {
@Override
public ClusterHealth checkCluster() {
- checkState(!webServer.isStandalone(), "Clustering is not enabled");
+ checkState(!nodeInformation.isStandalone(), "Clustering is not enabled");
checkState(sharedHealthState != null, "HealthState instance can't be null when clustering is enabled");
Set<NodeHealth> nodeHealths = sharedHealthState.readAll();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
index c50d3fd62d3..a7401d18886 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
@@ -20,18 +20,18 @@
package org.sonar.server.platform.ws;
import org.sonar.core.platform.Module;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
public class ChangeLogLevelServiceModule extends Module {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
- public ChangeLogLevelServiceModule(WebServer webServer) {
- this.webServer = webServer;
+ public ChangeLogLevelServiceModule(NodeInformation nodeInformation) {
+ this.nodeInformation = nodeInformation;
}
@Override
protected void configureModule() {
- if (webServer.isStandalone()) {
+ if (nodeInformation.isStandalone()) {
add(ChangeLogLevelStandaloneService.class);
} else {
add(ChangeLogLevelClusterService.class);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java
index 42a2211a559..394fa418ce0 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthAction.java
@@ -23,19 +23,19 @@ import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.user.SystemPasscode;
import org.sonar.server.user.UserSession;
import org.sonar.server.ws.WsUtils;
public class HealthAction implements SystemWsAction {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
private final HealthActionSupport support;
private final SystemPasscode systemPasscode;
private final UserSession userSession;
- public HealthAction(WebServer webServer, HealthActionSupport support, SystemPasscode systemPasscode, UserSession userSession) {
- this.webServer = webServer;
+ public HealthAction(NodeInformation nodeInformation, HealthActionSupport support, SystemPasscode systemPasscode, UserSession userSession) {
+ this.nodeInformation = nodeInformation;
this.support = support;
this.systemPasscode = systemPasscode;
this.userSession = userSession;
@@ -52,7 +52,7 @@ public class HealthAction implements SystemWsAction {
throw new ForbiddenException("Insufficient privileges");
}
- if (webServer.isStandalone()) {
+ if (nodeInformation.isStandalone()) {
WsUtils.writeProtobuf(support.checkNodeHealth(), request, response);
} else {
WsUtils.writeProtobuf(support.checkClusterHealth(), request, response);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
index 61c3248eb65..f5646eaa6cf 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
@@ -27,13 +27,13 @@ import org.sonar.server.health.EsStatusClusterCheck;
import org.sonar.server.health.EsStatusNodeCheck;
import org.sonar.server.health.HealthCheckerImpl;
import org.sonar.server.health.WebServerStatusNodeCheck;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
public class HealthCheckerModule extends Module {
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
- public HealthCheckerModule(WebServer webServer) {
- this.webServer = webServer;
+ public HealthCheckerModule(NodeInformation nodeInformation) {
+ this.nodeInformation = nodeInformation;
}
@Override
@@ -42,7 +42,7 @@ public class HealthCheckerModule extends Module {
add(WebServerStatusNodeCheck.class,
DbConnectionNodeCheck.class,
CeStatusNodeCheck.class);
- if (webServer.isStandalone()) {
+ if (nodeInformation.isStandalone()) {
add(EsStatusNodeCheck.class);
} else {
// ClusterHealthCheck implementations
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java
index de87d55c6c3..951cfe022d1 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/RestartAction.java
@@ -26,7 +26,7 @@ import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.server.app.ProcessCommandWrapper;
import org.sonar.server.app.RestartFlagHolder;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.user.UserSession;
/**
@@ -39,14 +39,14 @@ public class RestartAction implements SystemWsAction {
private final UserSession userSession;
private final ProcessCommandWrapper processCommandWrapper;
private final RestartFlagHolder restartFlagHolder;
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
public RestartAction(UserSession userSession, ProcessCommandWrapper processCommandWrapper, RestartFlagHolder restartFlagHolder,
- WebServer webServer) {
+ NodeInformation nodeInformation) {
this.userSession = userSession;
this.processCommandWrapper = processCommandWrapper;
this.restartFlagHolder = restartFlagHolder;
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
}
@Override
@@ -61,7 +61,7 @@ public class RestartAction implements SystemWsAction {
@Override
public void handle(Request request, Response response) {
- if (!webServer.isStandalone()) {
+ if (!nodeInformation.isStandalone()) {
throw new IllegalArgumentException("Restart not allowed for cluster nodes");
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
index fd59388942d..bbe34987ba0 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
@@ -39,7 +39,7 @@ import org.sonar.db.DbSession;
import org.sonar.db.dialect.H2;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ui.VersionFormatter;
import org.sonar.server.ui.WebAnalyticsLoader;
@@ -69,7 +69,7 @@ public class GlobalAction implements NavigationWsAction, Startable {
private final Configuration config;
private final ResourceTypes resourceTypes;
private final Server server;
- private final WebServer webServer;
+ private final NodeInformation nodeInformation;
private final DbClient dbClient;
private final UserSession userSession;
private final PlatformEditionProvider editionProvider;
@@ -78,14 +78,14 @@ public class GlobalAction implements NavigationWsAction, Startable {
private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier;
public GlobalAction(PageRepository pageRepository, Configuration config, ResourceTypes resourceTypes, Server server,
- WebServer webServer, DbClient dbClient, UserSession userSession, PlatformEditionProvider editionProvider,
+ NodeInformation nodeInformation, DbClient dbClient, UserSession userSession, PlatformEditionProvider editionProvider,
WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker,
DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier) {
this.pageRepository = pageRepository;
this.config = config;
this.resourceTypes = resourceTypes;
this.server = server;
- this.webServer = webServer;
+ this.nodeInformation = nodeInformation;
this.dbClient = dbClient;
this.userSession = userSession;
this.editionProvider = editionProvider;
@@ -129,7 +129,7 @@ public class GlobalAction implements NavigationWsAction, Startable {
writeInstanceUsesDefaultAdminCredentials(json);
editionProvider.get().ifPresent(e -> json.prop("edition", e.name().toLowerCase(Locale.ENGLISH)));
writeNeedIssueSync(json);
- json.prop("standalone", webServer.isStandalone());
+ json.prop("standalone", nodeInformation.isStandalone());
writeWebAnalytics(json);
json.endObject();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java
index 5255dd6d7f7..fa51c868275 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/projectdump/ExportSubmitterImplTest.java
@@ -29,7 +29,7 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.component.ComponentDto;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -45,7 +45,7 @@ public class ExportSubmitterImplTest {
public DbTester db = DbTester.create(system2);
private final DbClient dbClient = db.getDbClient();
- private final CeQueue ceQueue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(WebServer.class));
+ private final CeQueue ceQueue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(NodeInformation.class));
private final ExportSubmitterImpl underTest = new ExportSubmitterImpl(ceQueue, dbClient);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
index 6086a1219b6..16de1288fb0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/ws/CancelActionTest.java
@@ -36,7 +36,7 @@ import org.sonar.db.ce.CeQueueDto;
import org.sonar.db.ce.CeTaskTypes;
import org.sonar.db.component.ComponentDto;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
@@ -53,7 +53,7 @@ public class CancelActionTest {
public DbTester db = DbTester.create();
private System2 system2 = new TestSystem2();
- private CeQueue queue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(WebServer.class));
+ private CeQueue queue = new CeQueueImpl(system2, db.getDbClient(), UuidFactoryFast.getInstance(), mock(NodeInformation.class));
private CancelAction underTest = new CancelAction(userSession, db.getDbClient(), queue);
private WsActionTester tester = new WsActionTester(underTest);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
index 127163463ce..fd1572b0229 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthCheckerImplTest.java
@@ -32,7 +32,7 @@ import org.junit.Test;
import org.sonar.process.cluster.health.NodeDetails;
import org.sonar.process.cluster.health.NodeHealth;
import org.sonar.process.cluster.health.SharedHealthState;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,13 +49,13 @@ import static org.sonar.server.health.Health.Status.YELLOW;
public class HealthCheckerImplTest {
- private final WebServer webServer = mock(WebServer.class);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
private final SharedHealthState sharedHealthState = mock(SharedHealthState.class);
private final Random random = new Random();
@Test
public void check_returns_green_status_without_any_cause_when_there_is_no_NodeHealthCheck() {
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0]);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0]);
assertThat(underTest.checkNode()).isEqualTo(Health.GREEN);
}
@@ -109,15 +109,15 @@ public class HealthCheckerImplTest {
.toArray(NodeHealthCheck[]::new);
String[] expected = Arrays.stream(nodeHealthChecks).map(NodeHealthCheck::check).flatMap(s -> s.getCauses().stream()).toArray(String[]::new);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, nodeHealthChecks);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, nodeHealthChecks);
assertThat(underTest.checkNode().getCauses()).containsOnly(expected);
}
@Test
public void checkCluster_fails_with_ISE_in_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
+ when(nodeInformation.isStandalone()).thenReturn(true);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
assertThatThrownBy(() -> underTest.checkCluster())
.isInstanceOf(IllegalStateException.class)
@@ -126,8 +126,8 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_fails_with_ISE_in_clustering_and_HealthState_is_null() {
- when(webServer.isStandalone()).thenReturn(false);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], null);
+ when(nodeInformation.isStandalone()).thenReturn(false);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], null);
assertThatThrownBy(() -> underTest.checkCluster())
.isInstanceOf(IllegalStateException.class)
@@ -136,15 +136,15 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_GREEN_when_there_is_no_ClusterHealthCheck() {
- when(webServer.isStandalone()).thenReturn(false);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
+ when(nodeInformation.isStandalone()).thenReturn(false);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
assertThat(underTest.checkCluster().getHealth()).isEqualTo(Health.GREEN);
}
@Test
public void checkCluster_returns_GREEN_status_if_only_GREEN_statuses_returned_by_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<Health.Status> statuses = IntStream.range(1, 1 + random.nextInt(20)).mapToObj(i -> GREEN).collect(Collectors.toList());
HealthCheckerImpl underTest = newClusterHealthCheckerImpl(statuses.stream());
@@ -155,7 +155,7 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_YELLOW_status_if_only_GREEN_and_at_least_one_YELLOW_statuses_returned_by_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<Health.Status> statuses = new ArrayList<>();
Stream.concat(
IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> YELLOW), // at least 1 YELLOW
@@ -170,7 +170,7 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_RED_status_if_at_least_one_RED_status_returned_by_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<Health.Status> statuses = new ArrayList<>();
Stream.of(
IntStream.range(0, 1 + random.nextInt(20)).mapToObj(i -> RED), // at least 1 RED
@@ -188,7 +188,7 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_causes_of_all_ClusterHealthChecks_whichever_their_status() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
List<String[]> causesGroups = IntStream.range(0, 1 + random.nextInt(20))
.mapToObj(s -> IntStream.range(0, random.nextInt(3)).mapToObj(i -> randomAlphanumeric(3)).toArray(String[]::new))
.collect(Collectors.toList());
@@ -198,14 +198,14 @@ public class HealthCheckerImplTest {
.toArray(ClusterHealthCheck[]::new);
String[] expectedCauses = causesGroups.stream().flatMap(Arrays::stream).toArray(String[]::new);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], clusterHealthChecks, sharedHealthState);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], clusterHealthChecks, sharedHealthState);
assertThat(underTest.checkCluster().getHealth().getCauses()).containsOnly(expectedCauses);
}
@Test
public void checkCluster_passes_set_of_NodeHealth_returns_by_HealthState_to_all_ClusterHealthChecks() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ClusterHealthCheck[] mockedClusterHealthChecks = IntStream.range(0, 1 + random.nextInt(3))
.mapToObj(i -> mock(ClusterHealthCheck.class))
.toArray(ClusterHealthCheck[]::new);
@@ -215,7 +215,7 @@ public class HealthCheckerImplTest {
when(mockedClusterHealthCheck.check(same(nodeHealths))).thenReturn(Health.GREEN);
}
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], mockedClusterHealthChecks, sharedHealthState);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], mockedClusterHealthChecks, sharedHealthState);
underTest.checkCluster();
for (ClusterHealthCheck mockedClusterHealthCheck : mockedClusterHealthChecks) {
@@ -225,11 +225,11 @@ public class HealthCheckerImplTest {
@Test
public void checkCluster_returns_NodeHealths_returned_by_HealthState() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
Set<NodeHealth> nodeHealths = IntStream.range(0, 1 + random.nextInt(4)).mapToObj(i -> randomNodeHealth()).collect(Collectors.toSet());
when(sharedHealthState.readAll()).thenReturn(nodeHealths);
- HealthCheckerImpl underTest = new HealthCheckerImpl(webServer, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
+ HealthCheckerImpl underTest = new HealthCheckerImpl(nodeInformation, new NodeHealthCheck[0], new ClusterHealthCheck[0], sharedHealthState);
ClusterHealth clusterHealth = underTest.checkCluster();
assertThat(clusterHealth.getNodes()).isEqualTo(nodeHealths);
@@ -251,14 +251,14 @@ public class HealthCheckerImplTest {
private HealthCheckerImpl newNodeHealthCheckerImpl(Stream<Health.Status> statuses) {
Stream<HardcodedHealthNodeCheck> staticHealthCheckStream = statuses.map(HardcodedHealthNodeCheck::new);
return new HealthCheckerImpl(
- webServer,
+ nodeInformation,
staticHealthCheckStream.map(NodeHealthCheck.class::cast).toArray(NodeHealthCheck[]::new));
}
private HealthCheckerImpl newClusterHealthCheckerImpl(Stream<Health.Status> statuses) {
Stream<HardcodedHealthClusterCheck> staticHealthCheckStream = statuses.map(HardcodedHealthClusterCheck::new);
return new HealthCheckerImpl(
- webServer,
+ nodeInformation,
new NodeHealthCheck[0],
staticHealthCheckStream.map(ClusterHealthCheck.class::cast).toArray(ClusterHealthCheck[]::new),
sharedHealthState);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
index 21c00a6a403..65183c73d1c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
@@ -21,19 +21,19 @@ package org.sonar.server.platform.ws;
import org.junit.Test;
import org.sonar.core.platform.ListContainer;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class ChangeLogLevelServiceModuleTest {
- private final WebServer webServer = mock(WebServer.class);
- private final ChangeLogLevelServiceModule underTest = new ChangeLogLevelServiceModule(webServer);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
+ private final ChangeLogLevelServiceModule underTest = new ChangeLogLevelServiceModule(nodeInformation);
@Test
public void provide_returns_ChangeLogLevelClusterService() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -43,7 +43,7 @@ public class ChangeLogLevelServiceModuleTest {
@Test
public void provide_returns_ChangeLogLevelStandaloneService_if_SQ_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
ListContainer container = new ListContainer();
underTest.configure(container);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
index 76d47596723..4de9869a6f0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionTest.java
@@ -38,7 +38,7 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.health.ClusterHealth;
import org.sonar.server.health.Health;
import org.sonar.server.health.HealthChecker;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.user.SystemPasscode;
import org.sonar.server.ws.TestRequest;
@@ -69,9 +69,9 @@ public class HealthActionTest {
private final Random random = new Random();
private HealthChecker healthChecker = mock(HealthChecker.class);
- private WebServer webServer = mock(WebServer.class);
+ private NodeInformation nodeInformation = mock(NodeInformation.class);
private SystemPasscode systemPasscode = mock(SystemPasscode.class);
- private WsActionTester underTest = new WsActionTester(new HealthAction(webServer, new HealthActionSupport(healthChecker), systemPasscode, userSessionRule));
+ private WsActionTester underTest = new WsActionTester(new HealthAction(nodeInformation, new HealthActionSupport(healthChecker), systemPasscode, userSessionRule));
@Test
public void verify_definition() {
@@ -134,7 +134,7 @@ public class HealthActionTest {
@Test
public void verify_response_example() {
authenticateWithRandomMethod();
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
long time = parseDateTime("2015-08-13T23:34:59+0200").getTime();
when(healthChecker.checkCluster())
.thenReturn(
@@ -183,7 +183,7 @@ public class HealthActionTest {
IntStream.range(0, new Random().nextInt(5)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).forEach(builder::addCause);
Health health = builder.build();
when(healthChecker.checkNode()).thenReturn(health);
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
TestRequest request = underTest.newRequest();
System.HealthResponse healthResponse = request.executeProtobuf(System.HealthResponse.class);
@@ -199,7 +199,7 @@ public class HealthActionTest {
Health.Builder healthBuilder = Health.builder()
.setStatus(randomStatus);
Arrays.stream(causes).forEach(healthBuilder::addCause);
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(healthBuilder.build(), emptySet()));
System.HealthResponse clusterHealthResponse = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
@@ -213,7 +213,7 @@ public class HealthActionTest {
public void response_contains_information_of_nodes_when_clustered() {
authenticateWithRandomMethod();
NodeHealth nodeHealth = randomNodeHealth();
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(GREEN, singleton(nodeHealth)));
System.HealthResponse response = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
@@ -255,7 +255,7 @@ public class HealthActionTest {
String[] expected = nodeHealths.stream().map(s -> formatDateTime(new Date(s.getDetails().getStartedAt()))).toArray(String[]::new);
Collections.shuffle(nodeHealths);
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
when(healthChecker.checkCluster()).thenReturn(new ClusterHealth(GREEN, new HashSet<>(nodeHealths)));
System.HealthResponse response = underTest.newRequest().executeProtobuf(System.HealthResponse.class);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
index b91322ca303..f20785d7454 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import org.junit.Test;
+import org.sonar.core.platform.ListContainer;
import org.sonar.server.health.AppNodeClusterCheck;
import org.sonar.server.health.CeStatusNodeCheck;
import org.sonar.server.health.ClusterHealthCheck;
@@ -32,21 +33,20 @@ import org.sonar.server.health.EsStatusNodeCheck;
import org.sonar.server.health.HealthCheckerImpl;
import org.sonar.server.health.NodeHealthCheck;
import org.sonar.server.health.WebServerStatusNodeCheck;
-import org.sonar.core.platform.ListContainer;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class HealthCheckerModuleTest {
- private final WebServer webServer = mock(WebServer.class);
- private final HealthCheckerModule underTest = new HealthCheckerModule(webServer);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
+ private final HealthCheckerModule underTest = new HealthCheckerModule(nodeInformation);
@Test
public void verify_HealthChecker() {
boolean standalone = new Random().nextBoolean();
- when(webServer.isStandalone()).thenReturn(standalone);
+ when(nodeInformation.isStandalone()).thenReturn(standalone);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -61,7 +61,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_NodeHealthChecks_implementations_when_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -75,7 +75,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_NodeHealthChecks_implementations_when_clustered() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -89,7 +89,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_ClusterHealthChecks_implementations_in_standalone() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
ListContainer container = new ListContainer();
underTest.configure(container);
@@ -103,7 +103,7 @@ public class HealthCheckerModuleTest {
@Test
public void verify_installed_ClusterHealthChecks_implementations_in_clustering() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
ListContainer container = new ListContainer();
underTest.configure(container);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
index c06798ff59b..5d63f8a6ae9 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
@@ -28,7 +28,7 @@ import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.server.app.ProcessCommandWrapper;
import org.sonar.server.app.RestartFlagHolder;
import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
@@ -45,15 +45,15 @@ public class RestartActionTest {
private ProcessCommandWrapper processCommandWrapper = mock(ProcessCommandWrapper.class);
private RestartFlagHolder restartFlagHolder = mock(RestartFlagHolder.class);
- private WebServer webServer = mock(WebServer.class);
- private RestartAction sut = new RestartAction(userSessionRule, processCommandWrapper, restartFlagHolder, webServer);
+ private NodeInformation nodeInformation = mock(NodeInformation.class);
+ private RestartAction sut = new RestartAction(userSessionRule, processCommandWrapper, restartFlagHolder, nodeInformation);
private InOrder inOrder = Mockito.inOrder(restartFlagHolder, processCommandWrapper);
private WsActionTester actionTester = new WsActionTester(sut);
@Test
public void request_fails_in_production_mode_with_ForbiddenException_when_user_is_not_logged_in() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
assertThatThrownBy(() -> actionTester.newRequest().execute())
.isInstanceOf(ForbiddenException.class);
@@ -61,7 +61,7 @@ public class RestartActionTest {
@Test
public void request_fails_in_production_mode_with_ForbiddenException_when_user_is_not_system_administrator() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
userSessionRule.logIn().setNonSystemAdministrator();
assertThatThrownBy(() -> actionTester.newRequest().execute())
@@ -70,7 +70,7 @@ public class RestartActionTest {
@Test
public void request_fails_in_cluster_mode_with_IllegalArgumentException() {
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
assertThatThrownBy(() -> actionTester.newRequest().execute())
.isInstanceOf(IllegalArgumentException.class)
@@ -79,7 +79,7 @@ public class RestartActionTest {
@Test
public void calls_ProcessCommandWrapper_requestForSQRestart_in_production_mode() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
userSessionRule.logIn().setSystemAdministrator();
actionTester.newRequest().execute();
@@ -90,7 +90,7 @@ public class RestartActionTest {
@Test
public void logs_login_of_authenticated_user_requesting_the_restart_in_production_mode() {
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
String login = "BigBother";
userSessionRule.logIn(login).setSystemAdministrator();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
index 4fa843fd22f..182adb66d1e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
@@ -23,8 +23,8 @@ import org.junit.Test;
import org.sonar.api.server.ws.WebService;
import org.sonar.server.app.ProcessCommandWrapper;
import org.sonar.server.app.RestartFlagHolder;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.platform.SystemInfoWriter;
-import org.sonar.server.platform.WebServer;
import org.sonar.server.tester.AnonymousMockUserSession;
import org.sonar.server.user.UserSession;
@@ -36,7 +36,7 @@ public class SystemWsTest {
@Test
public void define() {
RestartAction action1 = new RestartAction(mock(UserSession.class), mock(ProcessCommandWrapper.class),
- mock(RestartFlagHolder.class), mock(WebServer.class));
+ mock(RestartFlagHolder.class), mock(NodeInformation.class));
InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(SystemInfoWriter.class));
SystemWs ws = new SystemWs(action1, action2);
WebService.Context context = new WebService.Context();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
index bdcb1b773b9..f0c048ab946 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
@@ -39,7 +39,7 @@ import org.sonar.db.dialect.H2;
import org.sonar.db.dialect.PostgreSql;
import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
-import org.sonar.server.platform.WebServer;
+import org.sonar.server.platform.NodeInformation;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ui.PageRepository;
import org.sonar.server.ui.WebAnalyticsLoader;
@@ -61,7 +61,7 @@ public class GlobalActionTest {
private final MapSettings settings = new MapSettings();
private final Server server = mock(Server.class);
- private final WebServer webServer = mock(WebServer.class);
+ private final NodeInformation nodeInformation = mock(NodeInformation.class);
private final DbClient dbClient = mock(DbClient.class, RETURNS_DEEP_STUBS);
private final IssueIndexSyncProgressChecker indexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
private final BranchFeatureRule branchFeature = new BranchFeatureRule();
@@ -244,7 +244,7 @@ public class GlobalActionTest {
public void standalone_flag() {
init();
userSession.logIn().setSystemAdministrator();
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
assertJson(call()).isSimilarTo("{\"standalone\":true}");
}
@@ -253,7 +253,7 @@ public class GlobalActionTest {
public void not_standalone_flag() {
init();
userSession.logIn().setSystemAdministrator();
- when(webServer.isStandalone()).thenReturn(false);
+ when(nodeInformation.isStandalone()).thenReturn(false);
assertJson(call()).isSimilarTo("{\"standalone\":false}");
}
@@ -280,7 +280,7 @@ public class GlobalActionTest {
});
when(server.getVersion()).thenReturn("6.2");
when(dbClient.getDatabase().getDialect()).thenReturn(new PostgreSql());
- when(webServer.isStandalone()).thenReturn(true);
+ when(nodeInformation.isStandalone()).thenReturn(true);
when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
String result = call();
@@ -343,7 +343,7 @@ public class GlobalActionTest {
}});
pageRepository.start();
GlobalAction wsAction = new GlobalAction(pageRepository, settings.asConfig(), new ResourceTypes(resourceTypeTrees), server,
- webServer, dbClient, userSession, editionProvider, webAnalyticsLoader,
+ nodeInformation, dbClient, userSession, editionProvider, webAnalyticsLoader,
indexSyncProgressChecker, defaultAdminCredentialsVerifier);
ws = new WsActionTester(wsAction);
wsAction.start();