You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2026/06/07 19:36:18 UTC
(causeway) 02/10: CAUSEWAY-4015: suppresses initial fixture command logging
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-4019
in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 22412e44da7ab1360e88f5037009e3f6177530e3
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Sun Jun 7 16:52:09 2026 +0100
CAUSEWAY-4015: suppresses initial fixture command logging
---
.../applib/CausewayModuleExtCommandLogApplib.java | 4 +
.../applib/events/PauseLoggingEvent.java | 41 ++++++++++
.../applib/events/ResumeLoggingEvent.java | 39 ++++++++++
.../applib/subscriber/CommandLogPauseState.java | 52 +++++++++++++
.../subscriber/CommandLogPauseStateListener.java | 70 +++++++++++++++++
.../subscriber/CommandSubscriberForCommandLog.java | 7 +-
.../integtest/CommandLog_IntegTestAbstract.java | 74 ++++++++++++++++++
.../.openspec.yaml | 0
.../design.md | 0
.../proposal.md | 0
.../specs/command-recording-suppression/spec.md | 0
.../tasks.md | 32 ++++----
.../specs/command-recording-suppression/spec.md | 59 ++++++++++++++
.../InitialFixtureScriptsInstalledEvent.java | 34 ++++++++
.../InitialFixtureScriptsInstallingEvent.java | 34 ++++++++
.../services/InitialFixtureScriptsInstaller.java | 15 +++-
.../InitialFixtureScriptsInstaller_Test.java | 90 ++++++++++++++++++++++
17 files changed, 530 insertions(+), 21 deletions(-)
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java
index b17292d4e83..ddacb899a39 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/CausewayModuleExtCommandLogApplib.java
@@ -64,6 +64,8 @@
import org.apache.causeway.extensions.commandlog.applib.spi.CommandReplayMappingListener;
import org.apache.causeway.extensions.commandlog.applib.spi.CommandReplayMappingListenerInMemory;
import org.apache.causeway.extensions.commandlog.applib.spi.RunBackgroundCommandsJobListener;
+import org.apache.causeway.extensions.commandlog.applib.subscriber.CommandLogPauseState;
+import org.apache.causeway.extensions.commandlog.applib.subscriber.CommandLogPauseStateListener;
import org.apache.causeway.extensions.commandlog.applib.subscriber.CommandSubscriberForCommandLog;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -114,6 +116,8 @@
CommandReplayMappingListenerInMemory.BeanFactory.class,
// @Service's
+ CommandLogPauseState.class,
+ CommandLogPauseStateListener.class,
CommandSubscriberForCommandLog.class,
CommandLogEntry.TableColumnOrderDefault.class,
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/events/PauseLoggingEvent.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/events/PauseLoggingEvent.java
new file mode 100644
index 00000000000..b297a8590c2
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/events/PauseLoggingEvent.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.extensions.commandlog.applib.events;
+
+import org.apache.causeway.applib.events.EventObjectBase;
+
+/**
+ * Pauses command-log persistence for a scoped operation.
+ *
+ * <p>
+ * Subscribers in the command-log module use this event to temporarily ignore command lifecycle notifications without
+ * disabling command publishing itself.
+ * Every pause event should be paired with a {@link ResumeLoggingEvent}, preferably from a {@code finally} block.
+ * Nested pauses are supported, so command logging resumes only after all active pauses have been resumed.
+ * </p>
+ *
+ * @since 3.x {@index}
+ */
+public class PauseLoggingEvent extends EventObjectBase<Object> {
+
+ public PauseLoggingEvent(final Object source) {
+ super(source);
+ }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/events/ResumeLoggingEvent.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/events/ResumeLoggingEvent.java
new file mode 100644
index 00000000000..d555494f1f3
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/events/ResumeLoggingEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.extensions.commandlog.applib.events;
+
+import org.apache.causeway.applib.events.EventObjectBase;
+
+/**
+ * Resumes command-log persistence after a scoped pause.
+ *
+ * <p>
+ * This event should be posted for each matching {@link PauseLoggingEvent}.
+ * The command-log module tolerates unmatched resume events and never lets its pause depth become negative.
+ * </p>
+ *
+ * @since 3.x {@index}
+ */
+public class ResumeLoggingEvent extends EventObjectBase<Object> {
+
+ public ResumeLoggingEvent(final Object source) {
+ super(source);
+ }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandLogPauseState.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandLogPauseState.java
new file mode 100644
index 00000000000..82ffaed8925
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandLogPauseState.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.extensions.commandlog.applib.subscriber;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.inject.Named;
+
+import org.springframework.stereotype.Service;
+
+import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
+
+/**
+ * Tracks scoped command-log persistence pauses.
+ */
+@Service
+@Named(CommandLogPauseState.LOGICAL_TYPE_NAME)
+public class CommandLogPauseState {
+
+ static final String LOGICAL_TYPE_NAME = CausewayModuleExtCommandLogApplib.NAMESPACE + ".CommandLogPauseState";
+
+ private final AtomicInteger pauseDepth = new AtomicInteger();
+
+ public boolean isPaused() {
+ return pauseDepth.get() > 0;
+ }
+
+ public void pause() {
+ pauseDepth.incrementAndGet();
+ }
+
+ public void resume() {
+ pauseDepth.updateAndGet(current -> current > 0 ? current - 1 : 0);
+ }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandLogPauseStateListener.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandLogPauseStateListener.java
new file mode 100644
index 00000000000..92a2cd02178
--- /dev/null
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandLogPauseStateListener.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.extensions.commandlog.applib.subscriber;
+
+import javax.annotation.Priority;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Service;
+
+import org.apache.causeway.applib.annotation.PriorityPrecedence;
+import org.apache.causeway.extensions.commandlog.applib.CausewayModuleExtCommandLogApplib;
+import org.apache.causeway.extensions.commandlog.applib.events.PauseLoggingEvent;
+import org.apache.causeway.extensions.commandlog.applib.events.ResumeLoggingEvent;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstalledEvent;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstallingEvent;
+
+import lombok.RequiredArgsConstructor;
+
+/**
+ * Maintains command-log pause state in response to application events.
+ */
+@Service
+@Named(CommandLogPauseStateListener.LOGICAL_TYPE_NAME)
+@Priority(PriorityPrecedence.MIDPOINT)
+@RequiredArgsConstructor(onConstructor_ = {@Inject})
+public class CommandLogPauseStateListener {
+
+ static final String LOGICAL_TYPE_NAME = CausewayModuleExtCommandLogApplib.NAMESPACE + ".CommandLogPauseStateListener";
+
+ private final CommandLogPauseState commandLogPauseState;
+
+ @EventListener(PauseLoggingEvent.class)
+ public void onPauseLoggingEvent(final PauseLoggingEvent event) {
+ commandLogPauseState.pause();
+ }
+
+ @EventListener(ResumeLoggingEvent.class)
+ public void onResumeLoggingEvent(final ResumeLoggingEvent event) {
+ commandLogPauseState.resume();
+ }
+
+ @EventListener(InitialFixtureScriptsInstallingEvent.class)
+ public void onInitialFixtureScriptsInstallingEvent(final InitialFixtureScriptsInstallingEvent event) {
+ commandLogPauseState.pause();
+ }
+
+ @EventListener(InitialFixtureScriptsInstalledEvent.class)
+ public void onInitialFixtureScriptsInstalledEvent(final InitialFixtureScriptsInstalledEvent event) {
+ commandLogPauseState.resume();
+ }
+
+}
diff --git a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
index 2f5cd455eed..cb324d55477 100644
--- a/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
+++ b/extensions/core/commandlog/applib/src/main/java/org/apache/causeway/extensions/commandlog/applib/subscriber/CommandSubscriberForCommandLog.java
@@ -62,6 +62,7 @@ public class CommandSubscriberForCommandLog implements CommandSubscriber {
final RepositoryService repositoryService;
final CausewayConfiguration causewayConfiguration;
final ClockService clockService;
+ final CommandLogPauseState commandLogPauseState;
@Override
public boolean isEnabled() {
@@ -71,7 +72,7 @@ public boolean isEnabled() {
@Override
public void onReady(final Command command) {
- if (!isEnabled()) {
+ if (!isEnabled() || commandLogPauseState.isPaused()) {
return;
}
@@ -114,7 +115,7 @@ public void onReady(final Command command) {
@Override
public void onStarted(final Command command) {
- if (!isEnabled()) {
+ if (!isEnabled() || commandLogPauseState.isPaused()) {
return;
}
@@ -127,7 +128,7 @@ public void onStarted(final Command command) {
@Override
public void onCompleted(final Command command) {
- if (!isEnabled()) {
+ if (!isEnabled() || commandLogPauseState.isPaused()) {
return;
}
diff --git a/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java b/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java
index db4f61e998c..0f017b7c6c4 100644
--- a/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java
+++ b/extensions/core/commandlog/applib/src/test/java/org/apache/causeway/extensions/commandlog/applib/integtest/CommandLog_IntegTestAbstract.java
@@ -33,6 +33,7 @@
import org.apache.causeway.applib.services.bookmark.Bookmark;
import org.apache.causeway.applib.services.bookmark.BookmarkService;
import org.apache.causeway.applib.services.clock.ClockService;
+import org.apache.causeway.applib.services.eventbus.EventBusService;
import org.apache.causeway.applib.services.iactnlayer.InteractionContext;
import org.apache.causeway.applib.services.iactnlayer.InteractionLayerTracker;
import org.apache.causeway.applib.services.iactnlayer.InteractionService;
@@ -47,7 +48,11 @@
import org.apache.causeway.extensions.commandlog.applib.dom.CommandLogEntryRepository;
import org.apache.causeway.extensions.commandlog.applib.dom.CommandReplayResultMappingRepository;
import org.apache.causeway.extensions.commandlog.applib.dom.ReplayState;
+import org.apache.causeway.extensions.commandlog.applib.events.PauseLoggingEvent;
+import org.apache.causeway.extensions.commandlog.applib.events.ResumeLoggingEvent;
import org.apache.causeway.extensions.commandlog.applib.spi.CommandReplayMappingListenerPersistent;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstalledEvent;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstallingEvent;
import org.apache.causeway.core.config.CausewayConfiguration.Extensions.CommandLog.RecordingSupport;
import org.apache.causeway.core.config.CausewayConfiguration.Extensions.CommandLog.ReplayResultMapping.OnConflictPolicy;
import org.apache.causeway.extensions.commandlog.applib.integtest.model.Counter;
@@ -319,6 +324,74 @@ void safe_action_command_publishing_logs_null_list_and_scalar_results() {
+ @Test
+ void paused_command_logging_suppresses_commands_until_resumed() {
+
+ // given
+ eventBusService.post(new PauseLoggingEvent(this));
+
+ // when
+ wrapperFactory.wrap(counter1).bumpUsingDeclaredAction();
+ interactionService.nextInteraction();
+
+ // then
+ assertThat(commandLogEntryRepository.findAll()).isEmpty();
+
+ // and when
+ eventBusService.post(new ResumeLoggingEvent(this));
+ wrapperFactory.wrap(counter1).bumpUsingDeclaredAction();
+ interactionService.nextInteraction();
+
+ // then
+ assertThat(commandLogEntryRepository.findAll()).hasSize(1);
+ }
+
+ @Test
+ void nested_paused_command_logging_requires_matching_resumes() {
+
+ // given
+ eventBusService.post(new PauseLoggingEvent(this));
+ eventBusService.post(new PauseLoggingEvent(this));
+
+ // when
+ eventBusService.post(new ResumeLoggingEvent(this));
+ wrapperFactory.wrap(counter1).bumpUsingDeclaredAction();
+ interactionService.nextInteraction();
+
+ // then
+ assertThat(commandLogEntryRepository.findAll()).isEmpty();
+
+ // and when
+ eventBusService.post(new ResumeLoggingEvent(this));
+ wrapperFactory.wrap(counter1).bumpUsingDeclaredAction();
+ interactionService.nextInteraction();
+
+ // then
+ assertThat(commandLogEntryRepository.findAll()).hasSize(1);
+ }
+
+ @Test
+ void initial_fixture_script_events_suppress_command_logging_until_installed_event() {
+
+ // given
+ eventBusService.post(new InitialFixtureScriptsInstallingEvent(this));
+
+ // when
+ wrapperFactory.wrap(counter1).bumpUsingDeclaredAction();
+ interactionService.nextInteraction();
+
+ // then
+ assertThat(commandLogEntryRepository.findAll()).isEmpty();
+
+ // and when
+ eventBusService.post(new InitialFixtureScriptsInstalledEvent(this));
+ wrapperFactory.wrap(counter1).bumpUsingDeclaredAction();
+ interactionService.nextInteraction();
+
+ // then
+ assertThat(commandLogEntryRepository.findAll()).hasSize(1);
+ }
+
@Test
void edit() {
@@ -623,5 +696,6 @@ void test_all_the_repository_methods() {
@Inject BookmarkService bookmarkService;
@Inject CausewayConfiguration causewayConfiguration;
@Inject CausewayBeanTypeRegistry causewayBeanTypeRegistry;
+ @Inject EventBusService eventBusService;
}
diff --git a/openspec/changes/suppress-fixture-initial-script-command-logging/.openspec.yaml b/openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/.openspec.yaml
similarity index 100%
rename from openspec/changes/suppress-fixture-initial-script-command-logging/.openspec.yaml
rename to openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/.openspec.yaml
diff --git a/openspec/changes/suppress-fixture-initial-script-command-logging/design.md b/openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/design.md
similarity index 100%
rename from openspec/changes/suppress-fixture-initial-script-command-logging/design.md
rename to openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/design.md
diff --git a/openspec/changes/suppress-fixture-initial-script-command-logging/proposal.md b/openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/proposal.md
similarity index 100%
rename from openspec/changes/suppress-fixture-initial-script-command-logging/proposal.md
rename to openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/proposal.md
diff --git a/openspec/changes/suppress-fixture-initial-script-command-logging/specs/command-recording-suppression/spec.md b/openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/specs/command-recording-suppression/spec.md
similarity index 100%
rename from openspec/changes/suppress-fixture-initial-script-command-logging/specs/command-recording-suppression/spec.md
rename to openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/specs/command-recording-suppression/spec.md
diff --git a/openspec/changes/suppress-fixture-initial-script-command-logging/tasks.md b/openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/tasks.md
similarity index 56%
rename from openspec/changes/suppress-fixture-initial-script-command-logging/tasks.md
rename to openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/tasks.md
index 77ca15227dd..fbfb5ddba7a 100644
--- a/openspec/changes/suppress-fixture-initial-script-command-logging/tasks.md
+++ b/openspec/changes/archive/2026-06-07-suppress-fixture-initial-script-command-logging/tasks.md
@@ -1,27 +1,27 @@
## 1. Command Log Pause State
-- [ ] 1.1 Add command-log applib event types for pausing and resuming command log persistence, with API documentation describing their scoped use.
-- [ ] 1.2 Add an internal command-log pause state service that tracks nested pause depth and exposes whether command logging is currently paused.
-- [ ] 1.3 Add an internal command-log listener that reacts to pause and resume events and updates the pause state service.
-- [ ] 1.4 Register any new command-log listener or support service in `CausewayModuleExtCommandLogApplib` if component scanning does not already include it.
+- [x] 1.1 Add command-log applib event types for pausing and resuming command log persistence, with API documentation describing their scoped use.
+- [x] 1.2 Add an internal command-log pause state service that tracks nested pause depth and exposes whether command logging is currently paused.
+- [x] 1.3 Add an internal command-log listener that reacts to pause and resume events and updates the pause state service.
+- [x] 1.4 Register any new command-log listener or support service in `CausewayModuleExtCommandLogApplib` if component scanning does not already include it.
## 2. Subscriber Suppression
-- [ ] 2.1 Update `CommandSubscriberForCommandLog#onReady` to return without creating or comparing command log entries while command logging is paused.
-- [ ] 2.2 Update `CommandSubscriberForCommandLog#onStarted` and `#onCompleted` to return without syncing command log entries while command logging is paused.
-- [ ] 2.3 Add unit tests for paused ready, started, and completed notifications.
-- [ ] 2.4 Add unit tests proving resumed and nested pause scopes restore normal command-log persistence only after all active pauses are resumed.
+- [x] 2.1 Update `CommandSubscriberForCommandLog#onReady` to return without creating or comparing command log entries while command logging is paused.
+- [x] 2.2 Update `CommandSubscriberForCommandLog#onStarted` and `#onCompleted` to return without syncing command log entries while command logging is paused.
+- [x] 2.3 Add unit tests for paused ready, started, and completed notifications.
+- [x] 2.4 Add unit tests proving resumed and nested pause scopes restore normal command-log persistence only after all active pauses are resumed.
## 3. Initial Fixture Script Integration
-- [ ] 3.1 Identify the lowest-coupling bridge from initial fixture installation to command-log pause state, respecting the existing dependency from command-log applib to testing fixtures applib.
-- [ ] 3.2 Update the initial fixture script execution path to enter a command-log pause scope before running the configured initial script and to resume in a `finally` path.
-- [ ] 3.3 Ensure the initial fixture script still executes through the existing `FixtureScripts` domain logic and transaction behavior.
-- [ ] 3.4 Add tests proving commands produced by the configured initial fixture script are not persisted as command log entries.
-- [ ] 3.5 Add tests proving command logging resumes after successful and failed initial fixture script execution.
+- [x] 3.1 Identify the lowest-coupling bridge from initial fixture installation to command-log pause state, respecting the existing dependency from command-log applib to testing fixtures applib.
+- [x] 3.2 Update the initial fixture script execution path to enter a command-log pause scope before running the configured initial script and to resume in a `finally` path.
+- [x] 3.3 Ensure the initial fixture script still executes through the existing `FixtureScripts` domain logic and transaction behavior.
+- [x] 3.4 Add tests proving commands produced by the configured initial fixture script are not persisted as command log entries.
+- [x] 3.5 Add tests proving command logging resumes after successful and failed initial fixture script execution.
## 4. Verification
-- [ ] 4.1 Run focused command-log applib tests covering the new pause state and subscriber behavior.
-- [ ] 4.2 Run focused testing fixtures applib or integration tests covering initial fixture installation behavior.
-- [ ] 4.3 Run `openspec validate suppress-fixture-initial-script-command-logging --strict` and fix any proposal/spec/task issues.
+- [x] 4.1 Run focused command-log applib tests covering the new pause state and subscriber behavior.
+- [x] 4.2 Run focused testing fixtures applib or integration tests covering initial fixture installation behavior.
+- [x] 4.3 Run `openspec validate suppress-fixture-initial-script-command-logging --strict` and fix any proposal/spec/task issues.
diff --git a/openspec/specs/command-recording-suppression/spec.md b/openspec/specs/command-recording-suppression/spec.md
index 1cee4177b71..fa565a2706f 100644
--- a/openspec/specs/command-recording-suppression/spec.md
+++ b/openspec/specs/command-recording-suppression/spec.md
@@ -56,3 +56,62 @@ When a user interacts with these marked helper objects during a recording sessio
- **WHEN** the user invokes an action on the `CommandLogEntry`
- **THEN** the system does not persist a command log entry for that helper action solely through recording support
+### Requirement: Command log persistence can be paused and resumed
+The system SHALL provide an application-event based mechanism to pause command log persistence.
+The system SHALL provide an application-event based mechanism to resume command log persistence after a previous pause.
+While command log persistence is paused, the command-log subscriber MUST NOT create new command log entries for published commands.
+While command log persistence is paused, the command-log subscriber MUST NOT sync existing command log entries for published command lifecycle updates.
+After command log persistence is resumed, subsequent eligible commands MUST remain persistable by the normal command-log subscriber flow.
+Nested pause scopes MUST NOT resume command log persistence until each active pause scope has been resumed.
+
+#### Scenario: Paused logging skips command entry creation
+- **GIVEN** command-log persistence is enabled
+- **AND** command log persistence has been paused
+- **WHEN** a command reaches the ready notification
+- **THEN** the system does not create a command log entry for that command
+
+#### Scenario: Paused logging skips command entry synchronization
+- **GIVEN** command-log persistence is enabled
+- **AND** command log persistence has been paused
+- **WHEN** a command reaches the started or completed notification
+- **THEN** the system does not sync a command log entry for that command notification
+
+#### Scenario: Resumed logging restores normal persistence
+- **GIVEN** command-log persistence is enabled
+- **AND** command log persistence was paused and has then been resumed
+- **WHEN** a subsequent eligible command reaches the ready notification
+- **THEN** the system can create a command log entry for that command through the normal command-log subscriber flow
+
+#### Scenario: Nested pause requires matching resumes
+- **GIVEN** command-log persistence is enabled
+- **AND** command log persistence has been paused twice
+- **WHEN** command log persistence is resumed once
+- **THEN** command log persistence remains paused
+- **WHEN** command log persistence is resumed a second time
+- **THEN** subsequent eligible commands can be persisted through the normal command-log subscriber flow
+
+### Requirement: Initial fixture script commands are not logged
+The system SHALL pause command log persistence while a configured initial fixture script is being installed during application startup.
+The system MUST resume command log persistence after the initial fixture script installation completes.
+The system MUST resume command log persistence if the initial fixture script installation fails.
+The pause MUST apply only to command-log persistence and MUST NOT prevent the fixture script from executing its domain logic normally.
+
+#### Scenario: Initial fixture script commands are suppressed
+- **GIVEN** command-log persistence is enabled
+- **AND** an application has a configured initial fixture script
+- **WHEN** the system installs the initial fixture script during startup
+- **THEN** commands produced by that initial fixture script are not persisted as command log entries
+- **AND** the fixture script domain logic still executes normally
+
+#### Scenario: Logging resumes after successful initial fixture installation
+- **GIVEN** command-log persistence is enabled
+- **AND** an application has installed its configured initial fixture script during startup
+- **WHEN** a subsequent eligible command is published after initial fixture installation completes
+- **THEN** the system can persist that command as a command log entry through the normal command-log subscriber flow
+
+#### Scenario: Logging resumes after failed initial fixture installation
+- **GIVEN** command-log persistence is enabled
+- **AND** an application has a configured initial fixture script that fails during startup installation
+- **WHEN** command processing continues after the failed initial fixture installation scope exits
+- **THEN** command log persistence is no longer paused because of the initial fixture installation scope
+
diff --git a/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/events/InitialFixtureScriptsInstalledEvent.java b/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/events/InitialFixtureScriptsInstalledEvent.java
new file mode 100644
index 00000000000..5e2df57dd65
--- /dev/null
+++ b/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/events/InitialFixtureScriptsInstalledEvent.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.testing.fixtures.applib.events;
+
+import org.apache.causeway.applib.events.EventObjectBase;
+
+/**
+ * Posted immediately after the configured initial fixture script installation scope exits.
+ *
+ * @since 3.x {@index}
+ */
+public class InitialFixtureScriptsInstalledEvent extends EventObjectBase<Object> {
+
+ public InitialFixtureScriptsInstalledEvent(final Object source) {
+ super(source);
+ }
+
+}
diff --git a/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/events/InitialFixtureScriptsInstallingEvent.java b/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/events/InitialFixtureScriptsInstallingEvent.java
new file mode 100644
index 00000000000..e0099ad36a2
--- /dev/null
+++ b/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/events/InitialFixtureScriptsInstallingEvent.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.testing.fixtures.applib.events;
+
+import org.apache.causeway.applib.events.EventObjectBase;
+
+/**
+ * Posted immediately before the configured initial fixture script is installed.
+ *
+ * @since 3.x {@index}
+ */
+public class InitialFixtureScriptsInstallingEvent extends EventObjectBase<Object> {
+
+ public InitialFixtureScriptsInstallingEvent(final Object source) {
+ super(source);
+ }
+
+}
diff --git a/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller.java b/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller.java
index 4442ecaecd6..14def162421 100644
--- a/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller.java
+++ b/testing/fixtures/applib/src/main/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller.java
@@ -31,7 +31,10 @@
import org.apache.causeway.applib.annotation.PriorityPrecedence;
import org.apache.causeway.applib.events.metamodel.MetamodelEvent;
+import org.apache.causeway.applib.services.eventbus.EventBusService;
import org.apache.causeway.core.config.CausewayConfiguration;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstalledEvent;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstallingEvent;
import org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScript;
import org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScripts;
@@ -48,15 +51,18 @@
public class InitialFixtureScriptsInstaller {
private final FixtureScripts fixtureScripts;
+ private final EventBusService eventBusService;
private FixtureScript initialFixtureScript;
@Inject
public InitialFixtureScriptsInstaller(
final CausewayConfiguration causewayConfiguration,
- final FixtureScripts fixtureScripts) {
+ final FixtureScripts fixtureScripts,
+ final EventBusService eventBusService) {
this.fixtureScripts = fixtureScripts;
+ this.eventBusService = eventBusService;
final Class<?> initialScript = causewayConfiguration.getTesting().getFixtures().getInitialScript();
if (initialScript != null
@@ -79,7 +85,12 @@ public void onMetamodelEvent(final MetamodelEvent event) {
&& initialFixtureScript != null) {
log.info("install initial fixtures from script {}", initialFixtureScript.getFriendlyName());
- fixtureScripts.run(initialFixtureScript);
+ try {
+ eventBusService.post(new InitialFixtureScriptsInstallingEvent(this));
+ fixtureScripts.run(initialFixtureScript);
+ } finally {
+ eventBusService.post(new InitialFixtureScriptsInstalledEvent(this));
+ }
}
}
diff --git a/testing/fixtures/applib/src/test/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller_Test.java b/testing/fixtures/applib/src/test/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller_Test.java
new file mode 100644
index 00000000000..d7c8eb49f22
--- /dev/null
+++ b/testing/fixtures/applib/src/test/java/org/apache/causeway/testing/fixtures/applib/services/InitialFixtureScriptsInstaller_Test.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.causeway.testing.fixtures.applib.services;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+import java.util.Optional;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.InOrder;
+import org.springframework.core.env.StandardEnvironment;
+
+import org.apache.causeway.applib.events.metamodel.MetamodelEvent;
+import org.apache.causeway.applib.services.eventbus.EventBusService;
+import org.apache.causeway.core.config.CausewayConfiguration;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstalledEvent;
+import org.apache.causeway.testing.fixtures.applib.events.InitialFixtureScriptsInstallingEvent;
+import org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScript;
+import org.apache.causeway.testing.fixtures.applib.fixturescripts.FixtureScripts;
+
+class InitialFixtureScriptsInstaller_Test {
+
+ @Test
+ void posts_initial_fixture_events_around_initial_script() {
+
+ CausewayConfiguration configuration = new CausewayConfiguration(new StandardEnvironment(), Optional.empty());
+ configuration.getTesting().getFixtures().setInitialScript(TestFixtureScript.class);
+ FixtureScripts fixtureScripts = mock(FixtureScripts.class);
+ EventBusService eventBusService = mock(EventBusService.class);
+ InitialFixtureScriptsInstaller installer = new InitialFixtureScriptsInstaller(
+ configuration, fixtureScripts, eventBusService);
+
+ installer.onMetamodelEvent(MetamodelEvent.AFTER_METAMODEL_LOADED);
+
+ InOrder inOrder = inOrder(eventBusService, fixtureScripts);
+ inOrder.verify(eventBusService).post(any(InitialFixtureScriptsInstallingEvent.class));
+ inOrder.verify(fixtureScripts).run(any(TestFixtureScript.class));
+ inOrder.verify(eventBusService).post(any(InitialFixtureScriptsInstalledEvent.class));
+ verifyNoMoreInteractions(eventBusService);
+ }
+
+ @Test
+ void posts_initial_fixture_installed_event_when_initial_script_fails() {
+
+ CausewayConfiguration configuration = new CausewayConfiguration(new StandardEnvironment(), Optional.empty());
+ configuration.getTesting().getFixtures().setInitialScript(TestFixtureScript.class);
+ FixtureScripts fixtureScripts = mock(FixtureScripts.class);
+ EventBusService eventBusService = mock(EventBusService.class);
+ doThrow(new RuntimeException("boom")).when(fixtureScripts).run(any(TestFixtureScript.class));
+ InitialFixtureScriptsInstaller installer = new InitialFixtureScriptsInstaller(
+ configuration, fixtureScripts, eventBusService);
+
+ try {
+ installer.onMetamodelEvent(MetamodelEvent.AFTER_METAMODEL_LOADED);
+ } catch (RuntimeException ex) {
+ // expected
+ }
+
+ verify(eventBusService).post(any(InitialFixtureScriptsInstallingEvent.class));
+ verify(eventBusService).post(any(InitialFixtureScriptsInstalledEvent.class));
+ }
+
+ public static class TestFixtureScript extends FixtureScript {
+
+ @Override
+ protected void execute(final ExecutionContext executionContext) {
+ }
+ }
+}