aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-10-18 12:55:57 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-10-23 08:01:13 -0700
commite385878da500a0f42c096c4607665ca7e8309248 (patch)
treea935552f86772e808d4c93a4f1e8d97a23c7278d /server/sonar-server
parent40441a529bbf9af6735b3d37aebdf7fcb410d443 (diff)
downloadsonarqube-e385878da500a0f42c096c4607665ca7e8309248.tar.gz
sonarqube-e385878da500a0f42c096c4607665ca7e8309248.zip
SONAR-10003 add MutableEditionManagementState#clearInstallErrorMessage
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java79
3 files changed, 94 insertions, 0 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java b/server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java
index ba3235146dc..69678588805 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java
@@ -76,6 +76,12 @@ public interface MutableEditionManagementState extends EditionManagementState {
PendingStatus installFailed(@Nullable String errorMessage);
/**
+ * Clears the error message set by {@link #installFailed(String)} (String)} if there is any and which ever the current
+ * status.
+ */
+ void clearInstallErrorMessage();
+
+ /**
* Uninstalls the currently installed edition
*
* @return the new pending status, always {@link PendingStatus#UNINSTALL_IN_PROGRESS}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java b/server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java
index d9debf0e10a..25b68072782 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java
@@ -175,6 +175,15 @@ public class StandaloneEditionManagementStateImpl implements MutableEditionManag
}
@Override
+ public synchronized void clearInstallErrorMessage() {
+ ensureStarted();
+ if (this.installErrorMessage != null) {
+ this.installErrorMessage = null;
+ persistProperties();
+ }
+ }
+
+ @Override
public synchronized PendingStatus finalizeInstallation() {
ensureStarted();
changeStatusToFrom(NONE, AUTOMATIC_READY, MANUAL_IN_PROGRESS, UNINSTALL_IN_PROGRESS);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java
index 238dcb756b1..ea16c7da7e1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java
@@ -1086,4 +1086,83 @@ public class StandaloneEditionManagementStateImplTest {
expectedException.expectMessage("StandaloneEditionManagementStateImpl is not started");
}
+ @Test
+ public void clearInstallErrorMessage_fails_with_ISE_if_not_started() {
+ expectISENotStarted();
+
+ underTest.clearInstallErrorMessage();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_state() {
+ underTest.start();
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_manualInstall() {
+ underTest.start();
+ underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_automaticInstall() {
+ underTest.start();
+ underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_automaticInstallReady() {
+ underTest.start();
+ underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
+ underTest.automaticInstallReady();
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_automaticInstallFailed_and_clears_message() {
+ underTest.start();
+ underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
+ underTest.installFailed(errorMessage);
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_automaticInstallFailed_without_message() {
+ underTest.start();
+ underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
+ underTest.installFailed(null);
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
+ @Test
+ public void clearInstallErrorMessage_succeeds_after_newEditionWithoutInstall() {
+ underTest.start();
+ underTest.newEditionWithoutInstall(randomAlphanumeric(4));
+
+ underTest.clearInstallErrorMessage();
+
+ assertThat(underTest.getInstallErrorMessage()).isEmpty();
+ }
+
}