]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10002 MutableEditionManagementState#installFailed only during install
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 19 Oct 2017 12:54:33 +0000 (14:54 +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 69678588805959dbd005d41d5bc8fbfb2879c69e..cd96b760a3d82b0212f77bb428b65cbe5b1b1a86 100644 (file)
@@ -70,8 +70,8 @@ public interface MutableEditionManagementState extends EditionManagementState {
    *
    * @return the new pending status, always {@link PendingStatus#NONE}
    *
-   * @throws IllegalStateException if current status is neither {@link PendingStatus#AUTOMATIC_IN_PROGRESS},
-   *         {@link PendingStatus#AUTOMATIC_READY} nor {@link PendingStatus#MANUAL_IN_PROGRESS}
+   * @throws IllegalStateException if current status is neither {@link PendingStatus#AUTOMATIC_IN_PROGRESS} nor
+   *         {@link PendingStatus#MANUAL_IN_PROGRESS}
    */
   PendingStatus installFailed(@Nullable String errorMessage);
 
index 475ed421c3695b32cf0ddd1563f015ad2d48557d..1b89c142ccc282a61d9f29c4397b5abc2569bb42 100644 (file)
@@ -172,7 +172,7 @@ public class StandaloneEditionManagementStateImpl implements MutableEditionManag
   @Override
   public synchronized PendingStatus installFailed(@Nullable String errorMessage) {
     ensureStarted();
-    State newState = changeStatusToFrom(NONE, AUTOMATIC_IN_PROGRESS, AUTOMATIC_READY, MANUAL_IN_PROGRESS)
+    State newState = changeStatusToFrom(NONE, AUTOMATIC_IN_PROGRESS, MANUAL_IN_PROGRESS)
       .setInstallErrorMessage(nullableTrimmedEmptyToNull(errorMessage))
       .clearPendingFields()
       .build();
index f999efc09e4858e25ebb1cf1991daece40d1a55f..db97fb0944135d9615bcd09d6ed6633dbbbd49ff 100644 (file)
@@ -908,7 +908,7 @@ public class StandaloneEditionManagementStateImplTest {
     underTest.start();
 
     expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_IN_PROGRESS, AUTOMATIC_READY, MANUAL_IN_PROGRESS])");
+    expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_IN_PROGRESS, MANUAL_IN_PROGRESS])");
 
     underTest.installFailed(nullableErrorMessage);
   }
@@ -1033,40 +1033,17 @@ public class StandaloneEditionManagementStateImplTest {
   }
 
   @Test
-  public void installFailed_after_automaticInstallReady_changes_status_to_NONE_stores_non_null_error_message_and_clear_pending_fields_when_current_install_exists() {
+  public void installFailed_fails_with_ISE_after_automaticInstallReady() {
     underTest.start();
     String currentEdition = "current-edition";
     underTest.newEditionWithoutInstall(currentEdition);
     underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
     underTest.automaticInstallReady();
-    String errorMessage = randomAlphanumeric(4);
-
-    PendingStatus newStatus = underTest.installFailed(errorMessage);
-
-    assertThat(newStatus).isEqualTo(NONE);
-    assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
-    assertThat(underTest.getPendingEditionKey()).isEmpty();
-    assertThat(underTest.getPendingLicense()).isEmpty();
-    assertThat(underTest.getCurrentEditionKey()).contains(currentEdition);
-    assertThat(underTest.getInstallErrorMessage()).contains(errorMessage);
-  }
 
-  @Test
-  public void installFailed_after_automaticInstallReady_changes_status_to_NONE_without_error_message_and_clear_pending_fields_when_current_install_exists() {
-    underTest.start();
-    String currentEdition = "current-edition";
-    underTest.newEditionWithoutInstall(currentEdition);
-    underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
-    underTest.automaticInstallReady();
-
-    PendingStatus newStatus = underTest.installFailed(null);
+    expectedException.expect(IllegalStateException.class);
+    expectedException.expectMessage("Can't move to NONE when status is AUTOMATIC_READY (should be any of [AUTOMATIC_IN_PROGRESS, MANUAL_IN_PROGRESS])");
 
-    assertThat(newStatus).isEqualTo(NONE);
-    assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
-    assertThat(underTest.getPendingEditionKey()).isEmpty();
-    assertThat(underTest.getPendingLicense()).isEmpty();
-    assertThat(underTest.getCurrentEditionKey()).contains(currentEdition);
-    assertThat(underTest.getInstallErrorMessage()).isEmpty();
+    underTest.installFailed(nullableErrorMessage);
   }
 
   @Test
@@ -1076,7 +1053,7 @@ public class StandaloneEditionManagementStateImplTest {
     underTest.installFailed(nullableErrorMessage);
 
     expectedException.expect(IllegalStateException.class);
-    expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_IN_PROGRESS, AUTOMATIC_READY, MANUAL_IN_PROGRESS])");
+    expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_IN_PROGRESS, MANUAL_IN_PROGRESS])");
 
     underTest.installFailed(nullableErrorMessage);
   }