This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch 3900-immutable.config
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 161276da127b68dc1851c9ef8734e8078c19071d
Author: Andi Huber <ahu...@apache.org>
AuthorDate: Fri Aug 1 20:07:05 2025 +0200

    CAUSEWAY-3900: mm tests back to green but take 28s vs 7s on v3
---
 .../metamodel/facets/FacetFactoryTestAbstract.java | 29 +++++-----
 .../action/ActionAnnotationFacetFactoryTest.java   |  9 +---
 ...tationFacetFactoryTest_executionPublishing.java | 18 +++++++
 .../DomainObjectAnnotationFacetFactoryTest.java    | 61 +++++++++++-----------
 .../ident/cssclass/CssClassFacetMethodTest.java    |  3 +-
 .../iconfa/FontAwesomeLayersFacetMethodTest.java   |  3 +-
 core/mmtestsupport/pom.xml                         |  2 +
 core/pom.xml                                       |  2 +-
 8 files changed, 72 insertions(+), 55 deletions(-)

diff --git 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
index c9538714be7..34696de3e6b 100644
--- 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
+++ 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/FacetFactoryTestAbstract.java
@@ -20,6 +20,7 @@
 
 import java.util.Optional;
 import java.util.function.BiConsumer;
+import java.util.function.Consumer;
 
 import org.jspecify.annotations.NonNull;
 import org.junit.jupiter.api.AfterEach;
@@ -117,23 +118,20 @@ public static CollectionScenarioBuilder builder(final 
Class<?> declaringClass, f
         }
     }
 
-    // --
+    // -- SETUP
 
     @Getter(onMethod_ = {@Override})
     private MetaModelContext metaModelContext;
 
     private MethodRemover_forTesting methodRemover;
 
