From d1b910c99247612bcbc96c0e6b44effbd8a2cb2b Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Mon, 5 Oct 2026 22:42:08 +0200 Subject: [PATCH] Port the rebased diagnostics and session logging onto the modules origin/main landed replayable session logging (MessageHistoryRecorder), file logging (ApplicationFileLogging) and a user-list refresh split on the old flat layout. The rebase carried the new files, but three things needed the new architecture: - ChatController.fireUserListUpdate() used javafx Platform; core is toolkit-free now, so it dispatches through uiDispatcher like every other fire method. - Two new tests were left in the old src/test/java; moved into core. - ScoreServiceRefreshTest mocked javafx Platform statically; it now injects the DirectUiDispatcher the no-arg constructor installs. The Leaflet map performance work was dropped with the HTML map it optimised. classes testClasses and test are green: 1069 tests, 0 failures, 3 skipped. Co-Authored-By: Claude Opus 5 (1M context) --- .../controller/ChatController.java | 4 ++-- .../controller/ScoreServiceRefreshTest.java | 24 +++++++++++-------- .../DirectionUtilsConsoleOutputTest.java | 0 .../utils/ApplicationFileLoggingTest.java | 0 4 files changed, 16 insertions(+), 12 deletions(-) rename {src => core/src}/test/java/kst4contest/locatorUtils/DirectionUtilsConsoleOutputTest.java (100%) rename {src => core/src}/test/java/kst4contest/utils/ApplicationFileLoggingTest.java (100%) diff --git a/core/src/main/java/kst4contest/controller/ChatController.java b/core/src/main/java/kst4contest/controller/ChatController.java index d286c31a..2c04e4a9 100644 --- a/core/src/main/java/kst4contest/controller/ChatController.java +++ b/core/src/main/java/kst4contest/controller/ChatController.java @@ -2501,10 +2501,10 @@ private SimpleRoster return; } - if (Platform.isFxApplicationThread()) { + if (uiDispatcher.isUiThread()) { statusListener.onUserListUpdated(); } else { - Platform.runLater(statusListener::onUserListUpdated); + uiDispatcher.runOnUi(statusListener::onUserListUpdated); } } diff --git a/core/src/test/java/kst4contest/controller/ScoreServiceRefreshTest.java b/core/src/test/java/kst4contest/controller/ScoreServiceRefreshTest.java index 31128a98..dcbd37a8 100644 --- a/core/src/test/java/kst4contest/controller/ScoreServiceRefreshTest.java +++ b/core/src/test/java/kst4contest/controller/ScoreServiceRefreshTest.java @@ -13,10 +13,8 @@ import java.util.List; import java.util.Map; import org.junit.jupiter.api.Test; -import org.mockito.MockedStatic; import org.mockito.invocation.Invocation; -import javafx.application.Platform; import kst4contest.logic.PriorityCalculator; import kst4contest.model.ChatCategory; import kst4contest.model.ChatMember; @@ -54,20 +52,26 @@ class ScoreServiceRefreshTest { } @Test - void userListRefreshKeepsDiagnosticAndReasonlessCallbacksSeparate() { + void userListRefreshKeepsDiagnosticAndReasonlessCallbacksSeparate() throws Exception { ChatController controller = mock( ChatController.class, org.mockito.Answers.CALLS_REAL_METHODS); + /* + * CALLS_REAL_METHODS runs no constructor, so the dispatcher field stays null. Give + * the mock the direct dispatcher the no-arg constructor installs; it runs inline and + * reports the calling thread as the UI thread, which is what the fire methods branch + * on. This replaces the old static Platform mock -- core no longer touches JavaFX. + */ + java.lang.reflect.Field dispatcherField = + ChatController.class.getDeclaredField("uiDispatcher"); + dispatcherField.setAccessible(true); + dispatcherField.set(controller, new kst4contest.observe.DirectUiDispatcher()); + StatusUpdateListener listener = mock(StatusUpdateListener.class); controller.setStatusListener(listener); - try (MockedStatic platform = - org.mockito.Mockito.mockStatic(Platform.class)) { - platform.when(Platform::isFxApplicationThread).thenReturn(true); - - controller.fireUserListUpdate(); - controller.fireUserListUpdate("Reachability calculated"); - } + controller.fireUserListUpdate(); + controller.fireUserListUpdate("Reachability calculated"); verify(listener).onUserListUpdated(); verify(listener).onUserListUpdated("Reachability calculated"); diff --git a/src/test/java/kst4contest/locatorUtils/DirectionUtilsConsoleOutputTest.java b/core/src/test/java/kst4contest/locatorUtils/DirectionUtilsConsoleOutputTest.java similarity index 100% rename from src/test/java/kst4contest/locatorUtils/DirectionUtilsConsoleOutputTest.java rename to core/src/test/java/kst4contest/locatorUtils/DirectionUtilsConsoleOutputTest.java diff --git a/src/test/java/kst4contest/utils/ApplicationFileLoggingTest.java b/core/src/test/java/kst4contest/utils/ApplicationFileLoggingTest.java similarity index 100% rename from src/test/java/kst4contest/utils/ApplicationFileLoggingTest.java rename to core/src/test/java/kst4contest/utils/ApplicationFileLoggingTest.java