aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-10-19 14:54:33 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-10-23 08:01:13 -0700
commitd0189372d6db69b38a1af4eab50ebc2ab6721b3f (patch)
tree6f816893ac2edafde245352623876e15d72b65d3
parent3c54405e43bed45afa8ad18770140335c726c54d (diff)
downloadsonarqube-d0189372d6db69b38a1af4eab50ebc2ab6721b3f.tar.gz
sonarqube-d0189372d6db69b38a1af4eab50ebc2ab6721b3f.zip
SONAR-10002 MutableEditionManagementState#installFailed only during install
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/edition/MutableEditionManagementState.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/edition/StandaloneEditionManagementStateImpl.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/edition/StandaloneEditionManagementStateImplTest.java35
3 files changed, 9 insertions, 32 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 69678588805..cd96b760a3d 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
@@ -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);
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 475ed421c36..1b89c142ccc 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
@@ -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();
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 f999efc09e4..db97fb09441 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
@@ -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);
}