-    /**
-     * Override, if a custom {@link MetaModelContext_forTesting} is required 
for certain tests.
-     */
-    protected MetaModelContext_forTesting setUpMmc(
-            final 
MetaModelContext_forTesting.MetaModelContext_forTestingBuilder builder) {
-        return builder.build();
+    @BeforeEach
+    protected void setup() {
+        setup(__->{});
     }
 
-    @BeforeEach
-    protected void setUpAll() {
+    protected final void setup(
+        final 
Consumer<MetaModelContext_forTesting.MetaModelContext_forTestingBuilder> 
customizer) {
 
         var mockTranslationService = Mockito.mock(TranslationService.class);
         var mockInteractionService = Mockito.mock(InteractionService.class);
@@ -141,17 +139,23 @@ protected void setUpAll() {
 
         var iaContext = InteractionContextFactory.testing();
 
-        methodRemover = new MethodRemover_forTesting();
+        this.methodRemover = new MethodRemover_forTesting();
 
-        metaModelContext = setUpMmc(MetaModelContext_forTesting.builder()
+        var builder = MetaModelContext_forTesting.builder()
             .translationService(mockTranslationService)
             .interactionService(mockInteractionService)
             .memberExecutor(mockMemberExecutorService)
-            .valueSemantic(new IntValueSemantics()));
+            .valueSemantic(new IntValueSemantics());
+
+        customizer.accept(builder);
+
+        this.metaModelContext = builder.build();
 
         
Mockito.when(mockInteractionService.currentInteractionContext()).thenReturn(Optional.of(iaContext));
     }
 
+    // -- TEAR DOWN
+
     @AfterEach
     protected void tearDownAll() {
         methodRemover = null;
@@ -188,7 +192,6 @@ void accept(
                 FacetedMethod facetedMethod,
                 OneToManyAssociation mixedInColl);
     }
-
     @FunctionalInterface
     protected static interface ParameterScenarioConsumer {
         void accept(
diff --git 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest.java
 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest.java
index 6ece8d3f21d..bd773df9bec 100644
--- 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest.java
+++ 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest.java
@@ -24,8 +24,6 @@
 import org.junit.jupiter.api.BeforeEach;
 
 import org.apache.causeway.applib.mixins.system.HasInteractionId;
-import org.apache.causeway.commons.internal.exceptions._Exceptions;
-import org.apache.causeway.core.config.metamodel.facets.ActionConfigOptions;
 import org.apache.causeway.core.metamodel.facets.FacetFactoryTestAbstract;
 
 class ActionAnnotationFacetFactoryTest
@@ -39,7 +37,7 @@ public void setUp() throws Exception {
     }
 
     @AfterEach
-    public void tearDown() throws Exception {
+    public void tearDown() {
         facetFactory = null;
     }
 
@@ -55,9 +53,4 @@ public UUID getInteractionId() {
         }
     }
 
-    void allowingPublishingConfigurationToReturn(final 
ActionConfigOptions.PublishingPolicy value) {
-        throw _Exceptions.unsupportedOperation();
-        //FIXME 
getConfiguration().applib().annotation().action().setExecutionPublishing(value);
-    }
-
 }
diff --git 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest_executionPublishing.java
 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest_executionPublishing.java
index 6f4b265271c..3d46c7f422a 100644
--- 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest_executionPublishing.java
+++ 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/actions/action/ActionAnnotationFacetFactoryTest_executionPublishing.java
@@ -18,6 +18,7 @@
  */
 package org.apache.causeway.core.metamodel.facets.actions.action;
 
+import org.jspecify.annotations.Nullable;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -25,10 +26,13 @@
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import org.springframework.boot.test.util.TestPropertyValues;
+
 import org.apache.causeway.applib.annotation.Action;
 import org.apache.causeway.applib.annotation.SemanticsOf;
 import org.apache.causeway.commons.internal.base._Blackhole;
 import org.apache.causeway.core.config.metamodel.facets.ActionConfigOptions;
+import 
org.apache.causeway.core.config.metamodel.facets.ActionConfigOptions.PublishingPolicy;
 import org.apache.causeway.core.metamodel.facetapi.Facet;
 import 
org.apache.causeway.core.metamodel.facets.FacetFactory.ProcessMethodContext;
 import 
org.apache.causeway.core.metamodel.facets.actions.semantics.ActionSemanticsFacet;
@@ -44,8 +48,22 @@ private void processExecutionPublishing(
         facetFactory.processExecutionPublishing(processMethodContext, 
actionIfAny);
     }
 
+    @Override
+    protected void setup() {
+        //overrides default setup method to do nothing
+    }
+
+    private void allowingPublishingConfigurationToReturn(final @Nullable 
PublishingPolicy publishingPolicyOverride) {
+        var testPropertyValues = publishingPolicyOverride!=null
+            ? 
TestPropertyValues.of("causeway.applib.annotation.action.executionPublishing=" 
+ publishingPolicyOverride.name())
+            : TestPropertyValues.empty();
+        super.setup(builder->builder.testPropertyValues(testPropertyValues));
+        facetFactory = new ActionAnnotationFacetFactory(getMetaModelContext());
+    }
+
     @Test
     void given_HasInteractionId_thenIgnored() {
+        allowingPublishingConfigurationToReturn(null); // defaults
         actionScenario(SomeHasInteractionId.class, "someAction", 
(processMethodContext, facetHolder, facetedMethod)->{
             processExecutionPublishing(facetFactory, processMethodContext);
             
assertFalse(ExecutionPublishingFacet.isPublishingEnabled(facetedMethod));
diff --git 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
index 003cfafc993..86db63cfa99 100644
--- 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
+++ 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/domainobject/DomainObjectAnnotationFacetFactoryTest.java
@@ -42,7 +42,6 @@
 import org.apache.causeway.applib.id.LogicalType;
 import org.apache.causeway.applib.mixins.system.HasInteractionId;
 import org.apache.causeway.commons.collections.Can;
-import org.apache.causeway.commons.internal.exceptions._Exceptions;
 import 
org.apache.causeway.core.config.metamodel.facets.DomainObjectConfigOptions;
 import org.apache.causeway.core.metamodel.facetapi.Facet;
 import 
org.apache.causeway.core.metamodel.facets.AbstractTestWithMetaModelContext;
@@ -65,16 +64,11 @@
 import 
org.apache.causeway.core.metamodel.specloader.validator.ValidationFailures;
 import org.apache.causeway.core.mmtestsupport.MetaModelContext_forTesting;
 
-class DomainObjectAnnotationFacetFactoryTest
+abstract class DomainObjectAnnotationFacetFactoryTest
 extends FacetFactoryTestAbstract {
 
     DomainObjectAnnotationFacetFactory facetFactory;
 
-    @BeforeEach
-    void setUp() throws Exception {
-        facetFactory = new 
DomainObjectAnnotationFacetFactory(getMetaModelContext());
-    }
-
     @AfterEach
     protected void tearDown() throws Exception {
         facetFactory = null;
@@ -92,22 +86,28 @@ public UUID getInteractionId() {
 
     }
 
-    void allowingEntityChangePublishingToReturn(final 
DomainObjectConfigOptions.EntityChangePublishingPolicy value) {
-        if(value!=null) {
-            throw _Exceptions.unsupportedOperation();
-            //FIXME 
getConfiguration().applib().annotation().domainObject().setEntityChangePublishing(value);
-        }
+    @Override
+    protected void setup() {
+        //overrides default setup method to do nothing
     }
 
+    void allowingEntityChangePublishingToReturn(final 
DomainObjectConfigOptions.EntityChangePublishingPolicy value) {
+        var testPropertyValues = value!=null
+            ? 
TestPropertyValues.of("causeway.applib.annotation.domainObject.entityChangePublishing="
 + value.name())
+            : TestPropertyValues.empty();
+        super.setup(builder->builder.testPropertyValues(testPropertyValues));
+        facetFactory = new 
DomainObjectAnnotationFacetFactory(getMetaModelContext());
+    }
     void allowingObjectsEditingToReturn(final 
DomainObjectConfigOptions.EditingObjectsConfiguration value) {
-        if(value!=null) {
-            throw _Exceptions.unsupportedOperation();
-            //FIXME 
getConfiguration().applib().annotation().domainObject().setEditing(value);
-        }
+        var testPropertyValues = value!=null
+            ? 
TestPropertyValues.of("causeway.applib.annotation.domainObject.editing=" + 
value.name())
+            : TestPropertyValues.empty();
+        super.setup(builder->builder.testPropertyValues(testPropertyValues));
+        facetFactory = new 
DomainObjectAnnotationFacetFactory(getMetaModelContext());
     }
-
     protected void ignoringConfiguration() {
-
+        super.setup();
+        facetFactory = new 
DomainObjectAnnotationFacetFactory(getMetaModelContext());
     }
 
     public static class EntityChangePublishing extends 
DomainObjectAnnotationFacetFactoryTest {
@@ -224,7 +224,6 @@ public void irrespective_of_configured_value() {
             }
 
         }
-
     }
 
     public static class AutoComplete extends 
DomainObjectAnnotationFacetFactoryTest {
@@ -249,6 +248,11 @@ class CustomerWithDomainObjectAndAutoCompleteRepository {
         class CustomerWithDomainObjectButNoAutoCompleteRepository {
         }
 
+        @BeforeEach
+        public void setUp() {
+            ignoringConfiguration();
+        }
+
         @Test
         public void whenDomainObjectAndAutoCompleteRepositoryAndAction() {
 
@@ -332,10 +336,8 @@ class CustomerWithDomainObjectAndBoundedSetToFalse {
         class CustomerWithDomainObjectButNoBounded {
         }
 
-        @Override
         @BeforeEach
-        public void setUp() throws Exception {
-            super.setUp();
+        public void setUp() {
             ignoringConfiguration();
         }
 
@@ -380,7 +382,6 @@ public void whenNoDomainObjectAnnotation() {
                 assertNoMethodsRemoved();
             });
         }
-
     }
 
     public static class Editing extends DomainObjectAnnotationFacetFactoryTest 
{
@@ -432,9 +433,11 @@ public void configured_value_set_to_false() {
                 });
             }
 
+
+
             @Test
             public void configured_value_set_to_defaults() {
-                //allowingConfigurationToReturn("causeway.objects.editing", 
"foobar");
+                ignoringConfiguration();
                 
objectScenario(DomainObjectAnnotationFacetFactoryTest.Customer.class, 
(processClassContext, facetHolder)->{
                     facetFactory.process(processClassContext);
 
@@ -478,7 +481,7 @@ public void configured_value_set_to_false() {
 
             @Test
             public void configured_value_set_to_defaults() {
-                //allowingConfigurationToReturn("causeway.objects.editing", 
"foobar");
+                ignoringConfiguration();
                 
objectScenario(CustomerWithDomainObjectAndEditingSetToAsConfigured.class, 
(processClassContext, facetHolder)->{
                     facetFactory.process(processClassContext);
 
@@ -536,10 +539,8 @@ class CustomerWithDomainObjectAndObjectTypeSet {
         class CustomerWithDomainObjectButNoObjectType {
         }
 
-        @Override
         @BeforeEach
-        public void setUp() throws Exception {
-            super.setUp();
+        public void setUp() {
             ignoringConfiguration();
         }
 
@@ -596,10 +597,8 @@ class CustomerWithDomainObjectAndNatureSetToViewModel {
         class CustomerWithDomainObjectButNoNature {
         }
 
-        @Override
         @BeforeEach
-        public void setUp() throws Exception {
-            super.setUp();
+        public void setUp() {
             ignoringConfiguration();
         }
 
diff --git 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/cssclass/CssClassFacetMethodTest.java
 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/cssclass/CssClassFacetMethodTest.java
index 5b0995151c0..a95532dcb95 100644
--- 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/cssclass/CssClassFacetMethodTest.java
+++ 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/cssclass/CssClassFacetMethodTest.java
@@ -49,8 +49,9 @@ static class DomainObjectInCssClassMethod {
     private ObjectSupportFacetFactory facetFactory;
 
     @BeforeEach
-    void setup() {
+    final void beforeEach() {
         facetFactory = new ObjectSupportFacetFactory(getMetaModelContext());
+        super.setup();
     }
 
     @AfterEach
diff --git 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/iconfa/FontAwesomeLayersFacetMethodTest.java
 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/iconfa/FontAwesomeLayersFacetMethodTest.java
index d1b3c61ea5e..20349d92711 100644
--- 
a/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/iconfa/FontAwesomeLayersFacetMethodTest.java
+++ 
b/core/mmtest/src/test/java/org/apache/causeway/core/metamodel/facets/object/ident/iconfa/FontAwesomeLayersFacetMethodTest.java
@@ -50,8 +50,9 @@ static class DomainObjectWithFontAwesomeLayersMethod {
     private ObjectSupportFacetFactory facetFactory;
 
     @BeforeEach
-    void setup() {
+    final void beforeEach() {
         facetFactory = new ObjectSupportFacetFactory(getMetaModelContext());
+        super.setup();
     }
 
     @AfterEach
diff --git a/core/mmtestsupport/pom.xml b/core/mmtestsupport/pom.xml
index c27ad7a387d..719c8af149b 100644
--- a/core/mmtestsupport/pom.xml
+++ b/core/mmtestsupport/pom.xml
@@ -28,6 +28,8 @@ additional
     <properties>
         
<jar-plugin.automaticModuleName>org.apache.causeway.core.mmtestsupport</jar-plugin.automaticModuleName>
         
<git-plugin.propertiesDir>org/apache/causeway/core/mmtestsupport</git-plugin.propertiesDir>
+        <maven.deploy.skip>true</maven.deploy.skip> <!-- don't deploy test
+        artifiacts -->
     </properties>
 
     <description>
diff --git a/core/pom.xml b/core/pom.xml
index b75c0649d15..85b99fce05f 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -58,7 +58,7 @@
         <module>internaltestsupport</module>
         <module>metamodel</module>
         <module>mmtestsupport</module>
-<!--        <module>mmtest</module>-->
+        <module>mmtest</module>
         <module>runtime</module>
         <module>runtimeservices</module>
         <module>transaction</module>

Reply via email to