Files
kst4contest/app-desktop/src/test/java/kst4contest/view/ApplicationRuntimeLauncherSetupWizardTest.java
T
Rsclub2_2 1dd0139e10 Add a setup assistant for unconfigured profiles (#174)
A profile without a callsign of its own now starts in a setup assistant instead
of the twelve-tab settings window. It asks for name, login, locator, bands and
chat category, and optionally for antenna and power, log program, rotator and
AirScout. Login and station can each be taken from another configured profile.

The assistant runs in startRuntime after the profile is resolved and before the
ChatController exists. It works on a ChatPreferences of its own, writes
preferences.xml, and the runtime then reads that file like any stored setting.
It never touches a running session. From the Options menu the runtime is torn
down first and the same profile restarted with the assistant in front.

A station set up anew gets only what the operator confirmed: the bundled
template has several integrations enabled, and the assistant switches off what
was not chosen and names it in its summary. A station left unchanged is written
page by page, only for pages the operator opened. A taken station is the whole
station, every setter listed in wizard-station-setters.txt; a test fails when a
new ChatPreferences setter is classified in neither list.

Changes outside the assistant:
- ChatPreferences.readPreferencesFromXmlFile() returns false when the file could
  not be read or parsed, or its root element is not praktiKST. It reads on as
  before, and its two existing callers ignore the return value.
- ApplicationRuntimeLauncher.switchProfile refuses a second switch while one is
  in progress.
- The Log synch tab's file chooser takes an optional owner dialog.

The design and its reasons are in
docs/superpowers/specs/2026-11-18-einrichtungsassistent-design.md.

Written-by: Claude Fable 5.2
Written-by: DeepSeek V4 Pro
Written-by: Gemini 4 Hydrogen (Antigravity)
Written-by: Codex (GPT-6.2 Sol)
2026-11-18 23:16:52 +01:00

88 lines
3.7 KiB
Java

package kst4contest.view;
import kst4contest.controller.ActiveOperatorProfile;
import kst4contest.model.OperatorProfile;
import kst4contest.model.OperatorProfileSelection;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* The request to show the setup wizard on the next runtime start is honoured exactly once.
* A request that stuck would open the wizard on every later profile switch.
*/
class ApplicationRuntimeLauncherSetupWizardTest {
@Test
void aRequestIsHonouredOnce() {
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "nothing was requested");
ApplicationRuntimeLauncher.requestSetupWizard();
assertTrue(ApplicationRuntimeLauncher.consumeSetupWizardRequest());
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "the request must not stick");
}
@Test
void switchGuardAllowsOnlyOneSwitchAtATime() {
try {
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
assertFalse(ApplicationRuntimeLauncher.beginSwitch(),
"a second switch must be refused while one is in progress");
} finally {
ApplicationRuntimeLauncher.endSwitch();
}
try {
assertTrue(ApplicationRuntimeLauncher.beginSwitch(),
"ending the first switch must release the guard");
} finally {
ApplicationRuntimeLauncher.endSwitch();
}
}
@Test
void aRefusedRerunLeavesTheRequestOfTheRunningSwitchAlone() {
OperatorProfileSelection previous = ActiveOperatorProfile.get();
OperatorProfile profile = new OperatorProfile("wizard-guard-test", "Wizard Guard Test", false, false);
ActiveOperatorProfile.set(new OperatorProfileSelection(profile, "preferences.xml", "worked.db", false));
// A first rerun is under way: it holds the guard and its request waits for startRuntime.
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
ApplicationRuntimeLauncher.requestSetupWizard();
try {
// A second one arrives while the first tears its windows down, and is refused.
assertFalse(ApplicationRuntimeLauncher.rerunSetupWizard());
assertTrue(ApplicationRuntimeLauncher.consumeSetupWizardRequest(),
"the refused rerun took the running switch's request with it: that switch "
+ "would end the session and then start without the wizard");
} finally {
ApplicationRuntimeLauncher.endSwitch();
ApplicationRuntimeLauncher.consumeSetupWizardRequest();
ActiveOperatorProfile.set(previous);
}
}
@Test
void aRefusedRerunLeavesNoRequestOfItsOwn() {
OperatorProfileSelection previous = ActiveOperatorProfile.get();
OperatorProfile profile = new OperatorProfile("wizard-guard-test", "Wizard Guard Test", false, false);
ActiveOperatorProfile.set(new OperatorProfileSelection(profile, "preferences.xml", "worked.db", false));
// A plain profile switch is under way; nobody asked for the wizard.
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
try {
assertFalse(ApplicationRuntimeLauncher.rerunSetupWizard());
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(),
"a refused rerun must not hand its wizard to the switch that refused it");
} finally {
ApplicationRuntimeLauncher.endSwitch();
ApplicationRuntimeLauncher.consumeSetupWizardRequest();
ActiveOperatorProfile.set(previous);
}
}
}