Fix non-null messages used in tests 19/143019/1
authordanielhanrahan <daniel.hanrahan@est.tech>
Mon, 26 Jan 2026 16:38:21 +0000 (16:38 +0000)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Mon, 26 Jan 2026 16:38:21 +0000 (16:38 +0000)
Many tests are needlessly using regular expressions like:
  "Object is marked .*on.*ull but is null"
instead of:
  "Object is marked non-null but is null"

Issue-ID: POLICY-5509
Change-Id: Ic6d0fa32058d68b74075986ca98cfbc8197076d3
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
17 files changed:
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionRollbackTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJobTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantReplicaTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/utils/StateDefinitionTest.java
policy-models/src/test/java/org/onap/policy/models/base/PfConceptKeyTest.java
policy-models/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java
policy-models/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplateTest.java
policy-models/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java
policy-models/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java
policy-models/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplateTest.java
policy-models/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplateTest.java

index 62d3ada..d25dd45 100644 (file)
@@ -44,9 +44,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
  */
 class JpaAutomationCompositionElementTest {
 
-    private static final String NULL_INSTANCE_ID_ERROR = "instanceId is marked .*ull but is null";
-    private static final String NULL_ELEMENT_ID_ERROR = "elementId is marked .*ull but is null";
-    private static final String NULL_ERROR = " is marked .*ull but is null";
+    private static final String NULL_INSTANCE_ID_ERROR = "instanceId is marked non-null but is null";
+    private static final String NULL_ELEMENT_ID_ERROR = "elementId is marked non-null but is null";
+    private static final String NULL_ERROR = " is marked non-null but is null";
     private static final String ELEMENT_ID = "a95757ba-b34a-4049-a2a8-46773abcbe5e";
     private static final String INSTANCE_ID = "a78757co-b34a-8949-a2a8-46773abcbe2a";
     private static final String KEY = "key";
index 6079b7e..eeee448 100644 (file)
@@ -32,8 +32,8 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionRollback;
 \r
 class JpaAutomationCompositionRollbackTest {\r
 \r
-    private static final String NULL_INSTANCE_ID_ERROR = "instanceId is marked .*ull but is null";\r
-    private static final String NULL_ERROR = " is marked .*ull but is null";\r
+    private static final String NULL_INSTANCE_ID_ERROR = "instanceId is marked non-null but is null";\r
+    private static final String NULL_ERROR = " is marked non-null but is null";\r
     private static final String INSTANCE_ID = "709c62b3-8918-41b9-a747-d21eb79c6c20";\r
     private static final String COMPOSITION_ID = "709c62b3-8918-41b9-a747-e21eb79c6c41";\r
 \r
index 7a8dda0..e310494 100644 (file)
@@ -43,7 +43,7 @@ import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
  * Test the{@link JpaAutomationCompositionTest} class.
  */
 class JpaAutomationCompositionTest {
-    private static final String NULL_ERROR = " is marked .*ull but is null";
+    private static final String NULL_ERROR = " is marked non-null but is null";
     private static final String INSTANCE_ID = "709c62b3-8918-41b9-a747-d21eb79c6c20";
     private static final String COMPOSITION_ID = "709c62b3-8918-41b9-a747-e21eb79c6c41";
 
@@ -95,7 +95,7 @@ class JpaAutomationCompositionTest {
         var testJpaAutomationComposition = new JpaAutomationComposition(createAutomationCompositionInstance());
 
         assertThatThrownBy(() -> testJpaAutomationComposition.validate(null))
-                .hasMessageMatching("fieldName is marked .*ull but is null");
+                .hasMessageMatching("fieldName is marked non-null but is null");
 
         assertTrue(testJpaAutomationComposition.validate("").isValid());
     }
index bf673be..c8bc561 100644 (file)
@@ -32,7 +32,7 @@ class JpaMessageJobTest {
     @Test
     void testJpaMessageJobConstructor() {
         assertThatThrownBy(() -> new JpaMessageJob(null))
-                .hasMessageMatching("identificationId is marked .*ull but is null");
+                .hasMessageMatching("identificationId is marked non-null but is null");
     }
 
     @Test
@@ -40,7 +40,7 @@ class JpaMessageJobTest {
         var jpaMessageJob = new JpaMessageJob();
 
         assertThatThrownBy(() -> jpaMessageJob.validate(null))
-                .hasMessageMatching("fieldName is marked .*ull but is null");
+                .hasMessageMatching("fieldName is marked non-null but is null");
 
         assertTrue(jpaMessageJob.validate("").isValid());
 
index f9a19c4..0e091ec 100644 (file)
@@ -36,9 +36,9 @@ class JpaMessageTest {
     @Test
     void testJpaMessageConstructor() {
         assertThatThrownBy(() -> new JpaMessage(null, new DocMessage()))
-                .hasMessageMatching("identificationId is marked .*ull but is null");
+                .hasMessageMatching("identificationId is marked non-null but is null");
         assertThatThrownBy(() -> new JpaMessage(UUID.randomUUID().toString(), null))
-                .hasMessageMatching("docMessage is marked .*ull but is null");
+                .hasMessageMatching("docMessage is marked non-null but is null");
     }
 
     @Test
@@ -47,7 +47,7 @@ class JpaMessageTest {
         var jpaMessage = new JpaMessage(docMessage.getInstanceId().toString(), docMessage);
 
         assertThatThrownBy(() -> jpaMessage.validate(null))
-                .hasMessageMatching("fieldName is marked .*ull but is null");
+                .hasMessageMatching("fieldName is marked non-null but is null");
 
         assertTrue(jpaMessage.validate("").isValid());
 
@@ -64,7 +64,7 @@ class JpaMessageTest {
         assertEquals(docMessage, jpaMessage.toAuthorative());
 
         assertThatThrownBy(() -> jpaMessage.fromAuthorative(null))
-                .hasMessageMatching("docMessage is marked .*ull but is null");
+                .hasMessageMatching("docMessage is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaMessage((JpaMessage) null)).isInstanceOf(NullPointerException.class);
 
index 4f48c66..cac9afa 100644 (file)
@@ -35,10 +35,10 @@ class JpaParticipantReplicaTest {
     @Test
     void testJpaParticipantReplicaConstructor() {
         assertThatThrownBy(() -> new JpaParticipantReplica(UUID.randomUUID().toString(), null))
-                .hasMessageMatching("participantId is marked .*ull but is null");
+                .hasMessageMatching("participantId is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaParticipantReplica(null, UUID.randomUUID().toString()))
-                .hasMessageMatching("replicaId is marked .*ull but is null");
+                .hasMessageMatching("replicaId is marked non-null but is null");
 
         assertDoesNotThrow(() -> new JpaParticipantReplica(UUID.randomUUID().toString(), UUID.randomUUID().toString()));
     }
index 6bd25bb..68a60a9 100644 (file)
@@ -34,9 +34,9 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType
  */
 class JpaParticipantSupportedElementTypeTest {
 
-    private static final String NULL_PARTICIPANT_ID_ERROR = "participantId is marked .*ull but is null";
-    private static final String NULL_ID_ERROR = "id is marked .*ull but is null";
-    private static final String NULL_ERROR = " is marked .*ull but is null";
+    private static final String NULL_PARTICIPANT_ID_ERROR = "participantId is marked non-null but is null";
+    private static final String NULL_ID_ERROR = "id is marked non-null but is null";
+    private static final String NULL_ERROR = " is marked non-null but is null";
     private static final String ID = "a95757ba-b34a-4049-a2a8-46773abcbe5e";
     private static final String PARTICIPANT_ID = "a78757co-b34a-8949-a2a8-46773abcbe2a";
 
@@ -44,7 +44,7 @@ class JpaParticipantSupportedElementTypeTest {
     void testJpaAutomationCompositionElementConstructor() {
         assertThatThrownBy(() -> {
             new JpaParticipantSupportedElementType((JpaParticipantSupportedElementType) null);
-        }).hasMessageMatching("copyConcept is marked .*ull but is null");
+        }).hasMessageMatching("copyConcept is marked non-null but is null");
 
         assertThatThrownBy(() -> {
             new JpaParticipantSupportedElementType("key", null);
@@ -90,7 +90,7 @@ class JpaParticipantSupportedElementTypeTest {
 
         assertThatThrownBy(() -> {
             testJpaSupportElement.fromAuthorative(null);
-        }).hasMessageMatching("participantSupportedElementType is marked .*ull but is null");
+        }).hasMessageMatching("participantSupportedElementType is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaParticipantSupportedElementType((JpaParticipantSupportedElementType) null))
             .isInstanceOf(NullPointerException.class);
index ceca60f..4c2ac0e 100644 (file)
@@ -38,24 +38,24 @@ import org.onap.policy.clamp.models.acm.concepts.Participant;
  */
 class JpaParticipantTest {
 
-    private static final String NULL_KEY_ERROR = "participantId is marked .*ull but is null";
+    private static final String NULL_KEY_ERROR = "participantId is marked non-null but is null";
 
     @Test
     void testJpaParticipantConstructor() {
         assertThatThrownBy(() -> new JpaParticipant((Participant) null))
-            .hasMessageMatching("authorativeConcept is marked .*ull but is null");
+            .hasMessageMatching("authorativeConcept is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null))
-            .hasMessageMatching("copyConcept is marked .*ull but is null");
+            .hasMessageMatching("copyConcept is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaParticipant(null, new ArrayList<>(), new ArrayList<>()))
             .hasMessageMatching(NULL_KEY_ERROR);
 
         assertThatThrownBy(() -> new JpaParticipant(UUID.randomUUID().toString(), null, new ArrayList<>()))
-            .hasMessageMatching("supportedElements is marked .*ull but is null");
+            .hasMessageMatching("supportedElements is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaParticipant(UUID.randomUUID().toString(), new ArrayList<>(), null))
-            .hasMessageMatching("replicas is marked .*ull but is null");
+            .hasMessageMatching("replicas is marked non-null but is null");
 
         assertDoesNotThrow(() -> new JpaParticipant(UUID.randomUUID().toString(),
                 new ArrayList<>(), new ArrayList<>()));
@@ -69,7 +69,7 @@ class JpaParticipantTest {
         assertEquals(participant, testJpaParticipant.toAuthorative());
 
         assertThatThrownBy(() -> testJpaParticipant.fromAuthorative(null))
-            .hasMessageMatching("participant is marked .*ull but is null");
+            .hasMessageMatching("participant is marked non-null but is null");
 
         assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null)).isInstanceOf(NullPointerException.class);
 
@@ -88,7 +88,7 @@ class JpaParticipantTest {
         var testJpaParticipant = new JpaParticipant(createParticipantInstance());
 
         assertThatThrownBy(() -> testJpaParticipant.validate(null))
-            .hasMessageMatching("fieldName is marked .*ull but is null");
+            .hasMessageMatching("fieldName is marked non-null but is null");
 
         assertTrue(testJpaParticipant.validate("").isValid());
     }
index 7df50ad..b3dbb04 100644 (file)
@@ -69,7 +69,7 @@ class ParticipantProviderTest {
         "src/test/resources/providers/TestAutomationCompositions.json";
 
     private static final String NODE_TEMPLATE_STATE_JSON = "src/test/resources/providers/NodeTemplateState.json";
-    private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
+    private static final String LIST_IS_NULL = ".*. is marked non-null but is null";
     private static final UUID INVALID_ID = UUID.randomUUID();
 
     private final List<Participant> inputParticipants = new ArrayList<>();
index c2cbf4b..186e6be 100644 (file)
@@ -30,11 +30,11 @@ class StateDefinitionTest {
     void testNonNull() {
         var stateDefinition = new StateDefinition<String>(2, null);
         assertThatThrownBy(() -> stateDefinition.put(null, null))
-            .hasMessageMatching("keys is marked .*ull but is null");
+            .hasMessageMatching("keys is marked non-null but is null");
         assertThatThrownBy(() -> stateDefinition.put(new String[] {"", ""}, null))
-            .hasMessageMatching("value is marked .*ull but is null");
+            .hasMessageMatching("value is marked non-null but is null");
         assertThatThrownBy(() -> stateDefinition.get(null))
-            .hasMessageMatching("keys is marked .*ull but is null");
+            .hasMessageMatching("keys is marked non-null but is null");
     }
 
     @Test
index 4c8dfc3..753cbe4 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
 class PfConceptKeyTest {
 
     private static final String VERSION001 = "0.0.1";
-    private static final String ID_IS_NULL = "id is marked .*on.*ull but is null$";
+    private static final String ID_IS_NULL = "id is marked non-null but is null$";
 
     @Test
     void testConceptKey() {
@@ -66,10 +66,10 @@ class PfConceptKeyTest {
         assertThatThrownBy(() -> PfConceptKey.getNullKey().matchesId(null)).hasMessageMatching(ID_IS_NULL);
 
         assertThatThrownBy(() -> someKey0.setName(null)).isInstanceOf(NullPointerException.class)
-            .hasMessageMatching("^name is marked .*on.*ull but is null$");
+            .hasMessageMatching("^name is marked non-null but is null$");
 
         assertThatThrownBy(() -> someKey0.setVersion(null)).isInstanceOf(NullPointerException.class)
-            .hasMessageMatching("^version is marked .*on.*ull but is null$");
+            .hasMessageMatching("^version is marked non-null but is null$");
 
         assertThatIllegalArgumentException().isThrownBy(() -> new PfConceptKey("my-name.*", VERSION001)).withMessage(
             "parameter 'name': value 'my-name.*', does not match regular expression '^[A-Za-z0-9\\-_\\.]+$'"
index 83e38e3..df7b5bc 100644 (file)
@@ -43,7 +43,7 @@ import org.onap.policy.models.base.PfKey.Compatibility;
 
 class PfKeyImplTest {
 
-    private static final String ID_IS_NULL = "^id is marked .*on.*ull but is null$";
+    private static final String ID_IS_NULL = "^id is marked non-null but is null$";
     private static final String VERSION001 = "0.0.1";
     private static final String NAME = "name";
     private static MyKey someKey;
@@ -97,7 +97,7 @@ class PfKeyImplTest {
                 + PfKey.KEY_ID_REGEXP + "\"");
 
         assertThatThrownBy(() -> new MyKey((MyKey) null))
-            .hasMessageMatching("^copyConcept is marked .*on.*ull but is null$");
+            .hasMessageMatching("^copyConcept is marked non-null but is null$");
 
         assertTrue(someKey.isNullKey());
         assertEquals(new MyKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION), someKey);
@@ -119,7 +119,7 @@ class PfKeyImplTest {
         assertEquals("name:0.1.2", someKey4.getId());
 
         assertThatThrownBy(() -> someKey0.getCompatibility(null)).isInstanceOf(NullPointerException.class)
-            .hasMessageMatching("^otherKey is marked .*on.*ull but is null$");
+            .hasMessageMatching("^otherKey is marked non-null but is null$");
 
         assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(new PfConceptKey()));
         assertEquals(Compatibility.DIFFERENT, buildKey1.getCompatibility(new PfConceptKey()));
@@ -163,7 +163,7 @@ class PfKeyImplTest {
         assertEquals(-12, someKey7.compareTo(someKey0));
 
         assertThatThrownBy(() -> someKey0.compareTo(null)).isInstanceOf(NullPointerException.class)
-            .hasMessageMatching("^otherObj is marked .*on.*ull but is null$");
+            .hasMessageMatching("^otherObj is marked non-null but is null$");
 
         assertEquals(0, someKey0.compareTo(someKey0));
         assertNotEquals(0, someKey0.compareTo(new PfConceptKey()));
@@ -178,15 +178,15 @@ class PfKeyImplTest {
         assertThatThrownBy(() -> new MyKey((String) null)).hasMessageMatching(ID_IS_NULL);
 
         assertThatThrownBy(() -> new MyKey((MyKey) null))
-            .hasMessageMatching("^copyConcept is marked .*on.*ull but is null$");
+            .hasMessageMatching("^copyConcept is marked non-null but is null$");
 
-        assertThatThrownBy(() -> new MyKey(null, null)).hasMessageMatching("name is marked .*on.*ull but is null$");
+        assertThatThrownBy(() -> new MyKey(null, null)).hasMessageMatching("name is marked non-null but is null$");
 
         assertThatThrownBy(() -> new MyKey(NAME, null))
-            .hasMessageMatching("^version is marked .*on.*ull but is null$");
+            .hasMessageMatching("^version is marked non-null but is null$");
 
         assertThatThrownBy(() -> new MyKey(null, VERSION001))
-            .hasMessageMatching("^name is marked .*on.*ull but is null$");
+            .hasMessageMatching("^name is marked non-null but is null$");
     }
 
     @Test
index 58474b3..6d0d32a 100644 (file)
@@ -35,7 +35,7 @@ class ToscaNodeTemplateTest {
     void testToscaNodeTemplate() {
         assertThatThrownBy(() -> {
             new ToscaNodeTemplate(null);
-        }).hasMessageMatching("copyObject is marked .*on.*ull but is null");
+        }).hasMessageMatching("copyObject is marked non-null but is null");
 
         assertNotNull(new ToscaNodeTemplate(new ToscaNodeTemplate()));
 
index 123ed93..38f00d1 100644 (file)
@@ -37,7 +37,7 @@ class ToscaPolicyTest {
     void testGetIdentifier_testGetTypeIdentifier() {
         assertThatThrownBy(() -> {
             new ToscaPolicy(null);
-        }).hasMessageMatching("copyObject is marked .*on.*ull but is null");
+        }).hasMessageMatching("copyObject is marked non-null but is null");
 
         ToscaPolicy policy = new ToscaPolicy();
 
index 148cf8a..350725f 100644 (file)
@@ -38,7 +38,7 @@ class ToscaPolicyTypeTest {
     void testToscaPolicyType() {
         assertThatThrownBy(() -> {
             new ToscaPolicyType(null);
-        }).hasMessageMatching("copyObject is marked .*on.*ull but is null");
+        }).hasMessageMatching("copyObject is marked non-null but is null");
 
         ToscaPolicyType tpt = new ToscaPolicyType();
         tpt.setName("AType");
index b11b8a6..c6ca6ea 100644 (file)
@@ -34,7 +34,7 @@ class ToscaServiceTemplateTest {
     void testToscServiceTemplate() {
         assertThatThrownBy(() -> {
             new ToscaServiceTemplate(null);
-        }).hasMessageMatching("copyObject is marked .*on.*ull but is null");
+        }).hasMessageMatching("copyObject is marked non-null but is null");
 
         assertNotNull(new ToscaServiceTemplate(new ToscaServiceTemplate()));
 
index 398dfb1..1909f2e 100644 (file)
@@ -35,7 +35,7 @@ class ToscaTopologyTemplateTest {
     void testToscTopologyTemplate() {
         assertThatThrownBy(() -> {
             new ToscaTopologyTemplate(null);
-        }).hasMessageMatching("copyObject is marked .*on.*ull but is null");
+        }).hasMessageMatching("copyObject is marked non-null but is null");
 
         assertNotNull(new ToscaTopologyTemplate(new ToscaTopologyTemplate()));