You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/10/06 15:31:37 UTC

[causeway] branch master updated: CAUSEWAY-2297: code quality: cleaning up asserts

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

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/master by this push:
     new efe2e95ca7 CAUSEWAY-2297: code quality: cleaning up asserts
efe2e95ca7 is described below

commit efe2e95ca7254e3be7970a339ec325883bebe116
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Oct 6 17:31:32 2023 +0200

    CAUSEWAY-2297: code quality: cleaning up asserts
---
 .../commons/internal/assertions/_Assert.java       | 126 ++++++++++++---------
 .../commons/internal/exceptions/_Exceptions.java   |   8 +-
 .../appfeat/ApplicationFeatureDefault.java         |   8 +-
 .../core/metamodel/services/appfeat/_Asserts.java  |  11 +-
 .../appfeat/ApplicationFeatureTypeTest.java        |  24 ++--
 .../value/PropertyInteractionProbeImpl.java        |   9 +-
 .../apache/causeway/testdomain/value/_Utils.java   |  14 +--
 .../causeway/testdomain/rospec/BigComplex.java     |  21 +---
 .../testdomain/util/CollectionAssertions.java      |  30 +----
 .../test/components/scalars/ConverterTester.java   |  10 +-
 10 files changed, 119 insertions(+), 142 deletions(-)

diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/assertions/_Assert.java b/commons/src/main/java/org/apache/causeway/commons/internal/assertions/_Assert.java
index b2b6ee0533..5a6ce135fb 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/assertions/_Assert.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/assertions/_Assert.java
@@ -18,6 +18,7 @@
  */
 package org.apache.causeway.commons.internal.assertions;
 
+import java.math.BigDecimal;
 import java.util.Objects;
 import java.util.function.Supplier;
 
