]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10003 add MutableEditionManagementState#clearInstallErrorMessage
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 18 Oct 2017 10:55:57 +0000 (12:55 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 23 Oct 2017 15:01:13 +0000 (08:01 -0700)
server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java
server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java
server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java

index ba3235146dc8bca9d25fdf81c7b5312979222a39..69678588805959dbd005d41d5bc8fbfb2879c69e 100644 (file)
@@ -75,6 +75,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
    *
index d9debf0e10afddd3d4d822f3bd565ea8321d8a72..25b68072782717a36226ca90ae2df490059af6ec 100644 (file)
@@ -174,6 +174,15 @@ public class StandaloneEditionManagementStateImpl implements MutableEditionManag
     return this.pendingInstallationStatus;
   }
 
+  @Override
+  public synchronized void clearInstallErrorMessage() {
+    ensureStarted();
+    if (this.installErrorMessage != null) {
+      this.installErrorMessage = null;
+      persistProperties();
+    }
+  }
+
   @Override
   public synchronized PendingStatus finalizeInstallation() {
     ensureStarted();
index 238dcb756b1349048956f4254f4c8755a7e1a68f..ea16c7da7e10ff1a61ac0605e9f6eb888d847834 100644 (file)
@@ -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();
+  }
+
 }