3 * Copyright (C) 2009-2017 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.edition;
22 import java.util.Collections;
23 import java.util.Random;
24 import org.junit.Rule;
25 import org.junit.Test;
26 import org.junit.rules.ExpectedException;
27 import org.sonar.api.utils.System2;
28 import org.sonar.db.DbClient;
29 import org.sonar.db.DbTester;
30 import org.sonar.server.edition.EditionManagementState.PendingStatus;
32 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
33 import static org.assertj.core.api.Assertions.assertThat;
34 import static org.sonar.server.edition.EditionManagementState.PendingStatus.AUTOMATIC_IN_PROGRESS;
35 import static org.sonar.server.edition.EditionManagementState.PendingStatus.AUTOMATIC_READY;
36 import static org.sonar.server.edition.EditionManagementState.PendingStatus.MANUAL_IN_PROGRESS;
37 import static org.sonar.server.edition.EditionManagementState.PendingStatus.NONE;
38 import static org.sonar.server.edition.EditionManagementState.PendingStatus.UNINSTALL_IN_PROGRESS;
40 public class StandaloneEditionManagementStateImplTest {
41 private static final License LICENSE_WITHOUT_PLUGINS = new License(randomAlphanumeric(3), Collections.emptyList(), randomAlphanumeric(10));
44 public DbTester dbTester = DbTester.create(System2.INSTANCE);
46 public ExpectedException expectedException = ExpectedException.none();
48 private DbClient dbClient = dbTester.getDbClient();
49 private final StandaloneEditionManagementStateImpl underTest = new StandaloneEditionManagementStateImpl(dbClient);
52 public void getCurrentEditionKey_fails_with_ISE_if_start_has_not_been_called() {
53 expectISENotStarted();
55 underTest.getCurrentEditionKey();
59 public void getCurrentEditionKey_returns_empty_when_internal_properties_table_is_empty() {
62 assertThat(underTest.getCurrentEditionKey()).isEmpty();
66 public void getCurrentEditionKey_returns_value_in_db_for_key_currentEditionKey() {
67 String value = randomAlphanumeric(10);
68 dbTester.properties().insertInternal("currentEditionKey", value);
71 assertThat(underTest.getCurrentEditionKey()).contains(value);
75 public void getCurrentEditionKey_returns_empty_when_value_in_db_is_empty_for_key_currentEditionKey() {
76 dbTester.properties().insertEmptyInternal("currentEditionKey");
79 assertThat(underTest.getCurrentEditionKey()).isEmpty();
83 public void getPendingInstallationStatus_fails_with_ISE_if_start_has_not_been_called() {
84 expectISENotStarted();
86 underTest.getPendingInstallationStatus();
90 public void getPendingInstallationStatus_returns_NONE_when_internal_properties_table_is_empty() {
93 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
97 public void getPendingInstallationStatus_returns_value_in_db_for_key_pendingInstallStatus() {
98 PendingStatus value = PendingStatus.values()[new Random().nextInt(PendingStatus.values().length)];
99 dbTester.properties().insertInternal("pendingInstallStatus", value.name());
102 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(value);
106 public void getPendingInstallationStatus_returns_NONE_when_value_in_db_is_empty_for_key_pendingInstallStatus() {
107 dbTester.properties().insertEmptyInternal("pendingInstallStatus");
110 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
114 public void start_fails_when_value_in_db_for_key_pendingInstallStatus_cannot_be_parsed_to_enum() {
115 String value = randomAlphanumeric(30);
116 dbTester.properties().insertInternal("pendingInstallStatus", value);
118 expectedException.expect(IllegalArgumentException.class);
119 expectedException.expectMessage("No enum constant org.sonar.server.edition.EditionManagementState.PendingStatus." + value);
125 public void getPendingEditionKey_fails_with_ISE_if_start_has_not_been_called() {
126 expectISENotStarted();
128 underTest.getPendingEditionKey();
132 public void getPendingEditionKey_returns_empty_when_internal_properties_table_is_empty() {
135 assertThat(underTest.getPendingEditionKey()).isEmpty();
139 public void getPendingEditionKey_returns_value_in_db_for_key_pendingEditionKey() {
140 String value = randomAlphanumeric(10);
141 dbTester.properties().insertInternal("pendingEditionKey", value);
144 assertThat(underTest.getPendingEditionKey()).contains(value);
148 public void getPendingEditionKey_returns_empty_when_value_in_db_is_empty_for_key_pendingEditionKey() {
149 dbTester.properties().insertEmptyInternal("pendingEditionKey");
152 assertThat(underTest.getPendingEditionKey()).isEmpty();
156 public void getPendingLicense_fails_with_ISE_if_start_has_not_been_called() {
157 expectISENotStarted();
159 underTest.getPendingLicense();
163 public void getPendingLicense_returns_empty_when_internal_properties_table_is_empty() {
166 assertThat(underTest.getPendingLicense()).isEmpty();
170 public void getPendingLicense_returns_empty_value_in_db_for_key_pendingLicense() {
171 String value = randomAlphanumeric(10);
172 dbTester.properties().insertInternal("pendingLicense", value);
175 assertThat(underTest.getPendingLicense()).contains(value);
179 public void getPendingLicense_returns_empty_when_value_in_db_is_empty_for_key_pendingLicense() {
180 dbTester.properties().insertEmptyInternal("pendingLicense");
183 assertThat(underTest.getPendingLicense()).isEmpty();
187 public void startAutomaticInstall_fails_with_ISE_if_not_started() {
188 expectISENotStarted();
190 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
194 public void startAutomaticInstall_fails_with_NPE_if_license_is_null() {
197 expectedException.expect(NullPointerException.class);
198 expectedException.expectMessage("license can't be null");
200 underTest.startAutomaticInstall(null);
204 public void startAutomaticInstall_sets_pending_fields_after_start() {
207 PendingStatus newStatus = underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
209 assertThat(newStatus).isEqualTo(AUTOMATIC_IN_PROGRESS);
210 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(AUTOMATIC_IN_PROGRESS);
211 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
212 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
213 assertThat(underTest.getCurrentEditionKey()).isEmpty();
217 public void startAutomaticInstall_sets_pending_fields_after_start_with_existing_currentEditionKey() {
218 String value = randomAlphanumeric(10);
219 dbTester.properties().insertInternal("currentEditionKey", value);
222 PendingStatus newStatus = underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
224 assertThat(newStatus).isEqualTo(AUTOMATIC_IN_PROGRESS);
225 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(AUTOMATIC_IN_PROGRESS);
226 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
227 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
228 assertThat(underTest.getCurrentEditionKey()).contains(value);
232 public void startAutomaticInstall_sets_pending_fields_after_newEditionWithoutInstall() {
233 String value = randomAlphanumeric(10);
235 underTest.newEditionWithoutInstall(value);
237 PendingStatus newStatus = underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
239 assertThat(newStatus).isEqualTo(AUTOMATIC_IN_PROGRESS);
240 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(AUTOMATIC_IN_PROGRESS);
241 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
242 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
243 assertThat(underTest.getCurrentEditionKey()).contains(value);
247 public void startAutomaticInstall_fails_with_ISE_if_called_after_startAutomaticInstall() {
249 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
251 expectedException.expect(IllegalStateException.class);
252 expectedException.expectMessage("Can't move to AUTOMATIC_IN_PROGRESS when status is AUTOMATIC_IN_PROGRESS (should be any of [NONE])");
254 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
258 public void startAutomaticInstall_fails_with_ISE_if_called_after_automaticInstallReady() {
260 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
261 underTest.automaticInstallReady();
263 expectedException.expect(IllegalStateException.class);
264 expectedException.expectMessage("Can't move to AUTOMATIC_IN_PROGRESS when status is AUTOMATIC_READY (should be any of [NONE])");
266 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
270 public void startAutomaticInstall_fails_with_ISE_if_called_after_manualInstall() {
272 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
274 expectedException.expect(IllegalStateException.class);
275 expectedException.expectMessage("Can't move to AUTOMATIC_IN_PROGRESS when status is MANUAL_IN_PROGRESS (should be any of [NONE])");
277 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
281 public void uninstall_fails_with_ISE_if_not_started() {
282 expectISENotStarted();
284 underTest.uninstall();
288 public void uninstall_resets_fields_after_start_and_install() {
289 String value = randomAlphanumeric(10);
292 underTest.newEditionWithoutInstall(value);
293 PendingStatus newStatus = underTest.uninstall();
295 assertThat(newStatus).isEqualTo(UNINSTALL_IN_PROGRESS);
296 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(UNINSTALL_IN_PROGRESS);
297 assertThat(underTest.getPendingEditionKey()).isEmpty();
298 assertThat(underTest.getPendingLicense()).isEmpty();
299 assertThat(underTest.getCurrentEditionKey()).isEmpty();
303 public void uninstall_fails_with_ISE_if_called_after_uninstall() {
304 String value = randomAlphanumeric(10);
306 underTest.newEditionWithoutInstall(value);
307 underTest.uninstall();
309 expectedException.expect(IllegalStateException.class);
310 expectedException.expectMessage("Can't move to UNINSTALL_IN_PROGRESS when status is UNINSTALL_IN_PROGRESS (should be any of [NONE])");
312 underTest.uninstall();
316 public void uninstall_resets_fields_after_newEditionWithoutInstall() {
317 String value = randomAlphanumeric(10);
319 underTest.newEditionWithoutInstall(value);
321 PendingStatus newStatus = underTest.uninstall();
323 assertThat(newStatus).isEqualTo(UNINSTALL_IN_PROGRESS);
324 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(UNINSTALL_IN_PROGRESS);
325 assertThat(underTest.getPendingEditionKey()).isEmpty();
326 assertThat(underTest.getPendingLicense()).isEmpty();
327 assertThat(underTest.getCurrentEditionKey()).isEmpty();
331 public void uninstall_fails_with_ISE_if_called_after_startAutomaticInstall() {
333 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
335 expectedException.expect(IllegalStateException.class);
336 expectedException.expectMessage("Can't move to UNINSTALL_IN_PROGRESS when status is AUTOMATIC_IN_PROGRESS (should be any of [NONE])");
338 underTest.uninstall();
342 public void uninstall_fails_with_ISE_if_called_after_automaticInstallReady() {
344 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
345 underTest.automaticInstallReady();
347 expectedException.expect(IllegalStateException.class);
348 expectedException.expectMessage("Can't move to UNINSTALL_IN_PROGRESS when status is AUTOMATIC_READY (should be any of [NONE])");
350 underTest.uninstall();
354 public void uninstall_fails_with_ISE_if_called_after_manualInstall() {
356 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
358 expectedException.expect(IllegalStateException.class);
359 expectedException.expectMessage("Can't move to UNINSTALL_IN_PROGRESS when status is MANUAL_IN_PROGRESS (should be any of [NONE])");
361 underTest.uninstall();
365 public void startManualInstall_fails_with_ISE_if_not_started() {
366 expectISENotStarted();
368 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
372 public void startManualInstall_fails_with_NPE_if_license_is_null() {
375 expectedException.expect(NullPointerException.class);
376 expectedException.expectMessage("license can't be null");
378 underTest.startManualInstall(null);
382 public void startManualInstall_sets_pending_fields_after_start() {
385 PendingStatus newStatus = underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
387 assertThat(newStatus).isEqualTo(MANUAL_IN_PROGRESS);
388 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(MANUAL_IN_PROGRESS);
389 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
390 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
391 assertThat(underTest.getCurrentEditionKey()).isEmpty();
395 public void startManualInstall_sets_pending_fields_after_start_with_existing_currentEditionKey() {
396 String value = randomAlphanumeric(10);
397 dbTester.properties().insertInternal("currentEditionKey", value);
400 PendingStatus newStatus = underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
402 assertThat(newStatus).isEqualTo(MANUAL_IN_PROGRESS);
403 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(MANUAL_IN_PROGRESS);
404 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
405 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
406 assertThat(underTest.getCurrentEditionKey()).contains(value);
410 public void startManualInstall_sets_pending_fields_after_newEditionWithoutInstall() {
411 String value = randomAlphanumeric(10);
413 underTest.newEditionWithoutInstall(value);
415 PendingStatus newStatus = underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
417 assertThat(newStatus).isEqualTo(MANUAL_IN_PROGRESS);
418 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(MANUAL_IN_PROGRESS);
419 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
420 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
421 assertThat(underTest.getCurrentEditionKey()).contains(value);
425 public void startManualInstall_fails_with_ISE_if_called_after_startAutomaticInstall() {
427 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
429 expectedException.expect(IllegalStateException.class);
430 expectedException.expectMessage("Can't move to MANUAL_IN_PROGRESS when status is AUTOMATIC_IN_PROGRESS (should be any of [NONE])");
432 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
436 public void startManualInstall_fails_with_ISE_if_called_after_automaticInstallReady() {
438 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
439 underTest.automaticInstallReady();
441 expectedException.expect(IllegalStateException.class);
442 expectedException.expectMessage("Can't move to MANUAL_IN_PROGRESS when status is AUTOMATIC_READY (should be any of [NONE])");
444 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
448 public void startManualInstall_fails_with_ISE_if_called_after_manualInstall() {
450 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
452 expectedException.expect(IllegalStateException.class);
453 expectedException.expectMessage("Can't move to MANUAL_IN_PROGRESS when status is MANUAL_IN_PROGRESS (should be any of [NONE])");
455 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
459 public void automaticInstallReady_fails_with_ISE_if_not_started() {
460 expectISENotStarted();
462 underTest.automaticInstallReady();
466 public void automaticInstallReady_fails_with_ISE_if_called() {
469 expectedException.expect(IllegalStateException.class);
470 expectedException.expectMessage("Can't move to AUTOMATIC_READY when status is NONE (should be any of [AUTOMATIC_IN_PROGRESS])");
472 underTest.automaticInstallReady();
476 public void automaticInstallReady_fails_with_ISE_if_called_after_manualInstall() {
478 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
480 expectedException.expect(IllegalStateException.class);
481 expectedException.expectMessage("Can't move to AUTOMATIC_READY when status is MANUAL_IN_PROGRESS (should be any of [AUTOMATIC_IN_PROGRESS])");
483 underTest.automaticInstallReady();
487 public void automaticInstallReady_after_startAutomaticInstall_changes_status_to_AUTOMATIC_READY_but_does_not_change_editions() {
489 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
491 PendingStatus newStatus = underTest.automaticInstallReady();
493 assertThat(newStatus).isEqualTo(AUTOMATIC_READY);
494 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(AUTOMATIC_READY);
495 assertThat(underTest.getPendingEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
496 assertThat(underTest.getPendingLicense()).contains(LICENSE_WITHOUT_PLUGINS.getContent());
497 assertThat(underTest.getCurrentEditionKey()).isEmpty();
501 public void newEditionWithoutInstall_fails_with_ISE_if_not_started() {
502 expectISENotStarted();
504 underTest.newEditionWithoutInstall(randomAlphanumeric(3));
508 public void newEditionWithoutInstall_fails_with_NPE_if_newEditionKey_is_null() {
511 expectedException.expect(NullPointerException.class);
512 expectedException.expectMessage("newEditionKey can't be null");
514 underTest.newEditionWithoutInstall(null);
518 public void newEditionWithoutInstall_fails_with_IAE_if_newEditionKey_is_empty() {
521 expectedException.expect(IllegalArgumentException.class);
522 expectedException.expectMessage("newEditionKey can't be empty");
524 underTest.newEditionWithoutInstall("");
528 public void newEditionWithoutInstall_changes_current_edition() {
529 String newEditionKey = randomAlphanumeric(3);
532 PendingStatus newStatus = underTest.newEditionWithoutInstall(newEditionKey);
534 assertThat(newStatus).isEqualTo(NONE);
535 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
536 assertThat(underTest.getPendingEditionKey()).isEmpty();
537 assertThat(underTest.getPendingLicense()).isEmpty();
538 assertThat(underTest.getCurrentEditionKey()).contains(newEditionKey);
542 public void newEditionWithoutInstall_overwrite_current_edition() {
543 String newEditionKey = randomAlphanumeric(3);
546 PendingStatus newStatus = underTest.newEditionWithoutInstall(newEditionKey);
548 assertThat(newStatus).isEqualTo(NONE);
549 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
550 assertThat(underTest.getPendingEditionKey()).isEmpty();
551 assertThat(underTest.getPendingLicense()).isEmpty();
552 assertThat(underTest.getCurrentEditionKey()).contains(newEditionKey);
556 public void newEditionWithoutInstall_overwrites_from_previous_newEditionWithoutInstall() {
557 String newEditionKey1 = randomAlphanumeric(3);
558 String newEditionKey2 = randomAlphanumeric(3);
560 underTest.newEditionWithoutInstall(newEditionKey1);
562 PendingStatus newStatus = underTest.newEditionWithoutInstall(newEditionKey2);
564 assertThat(newStatus).isEqualTo(NONE);
565 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
566 assertThat(underTest.getPendingEditionKey()).isEmpty();
567 assertThat(underTest.getPendingLicense()).isEmpty();
568 assertThat(underTest.getCurrentEditionKey()).contains(newEditionKey2);
572 public void newEditionWithoutInstall_fails_with_ISE_if_called_after_startAutomaticInstall() {
573 String newEditionKey = randomAlphanumeric(3);
575 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
577 expectedException.expect(IllegalStateException.class);
578 expectedException.expectMessage("Can't move to NONE when status is AUTOMATIC_IN_PROGRESS (should be any of [NONE])");
580 underTest.newEditionWithoutInstall(newEditionKey);
584 public void newEditionWithoutInstall_fails_with_ISE_if_called_after_startManualInstall() {
585 String newEditionKey = randomAlphanumeric(3);
587 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
589 expectedException.expect(IllegalStateException.class);
590 expectedException.expectMessage("Can't move to NONE when status is MANUAL_IN_PROGRESS (should be any of [NONE])");
592 underTest.newEditionWithoutInstall(newEditionKey);
596 public void finalizeInstallation_fails_with_ISE_if_not_started() {
597 expectISENotStarted();
599 underTest.finalizeInstallation();
603 public void finalizeInstallation_fails_with_ISE_after_start() {
606 expectedException.expect(IllegalStateException.class);
607 expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_READY, MANUAL_IN_PROGRESS, UNINSTALL_IN_PROGRESS])");
609 underTest.finalizeInstallation();
613 public void finalizeInstallation_fails_with_ISE_after_newEditionWithoutInstall() {
615 underTest.newEditionWithoutInstall(randomAlphanumeric(3));
617 expectedException.expect(IllegalStateException.class);
618 expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_READY, MANUAL_IN_PROGRESS, UNINSTALL_IN_PROGRESS])");
620 underTest.finalizeInstallation();
624 public void finalizeInstallation_fails_with_ISE_after_startAutomaticInstall() {
626 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
628 expectedException.expect(IllegalStateException.class);
629 expectedException.expectMessage("Can't move to NONE when status is AUTOMATIC_IN_PROGRESS (should be any of [AUTOMATIC_READY, MANUAL_IN_PROGRESS, UNINSTALL_IN_PROGRESS])");
631 underTest.finalizeInstallation();
635 public void finalizeInstallation_set_new_edition_and_clear_pending_fields_after_manualInstallationReady() {
637 underTest.startAutomaticInstall(LICENSE_WITHOUT_PLUGINS);
638 underTest.automaticInstallReady();
640 PendingStatus newStatus = underTest.finalizeInstallation();
642 assertThat(newStatus).isEqualTo(NONE);
643 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
644 assertThat(underTest.getPendingEditionKey()).isEmpty();
645 assertThat(underTest.getPendingLicense()).isEmpty();
646 assertThat(underTest.getCurrentEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
650 public void finalizeInstallation_set_new_edition_and_clear_pending_fields_after_startManualInstall() {
652 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
654 PendingStatus newStatus = underTest.finalizeInstallation();
656 assertThat(newStatus).isEqualTo(NONE);
657 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
658 assertThat(underTest.getPendingEditionKey()).isEmpty();
659 assertThat(underTest.getPendingLicense()).isEmpty();
660 assertThat(underTest.getCurrentEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
664 public void finalizeInstallation_set_new_edition_and_clear_pending_fields_after_uninstall() {
666 String value = randomAlphanumeric(10);
667 underTest.newEditionWithoutInstall(value);
668 underTest.uninstall();
670 PendingStatus newStatus = underTest.finalizeInstallation();
672 assertThat(newStatus).isEqualTo(NONE);
673 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
674 assertThat(underTest.getPendingEditionKey()).isEmpty();
675 assertThat(underTest.getPendingLicense()).isEmpty();
676 assertThat(underTest.getCurrentEditionKey()).isEmpty();
680 public void finalizeInstallation_overwrites_current_edition_and_clear_pending_fields_after_startManualInstall() {
681 String value = randomAlphanumeric(10);
682 dbTester.properties().insertInternal("currentEditionKey", value);
684 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
686 PendingStatus newStatus = underTest.finalizeInstallation();
688 assertThat(newStatus).isEqualTo(NONE);
689 assertThat(underTest.getPendingInstallationStatus()).isEqualTo(NONE);
690 assertThat(underTest.getPendingEditionKey()).isEmpty();
691 assertThat(underTest.getPendingLicense()).isEmpty();
692 assertThat(underTest.getCurrentEditionKey()).contains(LICENSE_WITHOUT_PLUGINS.getEditionKey());
696 public void finalizeInstallation_fails_with_ISE_after_finalizeInstallation() {
698 underTest.startManualInstall(LICENSE_WITHOUT_PLUGINS);
699 underTest.finalizeInstallation();
701 expectedException.expect(IllegalStateException.class);
702 expectedException.expectMessage("Can't move to NONE when status is NONE (should be any of [AUTOMATIC_READY, MANUAL_IN_PROGRESS, UNINSTALL_IN_PROGRESS])");
704 underTest.finalizeInstallation();
707 private void expectISENotStarted() {
708 expectedException.expect(IllegalStateException.class);
709 expectedException.expectMessage("StandaloneEditionManagementStateImpl is not started");