@@ -50,20 +51,19 @@ import lombok.extern.log4j.Log4j2;
 @Log4j2
 public final class _Assert {
 
-
     // -- TRUE
 
-    public static void assertTrue(final boolean condition) {
+    public void assertTrue(final boolean condition) {
         assertTrue(condition, (String) null);
     }
 
-    public static void assertTrue(final boolean condition, final String message) {
+    public void assertTrue(final boolean condition, final String message) {
         if (!condition) {
             fail(message, true, false);
         }
     }
 
-    public static void assertTrue(final boolean condition, final Supplier<String> lazyMessage) {
+    public void assertTrue(final boolean condition, final Supplier<String> lazyMessage) {
         if (!condition) {
             fail(lazyMessage.get(), true, false);
         }
@@ -71,17 +71,17 @@ public final class _Assert {
 
     // -- FALSE
 
-    public static void assertFalse(final boolean condition) {
+    public void assertFalse(final boolean condition) {
         assertFalse(condition, (String) null);
     }
 
-    public static void assertFalse(final boolean condition, final String message) {
+    public void assertFalse(final boolean condition, final String message) {
         if (condition) {
             fail(message, false, true);
         }
     }
 
-    public static void assertFalse(final boolean condition, final Supplier<String> lazyMessage) {
+    public void assertFalse(final boolean condition, final Supplier<String> lazyMessage) {
         if (condition) {
             fail(lazyMessage.get(), true, false);
         }
@@ -89,17 +89,17 @@ public final class _Assert {
 
     // -- NULL
 
-    public static void assertNull(final Object object) {
+    public void assertNull(final Object object) {
         assertNull(object, (String) null);
     }
 
-    public static void assertNull(final Object object, final String message) {
+    public void assertNull(final Object object, final String message) {
         if (object!=null) {
             fail(message, "null", "not null");
         }
     }
 
-    public static void assertNull(final Object object, final Supplier<String> lazyMessage) {
+    public void assertNull(final Object object, final Supplier<String> lazyMessage) {
         if (object!=null) {
             fail(lazyMessage.get(), "null", "not null");
         }
@@ -107,17 +107,17 @@ public final class _Assert {
 
     // -- NOT NULL
 
-    public static void assertNotNull(final Object object) {
+    public void assertNotNull(final Object object) {
         assertNotNull(object, (String) null);
     }
 
-    public static void assertNotNull(final Object object, final String message) {
+    public void assertNotNull(final Object object, final String message) {
         if (object==null) {
             fail(message, "not null", "null");
         }
     }
 
-    public static void assertNotNull(final Object object, final Supplier<String> lazyMessage) {
+    public void assertNotNull(final Object object, final Supplier<String> lazyMessage) {
         if (object==null) {
             fail(lazyMessage.get(), "not null", "null");
         }
@@ -129,7 +129,7 @@ public final class _Assert {
      * <em>Assert</em> that {@code left} == {@code right}.
      * @return {@code left} if assertion holds
      */
-    public static <T> T assertSameObject(final T left, final Object right) {
+    public <T> T assertSameObject(final T left, final Object right) {
         assertTrue(left == right);
         return left;
     }
@@ -138,7 +138,7 @@ public final class _Assert {
      * <em>Assert</em> that {@code left} == {@code right}.
      * @return {@code left} if assertion holds
      */
-    public static <T> T assertSameObject(final T left, final Object right, final String msg) {
+    public <T> T assertSameObject(final T left, final Object right, final String msg) {
         assertTrue(left == right, msg);
         return left;
     }
@@ -147,7 +147,7 @@ public final class _Assert {
      * <em>Assert</em> that {@code left} == {@code right}.
      * @return {@code left} if assertion holds
      */
-    public static <T> T assertSameObject(final T left, final Object right, final Supplier<String> lazyMessage) {
+    public <T> T assertSameObject(final T left, final Object right, final Supplier<String> lazyMessage) {
         assertTrue(left == right, lazyMessage);
         return left;
     }
@@ -160,7 +160,7 @@ public final class _Assert {
      *
      * @see Object#equals(Object)
      */
-    public static void assertEquals(final Object left, final Object right) {
+    public void assertEquals(final Object left, final Object right) {
         assertEquals(left, right, (String) null);
     }
 
@@ -171,13 +171,13 @@ public final class _Assert {
      *
      * @see Object#equals(Object)
      */
-    public static void assertEquals(final Object left, final Object right, final String message) {
+    public void assertEquals(final Object left, final Object right, final String message) {
         if (!Objects.equals(left, right)) {
             fail(message, left, right);
         }
     }
 
-    public static void assertEquals(final Object left, final Object right, final Supplier<String> lazyMessage) {
+    public void assertEquals(final Object left, final Object right, final Supplier<String> lazyMessage) {
         if (!Objects.equals(left, right)) {
             fail(lazyMessage.get(), left, right);
         }
@@ -185,25 +185,25 @@ public final class _Assert {
 
     // -- RANGE CHECKS
 
-    public static void assertRangeContains(final _Ints.Range range, final int value, final String message) {
+    public void assertRangeContains(final _Ints.Range range, final int value, final String message) {
         if(!range.contains(value)) {
             fail(message, range.toString(), value);
         }
     }
 
-    public static void assertRangeContains(final _Ints.Range range, final int value, final Supplier<String> lazyMessage) {
+    public void assertRangeContains(final _Ints.Range range, final int value, final Supplier<String> lazyMessage) {
         if(!range.contains(value)) {
             fail(lazyMessage.get(), range.toString(), value);
         }
     }
 
-    public static void assertRangeContains(final _Longs.Range range, final long value, final String message) {
+    public void assertRangeContains(final _Longs.Range range, final long value, final String message) {
         if(!range.contains(value)) {
             fail(message, range.toString(), value);
         }
     }
 
-    public static void assertRangeContains(final _Longs.Range range, final long value, final Supplier<String> lazyMessage) {
+    public void assertRangeContains(final _Longs.Range range, final long value, final Supplier<String> lazyMessage) {
         if(!range.contains(value)) {
             fail(lazyMessage.get(), range.toString(), value);
         }
@@ -211,17 +211,17 @@ public final class _Assert {
 
     // -- STRING CHECKS
 
-    public static void assertNotEmpty(final String s) {
+    public void assertNotEmpty(final String s) {
         assertNotEmpty(s, (String) null);
     }
 
-    public static void assertNotEmpty(final String s, final String message) {
+    public void assertNotEmpty(final String s, final String message) {
         if(_NullSafe.isEmpty(s)) {
             fail(message, "not empty", "empty");
         }
     }
 
-    public static void assertNotEmpty(final String s, final Supplier<String> lazyMessage) {
+    public void assertNotEmpty(final String s, final Supplier<String> lazyMessage) {
         if(_NullSafe.isEmpty(s)) {
             fail(lazyMessage.get(), "not empty", "empty");
         }
@@ -232,10 +232,10 @@ public final class _Assert {
     /**
      * Asserts, that given {@code type} is an instance of {@code requiredType}.
      */
-    public static void assertTypeIsInstanceOf(final @NonNull Class<?> type, final @NonNull Class<?> requiredType) {
+    public void assertTypeIsInstanceOf(final @NonNull Class<?> type, final @NonNull Class<?> requiredType) {
         if(!requiredType.isAssignableFrom(type)) {
-            throw _Exceptions.assertionError(String.format(
-                    "unexpected type: '%s' is not an instance of '%s' ", ""+type, ""+requiredType));
+            throw _Exceptions.assertionError(
+                    "unexpected type: '%s' is not an instance of '%s' ", ""+type, ""+requiredType);
         }
     }
 
@@ -244,43 +244,57 @@ public final class _Assert {
      * <p>
      * If {@code pojo} is {@code null}, the assertion is always satisfied.
      */
-    public static void assertNullableObjectIsInstanceOf(final @Nullable Object pojo, final @NonNull Class<?> requiredType) {
+    public void assertNullableObjectIsInstanceOf(final @Nullable Object pojo, final @NonNull Class<?> requiredType) {
         if(pojo==null) return; // skip check
         assertTypeIsInstanceOf(pojo.getClass(), requiredType);
     }
 
-    // -- OPEN/CLOSE STATE
-
-    public enum OpenCloseState {
-
-        NOT_INITIALIZED,
-        OPEN,
-        CLOSED
-        ;
+    // -- NUMBERS
 
-        public boolean isNotInitialized() { return this == NOT_INITIALIZED; }
-        public boolean isOpen() { return this == OPEN; }
-        public boolean isClosed() { return this == CLOSED; }
+    /**
+     * BigDecimal equality by value.
+     */
+    public void assertNumberEquals(final @Nullable BigDecimal a, final @Nullable BigDecimal b) {
+        if(a==null || b==null) {
+            assertEquals(a, b);
+            return;
+        }
+        val maxScale = Math.max(a.scale(), b.scale());
+        assertEquals(
+                a.setScale(maxScale),
+                b.setScale(maxScale));
+    }
 
-        /**
-         * @param expected - nullable
-         * @throws IllegalArgumentException if {@code this} not equal to {@code expected}
-         */
-        public void assertEquals(
-                final @Nullable OpenCloseState expected) {
-            if (expected != this) {
-                throw new IllegalStateException("State is: " + this + "; should be: " + expected);
-            }
+    /**
+     * double equality by value relaxed by delta
+     */
+    public void assertNumberEquals(final double a, final double b, final double delta) {
+        if (Double.isNaN(delta) || delta < 0.0) {
+            throw _Exceptions.assertionError(
+                    "invalid delta: '%s'", String.valueOf(delta));
+        }
+        if((Double.doubleToLongBits(a) != Double.doubleToLongBits(b))
+                || Math.abs(a - b) <= delta) {
+            throw _Exceptions.assertionError(
+                    "Numbers %s and %s are not equal within delta %s",
+                        String.valueOf(a), String.valueOf(b),
+                        String.valueOf(delta));
         }
+    }
 
+    /**
+     * Generic number equality check, use with caution!
+     */
+    public void assertNumberEqualsUnsafe(final @Nullable Number a, final @Nullable Number b, final double delta) {
+        if(a==null || b==null) {
+            assertEquals(a, b);
+            return;
+        }
+        assertNumberEquals(a.doubleValue(), b.doubleValue(), delta);
     }
 
     // -- HELPER
 
-    static String buildPrefix(final String message) {
-        return _Strings.isNotEmpty(message) ? message + " ==> " : "";
-    }
-
     private static void fail(final String message, final Object expected, final Object actual) {
         val error = _Exceptions.assertionError(
                 buildPrefix(message)
@@ -288,6 +302,8 @@ public final class _Assert {
         log.error(error); // in case exceptions get swallowed, make sure errors at least get logged
         throw error;
     }
-
+    private static String buildPrefix(final String message) {
+        return _Strings.isNotEmpty(message) ? message + " ==> " : "";
+    }
 
 }
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/exceptions/_Exceptions.java b/commons/src/main/java/org/apache/causeway/commons/internal/exceptions/_Exceptions.java
index 05b073452e..76382208ba 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/exceptions/_Exceptions.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/exceptions/_Exceptions.java
@@ -184,7 +184,7 @@ public final class _Exceptions {
     }
 
 
-    private static String safelyFormat(String format, Object... args) {
+    private static String safelyFormat(final String format, final Object... args) {
         try {
             return String.format(format, args);
         } catch (Throwable ex) {
@@ -193,14 +193,16 @@ public final class _Exceptions {
         }
     }
 
-
-
     // -- ASSERT
 
     public static AssertionError assertionError(final String msg) {
         return new AssertionError(msg);
     }
 
+    public static AssertionError assertionError(final String format, final Object ...args) {
+        return new AssertionError(safelyFormat(format, args));
+    }
+
     // -- MESSAGE
 
     public static String getMessage(final Throwable ex) {
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureDefault.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureDefault.java
index 9950cba670..ff2d448d71 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureDefault.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureDefault.java
@@ -109,14 +109,14 @@ Comparable<ApplicationFeature> {
     // -- PACKAGE PRIVATE ACCESS
 
     void addToContents(final ApplicationFeatureId contentId) {
-        _Asserts.ensureNamespace(this.getFeatureId());
-        _Asserts.ensureNamespaceOrType(contentId);
+        _Asserts.assertIsNamespace(this.getFeatureId());
+        _Asserts.assertIsNamespaceOrType(contentId);
         this.contents.add(contentId);
     }
 
     void addToMembers(final ApplicationFeatureId memberId, final ApplicationMemberSort memberSort) {
-        _Asserts.ensureType(this.getFeatureId());
-        _Asserts.ensureMember(memberId);
+        _Asserts.assertIsType(this.getFeatureId());
+        _Asserts.assertIsMember(memberId);
 
         getMembersOfSort(memberSort).add(memberId);
     }
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/_Asserts.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/_Asserts.java
index 43c1fbcc04..786146d529 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/_Asserts.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/appfeat/_Asserts.java
@@ -21,28 +21,31 @@ package org.apache.causeway.core.metamodel.services.appfeat;
 import org.apache.causeway.applib.services.appfeat.ApplicationFeatureId;
 import org.apache.causeway.applib.services.appfeat.ApplicationFeatureSort;
 
+import lombok.experimental.UtilityClass;
+
+@UtilityClass
 final class _Asserts {
 
-    public static void ensureNamespace(final ApplicationFeatureId feature) {
+    void assertIsNamespace(final ApplicationFeatureId feature) {
         if(feature.getSort() != ApplicationFeatureSort.NAMESPACE) {
             throw new IllegalStateException("Can only be called for a package; " + feature.toString());
         }
     }
 
-    public static void ensureNamespaceOrType(final ApplicationFeatureId applicationFeatureId) {
+    void assertIsNamespaceOrType(final ApplicationFeatureId applicationFeatureId) {
         if(applicationFeatureId.getSort() != ApplicationFeatureSort.NAMESPACE
                 && applicationFeatureId.getSort() != ApplicationFeatureSort.TYPE) {
             throw new IllegalStateException("Can only be called for a package or a class; " + applicationFeatureId.toString());
         }
     }
 
-    public static void ensureType(final ApplicationFeatureId feature) {
+    void assertIsType(final ApplicationFeatureId feature) {
         if(feature.getSort() != ApplicationFeatureSort.TYPE) {
             throw new IllegalStateException("Can only be called for a class; " + feature.toString());
         }
     }
 
-    public static void ensureMember(final ApplicationFeatureId feature) {
+    void assertIsMember(final ApplicationFeatureId feature) {
         if(feature.getSort() != ApplicationFeatureSort.MEMBER) {
             throw new IllegalStateException("Can only be called for a member; " + feature.toString());
         }
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java
index d90f4c509d..05d1086970 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/services/appfeat/ApplicationFeatureTypeTest.java
@@ -94,17 +94,17 @@ class ApplicationFeatureTypeTest {
 
         @Test
         public void whenPackage() throws Exception {
-            _Asserts.ensureNamespace(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx"));
+            _Asserts.assertIsNamespace(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx"));
         }
         @Test
         public void whenClass() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureNamespace(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx")));
+                _Asserts.assertIsNamespace(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx")));
         }
         @Test
         public void whenMember() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureNamespace(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x")));
+                _Asserts.assertIsNamespace(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x")));
         }
     }
 
@@ -112,16 +112,16 @@ class ApplicationFeatureTypeTest {
 
         @Test
         public void whenPackage() throws Exception {
-            _Asserts.ensureNamespaceOrType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx"));
+            _Asserts.assertIsNamespaceOrType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx"));
         }
         @Test
         public void whenClass() throws Exception {
-            _Asserts.ensureNamespaceOrType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx"));
+            _Asserts.assertIsNamespaceOrType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx"));
         }
         @Test
         public void whenMember() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureNamespaceOrType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x")));
+                _Asserts.assertIsNamespaceOrType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x")));
         }
 
     }
@@ -131,16 +131,16 @@ class ApplicationFeatureTypeTest {
         @Test
         public void whenPackage() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx")));
+                _Asserts.assertIsType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx")));
         }
         @Test
         public void whenClass() throws Exception {
-            _Asserts.ensureType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx"));
+            _Asserts.assertIsType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx"));
         }
         @Test
         public void whenMember() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x")));
+                _Asserts.assertIsType(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x")));
         }
 
     }
@@ -150,16 +150,16 @@ class ApplicationFeatureTypeTest {
         @Test
         public void whenPackage() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureMember(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx")));
+                _Asserts.assertIsMember(ApplicationFeatureId.newFeature(ApplicationFeatureSort.NAMESPACE, "xxx")));
         }
         @Test
         public void whenClass() throws Exception {
             assertThrows(IllegalStateException.class, ()->
-                _Asserts.ensureMember(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx")));
+                _Asserts.assertIsMember(ApplicationFeatureId.newFeature(ApplicationFeatureSort.TYPE, "x.xxx")));
         }
         @Test
         public void whenMember() throws Exception {
-            _Asserts.ensureMember(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x"));
+            _Asserts.assertIsMember(ApplicationFeatureId.newFeature(ApplicationFeatureSort.MEMBER, "x.xxx#x"));
         }
     }
 
diff --git a/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/PropertyInteractionProbeImpl.java b/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/PropertyInteractionProbeImpl.java
index ee135f4dfc..4e12901f1a 100644
--- a/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/PropertyInteractionProbeImpl.java
+++ b/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/PropertyInteractionProbeImpl.java
@@ -40,6 +40,7 @@ import org.apache.causeway.applib.value.semantics.Renderer;
 import org.apache.causeway.applib.value.semantics.ValueDecomposition;
 import org.apache.causeway.applib.value.semantics.ValueSemanticsProvider;
 import org.apache.causeway.commons.functional.Try;
+import org.apache.causeway.commons.internal.assertions._Assert;
 import org.apache.causeway.commons.internal.base._Strings;
 import org.apache.causeway.core.metamodel.consent.InteractionInitiatedBy;
 import org.apache.causeway.core.metamodel.interactions.managed.ActionInteraction;
@@ -57,12 +58,12 @@ import lombok.val;
 
 @RequiredArgsConstructor
 class PropertyInteractionProbeImpl<T> implements PropertyInteractionProbe<T> {
-    
+
     final @NonNull String name;
     final @NonNull Class<T> valueType;
     final @NonNull ValueTypeExample<T> example;
     final @NonNull ValueSemanticsTester<T> tester;
-    
+
     @Inject private SpecificationLoader specLoader;
     @Inject private SchemaValueMarshaller valueMarshaller;
     @Inject private WrapperFactory wrapperFactory;
@@ -152,7 +153,7 @@ class PropertyInteractionProbeImpl<T> implements PropertyInteractionProbe<T> {
                     val parsedValue = parser.parseTextRepresentation(context, in);
 
                     if(value instanceof BigDecimal) {
-                        _Utils.assertNumberEquals((BigDecimal)value, (BigDecimal)parsedValue);
+                        _Assert.assertNumberEquals((BigDecimal)value, (BigDecimal)parsedValue);
                     } else {
                         assertEquals(value, parsedValue);
                     }
@@ -275,5 +276,5 @@ class PropertyInteractionProbeImpl<T> implements PropertyInteractionProbe<T> {
                 parsedValue.getValue().orElse(null),
                 failureMessage);
     }
-    
+
 }
diff --git a/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/_Utils.java b/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/_Utils.java
index 6d9bfce57e..1d29f3b3ff 100644
--- a/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/_Utils.java
+++ b/regressiontests/stable-value/src/test/java/org/apache/causeway/testdomain/value/_Utils.java
@@ -18,11 +18,8 @@
  */
 package org.apache.causeway.testdomain.value;
 
-import java.math.BigDecimal;
 import java.util.Locale;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
 import org.apache.causeway.applib.locale.UserLocale;
 import org.apache.causeway.applib.services.iactnlayer.InteractionContext;
 import org.apache.causeway.commons.functional.Try;
@@ -36,17 +33,10 @@ import lombok.experimental.UtilityClass;
 @UtilityClass
 class _Utils {
 
-    void assertNumberEquals(final BigDecimal a, final BigDecimal b) {
-        val maxScale = Math.max(a.scale(), b.scale());
-        assertEquals(
-                a.setScale(maxScale),
-                b.setScale(maxScale));
-    }
-    
     InteractionContext interactionContext() {
         return InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build();
     }
-    
+
     // eg.. <ValueWithTypeDto type="string"><com:string>anotherString</com:string></ValueWithTypeDto>
     String valueDtoToXml(final ValueWithTypeDto valueWithTypeDto) {
         val rawXml = Try.call(()->JaxbUtils.toStringUtf8(valueWithTypeDto, opts->opts
@@ -62,5 +52,5 @@ class _Utils {
                 + "</ValueWithTypeDto>";
 
     }
-    
+
 }
diff --git a/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/rospec/BigComplex.java b/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/rospec/BigComplex.java
index 7bd0d73634..8a534e2f65 100644
--- a/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/rospec/BigComplex.java
+++ b/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/rospec/BigComplex.java
@@ -42,31 +42,24 @@ public final class BigComplex {
         return BigComplex.of(BigDecimal.ZERO, BigDecimal.ZERO);
     }
 
-    public static BigComplex of(String re, String im) {
+    public static BigComplex of(final String re, final String im) {
         return BigComplex.of(new BigDecimal(re), new BigDecimal(im));
     }
 
-    public BigComplex add(BigComplex other) {
+    public BigComplex add(final BigComplex other) {
         return BigComplex.of(
                 this.re.add(other.re),
                 this.im.add(other.im));
     }
 
-    public BigComplex subtract(BigComplex other) {
+    public BigComplex subtract(final BigComplex other) {
         return BigComplex.of(
                 this.re.subtract(other.re),
                 this.im.subtract(other.im));
     }
 
-// java 9 dependency
-//    public BigDecimal norm() {
-//        return this.re.multiply(this.re)
-//                .add(this.im.multiply(this.im))
-//                .sqrt(MathContext.UNLIMITED);
-//    }
-
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if(!(obj instanceof BigComplex)) {
             return false;
         }
@@ -80,13 +73,9 @@ public final class BigComplex {
         return Objects.hash(re, im);
     }
 
-    public static void assertEquals(BigComplex a, BigComplex b) {
+    public static void assertEquals(final BigComplex a, final BigComplex b) {
         _Assert.assertEquals(a.re.toPlainString(), b.re.toPlainString());
         _Assert.assertEquals(a.im.toPlainString(), b.im.toPlainString());
     }
 
-//    public static void assertNumberEquals(BigComplex a, BigComplex b, double epsilon) {
-//        _Assert.assertTrue(a.subtract(b).norm().doubleValue()<epsilon);
-//    }
-
 }
diff --git a/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/util/CollectionAssertions.java b/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/util/CollectionAssertions.java
index 7be86f20f8..69cae44ae0 100644
--- a/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/util/CollectionAssertions.java
+++ b/regressiontests/stable/src/main/java/org/apache/causeway/testdomain/util/CollectionAssertions.java
@@ -27,6 +27,7 @@ import org.assertj.core.api.Assertions;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import org.apache.causeway.commons.internal.assertions._Assert;
 import org.apache.causeway.commons.internal.base._NullSafe;
 import org.apache.causeway.commons.internal.collections._Arrays;
 import org.apache.causeway.core.metamodel.object.ManagedObject;
@@ -35,19 +36,16 @@ import lombok.val;
 
 public final class CollectionAssertions {
 
-    public static void assertComponentWiseEquals(Object a, Object b) {
-
+    public static void assertComponentWiseEquals(final Object a, final Object b) {
         val array1 = _NullSafe.streamAutodetect(a)
             .collect(_Arrays.toArray(Object.class));
         val array2 = _NullSafe.streamAutodetect(b)
             .collect(_Arrays.toArray(Object.class));
 
         assertArrayEquals(array1, array2);
-
     }
 
-    public static <T> void assertComponentWiseEquals(Object a, Object b, BiFunction<T, T, String> difference) {
-
+    public static <T> void assertComponentWiseEquals(final Object a, final Object b, final BiFunction<T, T, String> difference) {
         @SuppressWarnings("unchecked")
         final List<T> list1 = _NullSafe.streamAutodetect(a)
                 .map(t->(T)t)
@@ -60,7 +58,6 @@ public final class CollectionAssertions {
         assertEquals(list1.size(), list2.size(), "expected element count equals");
 
         for(int i=0; i<list1.size(); ++i) {
-
             final int index = i;
             val u = list1.get(i);
             val v = list2.get(i);
@@ -70,13 +67,10 @@ public final class CollectionAssertions {
             if(delta!=null) {
                 Assertions.fail(String.format("elements at index %d differ: %s", index, delta));
             }
-
         }
-
     }
 
-    public static void assertComponentWiseNumberEquals(Object a, Object b) {
-
+    public static void assertComponentWiseNumberEquals(final Object a, final Object b) {
         val array1 = _NullSafe.streamAutodetect(a)
             .map(Number.class::cast)
             .collect(_Arrays.toArray(Number.class));
@@ -87,13 +81,11 @@ public final class CollectionAssertions {
         assertEquals(array1.length, array2.length);
 
         for(int i=0; i<array1.length; ++i) {
-            assertNumberEqualsPoorManEdition(array1[i], array2[i]);
+            _Assert.assertNumberEqualsUnsafe(array1[i], array2[i], 1E-9);
         }
-
     }
 
-    public static void assertComponentWiseUnwrappedEquals(Object a, Object b) {
-
+    public static void assertComponentWiseUnwrappedEquals(final Object a, final Object b) {
         val array1 = _NullSafe.streamAutodetect(a)
             .map(element->(element instanceof ManagedObject)
                     ? ((ManagedObject)element).getPojo()
@@ -107,16 +99,6 @@ public final class CollectionAssertions {
                 .collect(_Arrays.toArray(Object.class));
 
         assertArrayEquals(array1, array2);
-
     }
 
-    private static void assertNumberEqualsPoorManEdition(Number a, Number b) {
-        if(a==null) {
-            assertEquals((Object)null, (Object)b);
-            return;
-        }
-        assertEquals(a.doubleValue(), b.doubleValue(), 1E-9);
-    }
-
-
 }
diff --git a/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/test/components/scalars/ConverterTester.java b/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/test/components/scalars/ConverterTester.java
index 58a982ec92..5d8bdf7037 100644
--- a/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/test/components/scalars/ConverterTester.java
+++ b/viewers/wicket/ui-test/src/test/java/org/apache/causeway/viewer/wicket/ui/test/components/scalars/ConverterTester.java
@@ -43,6 +43,7 @@ import org.apache.causeway.applib.services.iactnlayer.InteractionService;
 import org.apache.causeway.applib.value.semantics.ValueSemanticsAbstract;
 import org.apache.causeway.applib.value.semantics.ValueSemanticsResolver;
 import org.apache.causeway.commons.functional.ThrowingRunnable;
+import org.apache.causeway.commons.internal.assertions._Assert;
 import org.apache.causeway.commons.internal.base._Strings;
 import org.apache.causeway.core.metamodel._testing.MetaModelContext_forTesting;
 import org.apache.causeway.core.metamodel.commons.ViewOrEditMode;
@@ -147,7 +148,7 @@ public class ConverterTester<T extends Serializable> {
             val parsedValue = scenario.converter.convertToObject(valueAsText, LOCALE_NOT_USED);
 
             if(value instanceof BigDecimal) {
-                assertNumberEquals(
+                _Assert.assertNumberEquals(
                         (BigDecimal)value, (BigDecimal)parsedValue);
             } else if(value instanceof java.util.Date) {
                 assertTemporalEquals(
@@ -183,13 +184,6 @@ public class ConverterTester<T extends Serializable> {
 
     // -- HELPER
 
-    private static void assertNumberEquals(final BigDecimal a, final BigDecimal b) {
-        val maxScale = Math.max(a.scale(), b.scale());
-        assertEquals(
-                a.setScale(maxScale),
-                b.setScale(maxScale));
-    }
-
     @SuppressWarnings("deprecation")
     private void assertTemporalEquals(final java.util.Date a, final java.util.Date b) {
         assertEquals(a.getDay(), b.getDay());