Remove Validated class 01/143101/6
authordanielhanrahan <daniel.hanrahan@est.tech>
Tue, 27 Jan 2026 19:54:48 +0000 (19:54 +0000)
committerDaniel Hanrahan <daniel.hanrahan@est.tech>
Tue, 17 Feb 2026 16:04:44 +0000 (16:04 +0000)
This removes the Validated class from policy-models, using
BeanValidator.validate(object) instead object.validate().
It also removes some unused code from validation classes.

Issue-ID: POLICY-5509
Change-Id: Id801e24bc56cfe1b7cbaec3186b43ebbfdb547e1
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
36 files changed:
models/src/main/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidation.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaEntity.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaTopologyTemplate.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElement.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionRollback.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessage.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaMessageJob.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaNodeTemplateState.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantReplica.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java
models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/ProviderUtils.java
models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaServiceTemplateTest.java
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/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/JpaParticipantTest.java
policy-common/src/main/java/org/onap/policy/common/parameters/BeanValidationResult.java
policy-common/src/main/java/org/onap/policy/common/parameters/BeanValidator.java
policy-common/src/main/java/org/onap/policy/common/parameters/ObjectValidationResult.java
policy-common/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java [deleted file]
policy-common/src/main/java/org/onap/policy/common/parameters/ParameterGroupImpl.java
policy-common/src/main/java/org/onap/policy/common/parameters/ValidationResult.java
policy-common/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java
policy-common/src/main/java/org/onap/policy/common/parameters/ValidationStatus.java
policy-common/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java
policy-common/src/test/java/org/onap/policy/common/parameters/TestObjectValidationResult.java
policy-common/src/test/java/org/onap/policy/common/parameters/TestValidationResultImpl.java
policy-models/src/main/java/org/onap/policy/models/base/PfConcept.java
policy-models/src/main/java/org/onap/policy/models/base/Validated.java [deleted file]
policy-models/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConceptIdentifier.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/ToscaConceptIdentifierTest.java

index c13ca94..b1ff46b 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2023,2025 OpenInfra Foundation Europe. All rights reserved.
+ *  Copyright (C) 2022-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplat
 import org.onap.policy.clamp.models.acm.document.concepts.DocToscaTopologyTemplate;
 import org.onap.policy.common.parameters.BeanValidationResult;
 import org.onap.policy.common.parameters.ValidationStatus;
-import org.onap.policy.models.base.Validated;
 
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class ToscaServiceTemplateValidation {
 
     private static final String ROOT_KEY_NAME_SUFFIX = ".Root";
     private static final String TOPOLOGY_TEMPLATE = "TopologyTemplate";
+    private static final String NOT_FOUND = "not found";
 
     /**
      * validate a serviceTemplate.
@@ -153,7 +153,7 @@ public final class ToscaServiceTemplateValidation {
             final Collection<DocConceptKey> dataTypeKeyCollection, Map<String, Set<String>> references) {
         for (DocConceptKey dataTypeKey : dataTypeKeyCollection) {
             if (!isTypePresent(dataTypeKey, references.get(DocUtil.REF_DATA_TYPES))) {
-                result.addResult("data type", dataTypeKey.getId(), ValidationStatus.INVALID, Validated.NOT_FOUND);
+                result.addResult("data type", dataTypeKey.getId(), ValidationStatus.INVALID, NOT_FOUND);
             }
         }
     }
@@ -173,7 +173,7 @@ public final class ToscaServiceTemplateValidation {
             for (var policy : serviceTemplate.getToscaTopologyTemplate().getPolicies().values()) {
                 var key = policy.getTypeDocConceptKey();
                 if (!isTypePresent(key, references.get(DocUtil.REF_POLICY_TYPES))) {
-                    result.addResult("policy type", key, ValidationStatus.INVALID, Validated.NOT_FOUND);
+                    result.addResult("policy type", key, ValidationStatus.INVALID, NOT_FOUND);
                 }
             }
         }
@@ -181,7 +181,7 @@ public final class ToscaServiceTemplateValidation {
             for (var nodeTemplate : serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().values()) {
                 var key = nodeTemplate.getTypeDocConceptKey();
                 if (!isTypePresent(key, references.get(DocUtil.REF_NODE_TYPES))) {
-                    result.addResult("node Template", key, ValidationStatus.INVALID, Validated.NOT_FOUND);
+                    result.addResult("node Template", key, ValidationStatus.INVALID, NOT_FOUND);
                 }
             }
         }
@@ -233,7 +233,7 @@ public final class ToscaServiceTemplateValidation {
                     continue;
                 }
                 if (!isTypePresent(parentEntityTypeKey, reference)) {
-                    result.addResult("parent", parentEntityTypeKey, ValidationStatus.INVALID, Validated.NOT_FOUND);
+                    result.addResult("parent", parentEntityTypeKey, ValidationStatus.INVALID, NOT_FOUND);
                 }
             }
         }
@@ -255,7 +255,7 @@ public final class ToscaServiceTemplateValidation {
                         continue;
                     }
                     if (!isTypePresent(parentEntityTypeKey, reference)) {
-                        result.addResult("parent", parentEntityTypeKey, ValidationStatus.INVALID, Validated.NOT_FOUND);
+                        result.addResult("parent", parentEntityTypeKey, ValidationStatus.INVALID, NOT_FOUND);
                     }
                 }
             }
index 3d6d479..e38f011 100644 (file)
@@ -38,14 +38,13 @@ import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfKey;
 import org.onap.policy.models.base.PfNameVersion;
 import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.base.Validated;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityKey;
 
 @Data
-@EqualsAndHashCode(callSuper = true)
+@EqualsAndHashCode
 @NoArgsConstructor
-public class DocToscaEntity<T extends ToscaEntity> extends Validated
+public class DocToscaEntity<T extends ToscaEntity>
         implements PfNameVersion, PfAuthorative<T>, Serializable, Comparable<DocToscaEntity<T>> {
 
     @Serial
index 0bb586a..bed773d 100644 (file)
@@ -33,13 +33,12 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.onap.policy.clamp.models.acm.document.base.DocUtil;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.base.Validated;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
 
 @Data
 @NoArgsConstructor
-@EqualsAndHashCode(callSuper = true)
-public class DocToscaTopologyTemplate extends Validated
+@EqualsAndHashCode
+public class DocToscaTopologyTemplate
         implements PfAuthorative<ToscaTopologyTemplate>, Serializable, Comparable<DocToscaTopologyTemplate> {
 
     @Serial
index 5006b5a..fa6be7e 100644 (file)
@@ -52,7 +52,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState;
 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.base.Validated;
 
 /**
  * Class to represent an automation composition in the database.
@@ -63,9 +62,9 @@ import org.onap.policy.models.base.Validated;
 @Table(name = "AutomationComposition", indexes = {@Index(name = "ac_compositionId", columnList = "compositionId")})
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
+@EqualsAndHashCode
 @NoArgsConstructor
-public class JpaAutomationComposition extends Validated
+public class JpaAutomationComposition
         implements PfAuthorative<AutomationComposition>, Comparable<JpaAutomationComposition> {
 
     @Id
index 95a96c2..c21c498 100644 (file)
@@ -48,7 +48,6 @@ import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplat
 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfKey;
-import org.onap.policy.models.base.Validated;
 
 /**
  * Class to represent an automation composition definition in the database.
@@ -57,9 +56,8 @@ import org.onap.policy.models.base.Validated;
 @Table(name = "AutomationCompositionDefinition")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaAutomationCompositionDefinition extends Validated
-        implements PfAuthorative<AutomationCompositionDefinition> {
+@EqualsAndHashCode
+public class JpaAutomationCompositionDefinition implements PfAuthorative<AutomationCompositionDefinition> {
 
     @Id
     @NotNull
index e33b0ab..58668b0 100644 (file)
@@ -47,7 +47,6 @@ import org.onap.policy.clamp.models.acm.concepts.SubState;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.base.Validated;
 import org.onap.policy.models.base.validation.annotations.VerifyKey;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -60,8 +59,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 @Table(name = "AutomationCompositionElement")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaAutomationCompositionElement extends Validated
+@EqualsAndHashCode
+public class JpaAutomationCompositionElement
     implements PfAuthorative<AutomationCompositionElement>, Comparable<JpaAutomationCompositionElement> {
 
     @Id
index 64b3ccd..229501c 100644 (file)
@@ -1,6 +1,6 @@
 /*-\r
  * ============LICENSE_START=======================================================\r
- *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.\r
+ *  Copyright (C) 2025-2026 OpenInfra Foundation Europe. All rights reserved.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -42,14 +42,13 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionRollback;\r
 import org.onap.policy.models.base.PfAuthorative;\r
 import org.onap.policy.models.base.PfUtils;\r
-import org.onap.policy.models.base.Validated;\r
 \r
 @Entity\r
 @Table(name = "AutomationCompositionRollback")\r
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)\r
 @Data\r
-@EqualsAndHashCode(callSuper = false)\r
-public class JpaAutomationCompositionRollback extends Validated\r
+@EqualsAndHashCode\r
+public class JpaAutomationCompositionRollback\r
         implements PfAuthorative<AutomationCompositionRollback>, Comparable<JpaAutomationCompositionRollback> {\r
 \r
     @Id\r
index 2696983..86a7c88 100644 (file)
@@ -36,13 +36,12 @@ import lombok.NonNull;
 import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
 import org.onap.policy.models.base.PfAuthorative;
-import org.onap.policy.models.base.Validated;
 
 @Entity
 @Table(name = "Message", indexes = {@Index(name = "m_identificationId", columnList = "identificationId")})
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-public class JpaMessage extends Validated implements PfAuthorative<DocMessage> {
+public class JpaMessage implements PfAuthorative<DocMessage> {
 
     @Id
     @NotNull
index 8acf0b8..a062a36 100644 (file)
@@ -33,14 +33,13 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NonNull;
 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
-import org.onap.policy.models.base.Validated;
 
 @Entity
 @Table(name = "MessageJob")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaMessageJob extends Validated {
+@EqualsAndHashCode
+public class JpaMessageJob {
 
     @Id
     @NotNull
index b92b239..01b7876 100644 (file)
@@ -40,7 +40,6 @@ import org.onap.policy.clamp.models.acm.concepts.NodeTemplateState;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.base.Validated;
 import org.onap.policy.models.base.validation.annotations.VerifyKey;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -48,8 +47,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 @Table(name = "NodeTemplateState")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaNodeTemplateState extends Validated implements PfAuthorative<NodeTemplateState> {
+@EqualsAndHashCode
+public class JpaNodeTemplateState implements PfAuthorative<NodeTemplateState> {
 
     @Id
     @NotNull
index 9d67fbb..87afa17 100644 (file)
@@ -33,8 +33,6 @@ import jakarta.persistence.OneToMany;
 import jakarta.persistence.Table;
 import jakarta.validation.Valid;
 import jakarta.validation.constraints.NotNull;
-import java.io.Serial;
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -45,7 +43,6 @@ import lombok.NonNull;
 import org.apache.commons.lang3.ObjectUtils;
 import org.onap.policy.clamp.models.acm.concepts.Participant;
 import org.onap.policy.models.base.PfAuthorative;
-import org.onap.policy.models.base.Validated;
 
 /**
  * Class to represent a participant in the database.
@@ -56,12 +53,8 @@ import org.onap.policy.models.base.Validated;
 @Table(name = "Participant")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaParticipant extends Validated
-        implements PfAuthorative<Participant>, Comparable<JpaParticipant>, Serializable {
-
-    @Serial
-    private static final long serialVersionUID = -4697758484642403483L;
+@EqualsAndHashCode
+public class JpaParticipant implements PfAuthorative<Participant>, Comparable<JpaParticipant> {
 
     @Id
     @NotNull
index 0218422..e203799 100644 (file)
@@ -36,14 +36,13 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantReplica;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
 import org.onap.policy.models.base.PfAuthorative;
-import org.onap.policy.models.base.Validated;
 
 @Entity
 @Table(name = "ParticipantReplica")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaParticipantReplica extends Validated implements PfAuthorative<ParticipantReplica> {
+@EqualsAndHashCode
+public class JpaParticipantReplica implements PfAuthorative<ParticipantReplica> {
 
     @Id
     @NotNull
index 6ac71ab..75dc9bc 100644 (file)
@@ -34,14 +34,13 @@ import lombok.NonNull;
 import org.apache.commons.lang3.ObjectUtils;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
 import org.onap.policy.models.base.PfAuthorative;
-import org.onap.policy.models.base.Validated;
 
 @Entity
 @Table(name = "ParticipantSupportedAcElements")
 @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 @Data
-@EqualsAndHashCode(callSuper = false)
-public class JpaParticipantSupportedElementType extends Validated
+@EqualsAndHashCode
+public class JpaParticipantSupportedElementType
     implements PfAuthorative<ParticipantSupportedElementType>, Comparable<JpaParticipantSupportedElementType> {
 
     @NotNull
index 6feb2b7..d7c6061 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2023 Nordix Foundation.
+ *  Copyright (C) 2021-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,9 +27,9 @@ import java.util.function.Supplier;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.onap.policy.common.parameters.BeanValidationResult;
+import org.onap.policy.common.parameters.BeanValidator;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.base.Validated;
 
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class ProviderUtils {
@@ -42,7 +42,7 @@ public final class ProviderUtils {
      * @param conceptDescription the description used for validation result
      * @return the list of Jpa objects
      */
-    public static <A, J extends Validated & PfAuthorative<A>> List<J> getJpaAndValidateList(
+    public static <A, J extends PfAuthorative<A>> List<J> getJpaAndValidateList(
             List<A> authorativeConceptList, Supplier<J> jpaSupplier, String conceptDescription) {
         var validationResult = new BeanValidationResult(conceptDescription + " List", authorativeConceptList);
 
@@ -53,7 +53,7 @@ public final class ProviderUtils {
             jpaConcept.fromAuthorative(authorativeConcept);
             jpaConceptList.add(jpaConcept);
 
-            validationResult.addResult(jpaConcept.validate(conceptDescription));
+            validationResult.addResult(BeanValidator.validate(conceptDescription, jpaConcept));
         }
 
         if (!validationResult.isValid()) {
@@ -70,7 +70,7 @@ public final class ProviderUtils {
      * @param conceptDescription the description used for validation result
      * @return the Jpa object
      */
-    public static <A, J extends Validated & PfAuthorative<A>> J getJpaAndValidate(A authorativeConcept,
+    public static <A, J extends PfAuthorative<A>> J getJpaAndValidate(A authorativeConcept,
             Supplier<J> jpaSupplier, String conceptDescription) {
         var jpaConcept = jpaSupplier.get();
         jpaConcept.fromAuthorative(authorativeConcept);
@@ -85,11 +85,11 @@ public final class ProviderUtils {
      * @param jpaConcept  the Jpa of the concept
      * @param conceptDescription the description used for validation result
      */
-    public static <A, J extends Validated & PfAuthorative<A>> void validate(A authorativeConcept,
+    public static <A, J extends PfAuthorative<A>> void validate(A authorativeConcept,
             J jpaConcept, String conceptDescription) {
         var validationResult = new BeanValidationResult(conceptDescription, authorativeConcept);
 
-        validationResult.addResult(jpaConcept.validate(conceptDescription));
+        validationResult.addResult(BeanValidator.validate(conceptDescription, jpaConcept));
 
         if (!validationResult.isValid()) {
             throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
index c234e0a..6abd535 100644 (file)
@@ -95,7 +95,6 @@ class DocToscaServiceTemplateTest {
         doc2.setPolicyTypes(doc.getPolicyTypes());
         assertThat(doc).isEqualByComparingTo(doc2);
         assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
-        assertThat(doc.validate("serviceTemplate")).isNotNull();
 
         serviceTemplate.setName(NAME);
         serviceTemplate.setVersion("1.1.1");
@@ -232,9 +231,6 @@ class DocToscaServiceTemplateTest {
 
     @Test
     void testNullPointer() {
-        var docCapabilityType = new DocToscaCapabilityType();
-        assertThatThrownBy(() -> docCapabilityType.validate(null)).   isInstanceOf(NullPointerException.class);
-
         var docConceptKey = new DocConceptKey();
         assertThatThrownBy(() -> docConceptKey.setName(null)).   isInstanceOf(NullPointerException.class);
         assertThatThrownBy(() -> docConceptKey.setVersion(null)).   isInstanceOf(NullPointerException.class);
index d25dd45..a9b69f8 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2021-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import org.onap.policy.clamp.models.acm.concepts.LockState;
 import org.onap.policy.clamp.models.acm.concepts.MigrationState;
 import org.onap.policy.clamp.models.acm.concepts.SubState;
 import org.onap.policy.clamp.models.acm.utils.CommonTestData;
+import org.onap.policy.common.parameters.BeanValidator;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -110,11 +111,7 @@ class JpaAutomationCompositionElementTest {
     @Test
     void testJpaAutomationCompositionElementValidation() {
         var testJpaAutomationCompositionElement = createJpaAutomationCompositionElementInstance();
-
-        assertThatThrownBy(() -> testJpaAutomationCompositionElement.validate(null))
-                .hasMessageMatching("fieldName" + NULL_ERROR);
-
-        assertTrue(testJpaAutomationCompositionElement.validate("").isValid());
+        assertTrue(BeanValidator.isValid(testJpaAutomationCompositionElement));
     }
 
     @Test
index e310494..8a386c8 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
+ * Copyright (C) 2021-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import org.onap.policy.clamp.models.acm.concepts.LockState;
 import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
 import org.onap.policy.clamp.models.acm.concepts.SubState;
 import org.onap.policy.clamp.models.acm.utils.TimestampHelper;
+import org.onap.policy.common.parameters.BeanValidator;
 
 /**
  * Test the{@link JpaAutomationCompositionTest} class.
@@ -93,11 +94,7 @@ class JpaAutomationCompositionTest {
     @Test
     void testJpaAutomationCompositionValidation() {
         var testJpaAutomationComposition = new JpaAutomationComposition(createAutomationCompositionInstance());
-
-        assertThatThrownBy(() -> testJpaAutomationComposition.validate(null))
-                .hasMessageMatching("fieldName is marked non-null but is null");
-
-        assertTrue(testJpaAutomationComposition.validate("").isValid());
+        assertTrue(BeanValidator.isValid(testJpaAutomationComposition));
     }
 
     @Test
index c8bc561..e174075 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2025 Nordix Foundation.
+ * Copyright (C) 2025-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
-
+import org.onap.policy.common.parameters.BeanValidator;
 
 class JpaMessageJobTest {
 
@@ -39,12 +39,9 @@ class JpaMessageJobTest {
     void testJpaMessageValidation() {
         var jpaMessageJob = new JpaMessageJob();
 
-        assertThatThrownBy(() -> jpaMessageJob.validate(null))
-                .hasMessageMatching("fieldName is marked non-null but is null");
-
-        assertTrue(jpaMessageJob.validate("").isValid());
+        assertTrue(BeanValidator.isValid(jpaMessageJob));
 
         jpaMessageJob.setJobStarted(null);
-        assertFalse(jpaMessageJob.validate("").isValid());
+        assertFalse(BeanValidator.isValid(jpaMessageJob));
     }
 }
index 0e091ec..dfc76bc 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2025 Nordix Foundation.
+ * Copyright (C) 2025-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.DeployState;
 import org.onap.policy.clamp.models.acm.document.concepts.DocMessage;
 import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageType;
+import org.onap.policy.common.parameters.BeanValidator;
 
 class JpaMessageTest {
 
@@ -46,13 +47,10 @@ class JpaMessageTest {
         var docMessage = createDocMessage();
         var jpaMessage = new JpaMessage(docMessage.getInstanceId().toString(), docMessage);
 
-        assertThatThrownBy(() -> jpaMessage.validate(null))
-                .hasMessageMatching("fieldName is marked non-null but is null");
-
-        assertTrue(jpaMessage.validate("").isValid());
+        assertTrue(BeanValidator.isValid(jpaMessage));
 
         jpaMessage.setLastMsg(null);
-        assertFalse(jpaMessage.validate("").isValid());
+        assertFalse(BeanValidator.isValid(jpaMessage));
     }
 
     @Test
index 4c2ac0e..7ef721e 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
+ *  Copyright (C) 2021-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import java.util.LinkedHashMap;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.common.parameters.BeanValidator;
 
 /**
  * Test the {@link JpaParticipant} class.
@@ -86,11 +87,7 @@ class JpaParticipantTest {
     @Test
     void testJpaParticipantValidation() {
         var testJpaParticipant = new JpaParticipant(createParticipantInstance());
-
-        assertThatThrownBy(() -> testJpaParticipant.validate(null))
-            .hasMessageMatching("fieldName is marked non-null but is null");
-
-        assertTrue(testJpaParticipant.validate("").isValid());
+        assertTrue(BeanValidator.isValid(testJpaParticipant));
     }
 
     @Test
index e162053..cc27fd1 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 package org.onap.policy.common.parameters;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
 
 /**
  * This class holds the result of the validation of an arbitrary bean.
@@ -80,109 +76,16 @@ public class BeanValidationResult extends ValidationResultImpl {
         return addResult(new ObjectValidationResult(name, object, status, message));
     }
 
-    /**
-     * Validates that a sub-object within the bean is not {@code null}.
-     *
-     * @param subName name of the sub-object
-     * @param subObject the sub-object
-     * @return {@code true} if the value is not null, {@code false} otherwise
-     */
-    public boolean validateNotNull(String subName, Object subObject) {
-        var result = new ObjectValidationResult(subName, subObject);
-
-        if (result.validateNotNull()) {
-            return true;
-
-        } else {
-            addResult(result);
-            return false;
-        }
-    }
-
-    /**
-     * Validates the items in a list, after validating that the list, itself, is not null.
-     *
-     * @param listName name of the list
-     * @param list list whose items are to be validated, or {@code null}
-     * @param itemValidator function to validate an item in the list
-     * @return {@code true} if all items in the list are valid, {@code false} otherwise
-     */
-    public <T> boolean validateNotNullList(String listName, Collection<T> list,
-                    Function<T, ValidationResult> itemValidator) {
-
-        return validateNotNull(listName, list) && validateList(listName, list, itemValidator);
-    }
-
-    /**
-     * Validates the items in a list.
-     *
-     * @param listName name of the list
-     * @param list list whose items are to be validated, or {@code null}
-     * @param itemValidator function to validate an item in the list
-     * @return {@code true} if all items in the list are valid, {@code false} otherwise
-     */
-    public <T> boolean validateList(String listName, Collection<T> list, Function<T, ValidationResult> itemValidator) {
-        if (list == null) {
-            return true;
-        }
-
-        var result = new BeanValidationResult(listName, null);
-        for (T item : list) {
-            if (item == null) {
-                result.addResult("item", item, ValidationStatus.INVALID, "null");
-            } else {
-                result.addResult(itemValidator.apply(item));
-            }
-        }
-
-        if (result.isValid()) {
-            return true;
-
-        } else {
-            addResult(result);
-            return false;
-        }
-    }
-
-    /**
-     * Validates the entries in a map.
-     *
-     * @param mapName name of the list
-     * @param map map whose entries are to be validated, or {@code null}
-     * @param entryValidator function to validate an entry in the map
-     * @return {@code true} if all entries in the map are valid, {@code false} otherwise
-     */
-    public <V> boolean validateMap(String mapName, Map<String, V> map,
-                    BiConsumer<BeanValidationResult, Entry<String, V>> entryValidator) {
-        if (map == null) {
-            return true;
-        }
-
-        var result = new BeanValidationResult(mapName, null);
-        for (Entry<String, V> ent : map.entrySet()) {
-            entryValidator.accept(result, ent);
-        }
-
-        if (result.isValid()) {
-            return true;
-
-        } else {
-            addResult(result);
-            return false;
-        }
-    }
-
     /**
      * Gets the validation result.
      *
      * @param initialIndentation the indentation to use on the main result output
      * @param subIndentation the indentation to use on sub parts of the result output
-     * @param showClean output information on clean fields
      * @return the result
      */
     @Override
-    public String getResult(final String initialIndentation, final String subIndentation, final boolean showClean) {
-        if (!showClean && getStatus() == ValidationStatus.CLEAN) {
+    public String getResult(final String initialIndentation, final String subIndentation) {
+        if (getStatus() == ValidationStatus.CLEAN) {
             return null;
         }
 
@@ -199,7 +102,7 @@ public class BeanValidationResult extends ValidationResultImpl {
         builder.append('\n');
 
         for (ValidationResult itemResult : itemResults) {
-            String message = itemResult.getResult(initialIndentation + subIndentation, subIndentation, showClean);
+            String message = itemResult.getResult(initialIndentation + subIndentation, subIndentation);
             if (message != null) {
                 builder.append(message);
             }
index c3ed5f5..95acfd2 100644 (file)
@@ -52,4 +52,26 @@ public class BeanValidator {
         }
         return result;
     }
+
+    /**
+     * Validates the given bean.
+     *
+     * @param <T>  the type of the bean
+     * @param bean the bean to validate
+     * @return the validation result
+     */
+    public static <T> BeanValidationResult validate(final T bean) {
+        return validate(bean.getClass().getSimpleName(), bean);
+    }
+
+    /**
+     * Validates the given bean.
+     *
+     * @param <T>  the type of the bean
+     * @param bean the bean to validate
+     * @return true if the bean is valid
+     */
+    public static <T> boolean isValid(final T bean) {
+        return validate(bean).isValid();
+    }
 }
index af1884a..50a42b9 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,12 +53,11 @@ public class ObjectValidationResult extends ValidationResultImpl {
      *
      * @param initialIndentation the result indentation
      * @param subIndentation the indentation to use on sub parts of the result output
-     * @param showClean output information on clean fields
      * @return the result
      */
     @Override
-    public String getResult(final String initialIndentation, final String subIndentation, final boolean showClean) {
-        if (!showClean && getStatus() == ValidationStatus.CLEAN) {
+    public String getResult(final String initialIndentation, final String subIndentation) {
+        if (getStatus() == ValidationStatus.CLEAN) {
             return null;
         }
 
diff --git a/policy-common/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java b/policy-common/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java
deleted file mode 100644 (file)
index ea31ea3..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.common.parameters;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * This static class holds the values of constants for parameter handling.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ParameterConstants {
-    // Indentation is 0 on the left and 2 for each level of hierarchy
-    public static final String DEFAULT_INITIAL_RESULT_INDENTATION = "";
-    public static final String DEFAULT_RESULT_INDENTATION = "  ";
-
-    // By default we do not show validation results for parameters that are validated as clean
-    public static final boolean DO_NOT_SHOW_CLEAN_RESULTS = false;
-}
index 3faf5fe..7fc0e5c 100644 (file)
@@ -43,6 +43,6 @@ public class ParameterGroupImpl implements ParameterGroup {
 
     @Override
     public BeanValidationResult validate() {
-        return BeanValidator.validate(getClass().getSimpleName(), this);
+        return BeanValidator.validate(this);
     }
 }
index e601741..d0bb692 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation.
+ *  Modifications Copyright (C) 2024-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,10 @@ package org.onap.policy.common.parameters;
  * This interface defines the result of a parameter validation.
  */
 public interface ValidationResult {
+    // Indentation is 0 on the left and 2 for each level of hierarchy
+    String DEFAULT_INITIAL_RESULT_INDENTATION = "";
+    String DEFAULT_RESULT_INDENTATION = "  ";
+
     /**
      * Gets the name of the entity being validated.
      *
@@ -63,10 +67,7 @@ public interface ValidationResult {
      * @return the full validation result
      */
     default String getResult() {
-        return getResult(
-            ParameterConstants.DEFAULT_INITIAL_RESULT_INDENTATION,
-            ParameterConstants.DEFAULT_RESULT_INDENTATION,
-            ParameterConstants.DO_NOT_SHOW_CLEAN_RESULTS);
+        return getResult(DEFAULT_INITIAL_RESULT_INDENTATION, DEFAULT_RESULT_INDENTATION);
     }
 
     /**
@@ -74,10 +75,9 @@ public interface ValidationResult {
      *
      * @param initialIndentation the indentation to use on the main result output
      * @param subIndentation     the indentation to use on sub parts of the result output
-     * @param showClean          output information on clean fields
      * @return the result
      */
-    String getResult(final String initialIndentation, final String subIndentation, final boolean showClean);
+    String getResult(final String initialIndentation, final String subIndentation);
 
     /**
      * Set a validation result.
@@ -86,4 +86,4 @@ public interface ValidationResult {
      * @param message The validation message explaining the validation status
      */
     void setResult(final ValidationStatus status, final String message);
-}
\ No newline at end of file
+}
index 4589881..b223dfc 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,7 +51,7 @@ public abstract class ValidationResultImpl implements ValidationResult {
     /**
      * Validation message.
      */
-    private String message = ITEM_HAS_STATUS_MESSAGE + status.toString();
+    private String message = ITEM_HAS_STATUS_MESSAGE + status;
 
 
     /**
@@ -64,21 +65,6 @@ public abstract class ValidationResultImpl implements ValidationResult {
         this.object = object;
     }
 
-    /**
-     * Validates that the value is not {@code null}.
-     *
-     * @return {@code true} if the value is not null, {@code false} otherwise
-     */
-    public boolean validateNotNull() {
-        if (object == null) {
-            setResult(ValidationStatus.INVALID, "is null");
-            return false;
-
-        } else {
-            return true;
-        }
-    }
-
     /**
      * Set the validation result status. On a sequence of calls, the most serious
      * validation status is recorded, assuming the status enum ordinals increase in order
index 8692506..a34de41 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
+ *  Modifications Copyright (C) 2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,10 +23,8 @@ package org.onap.policy.common.parameters;
 
 public enum ValidationStatus {
     CLEAN,
-    OBSERVATION,
-    WARNING,
     INVALID;
-    
+
     /**
      * The result of a validation is valid unless the status is INVALID.
      * @return true if the validation has passed
@@ -33,7 +32,7 @@ public enum ValidationStatus {
     public boolean isValid() {
         return !this.equals(INVALID);
     }
-    
+
     /**
      * Check if the validation was clean.
      * @return true if the validation is clean
index ab733ae..19b3c1a 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,12 +27,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-import java.util.function.BiConsumer;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -40,17 +34,13 @@ class TestBeanValidationResult {
     private static final String TEXT1 = "abc";
     private static final String TEXT2 = "def";
     private static final String MY_LIST = "my-list";
-    private static final String MY_MAP = "my-map";
     private static final String OBJECT = "an object";
     private static final String INITIAL_INDENT = "xx ";
     private static final String NEXT_INDENT = "yy ";
     private static final String MID_INDENT = "xx yy ";
     private static final String NAME = "my-name";
-    private static final String MY_LIST_INVALID = "  'my-list' INVALID, item has status INVALID\n    ";
-    private static final String MY_MAP_INVALID = "  'my-map' INVALID, item has status INVALID\n    ";
-    private static final String BEAN_INVALID_MSG = requote("'my-name' INVALID, item has status INVALID\n");
+    private static final String BEAN_INVALID_MSG = "\"my-name\" INVALID, item has status INVALID\n";
 
-    private String cleanMsg;
     private String invalidMsg;
 
     private BeanValidationResult bean;
@@ -63,7 +53,6 @@ class TestBeanValidationResult {
     @BeforeEach
     void setUp() {
         clean = new ObjectValidationResult(TEXT1, 10);
-        cleanMsg = clean.getResult("", "", true);
 
         invalid = new ObjectValidationResult(TEXT2, 20);
         invalid.setResult(ValidationStatus.INVALID, "invalid");
@@ -91,124 +80,11 @@ class TestBeanValidationResult {
         assertFalse(bean.isValid());
         assertEquals(BEAN_INVALID_MSG + "  " + invalidMsg, bean.getResult());
 
-        assertEquals(INITIAL_INDENT + BEAN_INVALID_MSG + MID_INDENT + cleanMsg + MID_INDENT + invalidMsg,
-                        bean.getResult(INITIAL_INDENT, NEXT_INDENT, true));
+        assertEquals(INITIAL_INDENT + BEAN_INVALID_MSG + MID_INDENT + invalidMsg,
+                        bean.getResult(INITIAL_INDENT, NEXT_INDENT));
 
         bean = new BeanValidationResult(NAME, OBJECT);
         assertFalse(bean.addResult(MY_LIST, "hello", ValidationStatus.INVALID, TEXT1));
         assertThat(bean.getResult()).contains("\"" + MY_LIST + "\" value \"hello\" INVALID, " + TEXT1);
     }
-
-    @Test
-    void testValidateNotNull() {
-        assertTrue(bean.validateNotNull("sub-name", "sub-object"));
-        assertTrue(bean.isValid());
-        assertNull(bean.getResult());
-
-        assertFalse(bean.validateNotNull("sub-name", null));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + "  item 'sub-name' value 'null' INVALID, is null\n"), bean.getResult());
-    }
-
-    @Test
-    void testValidateNotNullList() {
-        List<ValidationResult> list = List.of(clean);
-        assertTrue(bean.validateNotNullList(MY_LIST, list, item -> item));
-        assertTrue(bean.isValid());
-        assertNull(bean.getResult());
-
-        list = Arrays.asList(invalid, invalid);
-        assertFalse(bean.validateNotNullList(MY_LIST, list, item -> item));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + MY_LIST_INVALID + invalidMsg
-                        + "    " + invalidMsg), bean.getResult());
-    }
-
-    @Test
-    void testValidateNotNullList_NullList() {
-        List<ValidationResult> list = null;
-        assertFalse(bean.validateNotNullList(MY_LIST, list, item -> item));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + "  item 'my-list' value 'null' INVALID, is null\n"), bean.getResult());
-
-    }
-
-    @Test
-    void testValidateList() {
-        List<ValidationResult> list = null;
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertTrue(bean.validateList(MY_LIST, list, item -> item));
-        assertTrue(bean.isValid());
-        assertNull(bean.getResult());
-
-        list = List.of(clean);
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertTrue(bean.validateList(MY_LIST, list, item -> item));
-        assertTrue(bean.isValid());
-        assertNull(bean.getResult());
-
-        // null item in the list
-        list = Arrays.asList(clean, null);
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertFalse(bean.validateList(MY_LIST, list, item -> item));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + MY_LIST_INVALID
-                        + "item 'item' value 'null' INVALID, null\n"), bean.getResult());
-
-        list = Arrays.asList(invalid, invalid);
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertFalse(bean.validateList(MY_LIST, list, item -> item));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + MY_LIST_INVALID + invalidMsg
-                        + "    " + invalidMsg), bean.getResult());
-
-    }
-
-    @Test
-    void testValidateMap() {
-        Map<String, ValidationResult> map = null;
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertTrue(bean.validateMap(MY_MAP, map, validMapEntry()));
-        assertTrue(bean.isValid());
-        assertNull(bean.getResult());
-
-        map = Map.of(TEXT1, clean, TEXT2, clean);
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertTrue(bean.validateMap(MY_MAP, map, validMapEntry()));
-        assertTrue(bean.isValid());
-        assertNull(bean.getResult());
-
-        // null value in the map
-        map = new TreeMap<>();
-        map.put(TEXT1, clean);
-        map.put(TEXT2, null);
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertFalse(bean.validateMap(MY_MAP, map, validMapEntry()));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + MY_MAP_INVALID
-                        + "item 'def' value 'null' INVALID, is null\n"), bean.getResult());
-
-        map = Map.of(TEXT1, invalid, TEXT2, invalid);
-        bean = new BeanValidationResult(NAME, OBJECT);
-        assertFalse(bean.validateMap(MY_MAP, map, validMapEntry()));
-        assertFalse(bean.isValid());
-        assertEquals(requote(BEAN_INVALID_MSG + MY_MAP_INVALID + invalidMsg
-                        + "    " + invalidMsg), bean.getResult());
-
-    }
-
-    private BiConsumer<BeanValidationResult, Entry<String, ValidationResult>> validMapEntry() {
-        return (result, entry) -> {
-            var value = entry.getValue();
-            if (value == null) {
-                result.validateNotNull(entry.getKey(), value);
-            } else {
-                result.addResult(value);
-            }
-        };
-    }
-
-    private static String requote(String text) {
-        return text.replace('\'', '"');
-    }
 }
index c72d4f4..fee1b73 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ package org.onap.policy.common.parameters;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
 
@@ -48,27 +47,11 @@ class TestObjectValidationResult {
         result = new ObjectValidationResult(NAME, OBJECT);
         assertEquals(ValidationStatus.CLEAN, result.getStatus());
         assertNull(result.getResult());
-        assertEquals(requote("xxx item 'my-name' value 'my-object' CLEAN, item has status CLEAN\n"),
-                        result.getResult("xxx ", "yyy", true));
-
-        result.setResult(ValidationStatus.WARNING, "a warning");
-        assertEquals(ValidationStatus.WARNING, result.getStatus());
-
-        // should not override warning
-        result.setResult(ValidationStatus.OBSERVATION, "an observation");
-        assertEquals(ValidationStatus.WARNING, result.getStatus());
-
-        assertTrue(result.isValid());
-        assertEquals(requote("item 'my-name' value 'my-object' WARNING, a warning\n"), result.getResult());
 
         result.setResult(ValidationStatus.INVALID, "is invalid");
         assertEquals(ValidationStatus.INVALID, result.getStatus());
 
         assertFalse(result.isValid());
-        assertEquals(requote("item 'my-name' value 'my-object' INVALID, is invalid\n"), result.getResult());
-    }
-
-    private String requote(String text) {
-        return text.replace('\'', '"');
+        assertEquals("item \"my-name\" value \"my-object\" INVALID, is invalid\n", result.getResult());
     }
 }
index f6851b5..1b8f4f0 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,8 +23,6 @@ package org.onap.policy.common.parameters;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -49,46 +47,9 @@ class TestValidationResultImpl {
         assertEquals("invalid data", result.getMessage());
     }
 
-    @Test
-    void testValidateNotNull() {
-        assertTrue(result.validateNotNull());
-        assertTrue(result.isValid());
-        assertNull(result.getResult());
-
-        // now try with null
-        result = new MyResult(NAME, null);
-        assertFalse(result.validateNotNull());
-        assertFalse(result.isValid());
-        assertEquals("INVALID is null", result.getResult());
-    }
-
-    @Test
-    void testSetResultValidationStatus() {
-        result.setResult(ValidationStatus.WARNING);
-        assertEquals(ValidationStatus.WARNING, result.getStatus());
-
-        // should not override warning
-        result.setResult(ValidationStatus.OBSERVATION);
-        assertEquals(ValidationStatus.WARNING, result.getStatus());
-
-        assertTrue(result.isValid());
-        assertEquals("WARNING item has status WARNING", result.getResult());
-    }
-
     @Test
     void testSetResult_testGetResult_testGetStatus() {
         assertEquals(ValidationStatus.CLEAN, result.getStatus());
-        assertEquals("CLEAN item has status CLEAN", result.getResult("xxx ", "yyy", true));
-
-        result.setResult(ValidationStatus.WARNING, "a warning");
-        assertEquals(ValidationStatus.WARNING, result.getStatus());
-
-        // should not override warning
-        result.setResult(ValidationStatus.OBSERVATION, "an observation");
-        assertEquals(ValidationStatus.WARNING, result.getStatus());
-
-        assertTrue(result.isValid());
-        assertEquals("WARNING a warning", result.getResult());
 
         result.setResult(ValidationStatus.INVALID, "is invalid");
         assertEquals(ValidationStatus.INVALID, result.getStatus());
@@ -112,8 +73,8 @@ class TestValidationResultImpl {
         }
 
         @Override
-        public String getResult(String initialIndentation, String subIndentation, boolean showClean) {
-            if (!showClean && getStatus() == ValidationStatus.CLEAN) {
+        public String getResult(String initialIndentation, String subIndentation) {
+            if (getStatus() == ValidationStatus.CLEAN) {
                 return null;
             }
 
index c8be88d..ae8983b 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019, 2023 Nordix Foundation.
+ *  Copyright (C) 2019-2026 OpenInfra Foundation Europe. All rights reserved.
  *  Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +34,7 @@ import lombok.NonNull;
  */
 
 @NoArgsConstructor(access = AccessLevel.PROTECTED)
-public abstract class PfConcept extends Validated implements Serializable, Comparable<PfConcept> {
+public abstract class PfConcept implements Serializable, Comparable<PfConcept> {
     @Serial
     private static final long serialVersionUID = -7434939557282697490L;
 
diff --git a/policy-models/src/main/java/org/onap/policy/models/base/Validated.java b/policy-models/src/main/java/org/onap/policy/models/base/Validated.java
deleted file mode 100644 (file)
index daade23..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- *  Modifications Copyright (C) 2024-2026 OpenInfra Foundation Europe. All rights reserved.
- * ================================================================================
- * Licensed 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.base;
-
-import lombok.NonNull;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.BeanValidator;
-
-/**
- * Classes that can be validated. This can be used as a super class or as a stand-alone
- * utility class.
- */
-public class Validated {
-    public static final String NOT_FOUND = "not found";
-
-    /**
-     * Validates the fields of the object. The default method uses a {@link BeanValidator}
-     * to validate the object.
-     *
-     * @param fieldName name of the field containing this
-     * @return the result, or {@code null}
-     */
-    public final BeanValidationResult validate(@NonNull String fieldName) {
-        return BeanValidator.validate(fieldName, this);
-    }
-}
index a243414..c07191c 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy Models
  * ================================================================================
  * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,8 +25,6 @@ import java.io.Serializable;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import lombok.NonNull;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ValidationResult;
 import org.onap.policy.models.base.PfKey;
 
 /**
@@ -38,7 +36,6 @@ public class ToscaConceptIdentifier extends ToscaNameVersion
                 implements Serializable, Comparable<ToscaConceptIdentifier> {
     private static final long serialVersionUID = 8010649773816325786L;
 
-
     public ToscaConceptIdentifier(@NonNull String name, @NonNull String version) {
         super(name, version);
     }
@@ -51,20 +48,6 @@ public class ToscaConceptIdentifier extends ToscaNameVersion
         super(source);
     }
 
-    /**
-     * Validates that appropriate fields are populated for an incoming call to the PAP REST API.
-     *
-     * @return the validation result
-     */
-    public ValidationResult validatePapRest() {
-        var result = new BeanValidationResult("identifier", this);
-
-        result.validateNotNull("name", getName());
-        result.validateNotNull("version", getVersion());
-
-        return result;
-    }
-
     @Override
     public int compareTo(ToscaConceptIdentifier other) {
         return commonCompareTo(other);
index ceb58c7..f0b5bfc 100644 (file)
@@ -21,7 +21,6 @@
 
 package org.onap.policy.models.base;
 
-import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -30,16 +29,12 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import jakarta.validation.constraints.Pattern;
-import java.lang.reflect.Field;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
-import org.onap.policy.common.parameters.BeanValidator;
-import org.onap.policy.common.parameters.ValidationResult;
 import org.onap.policy.models.base.PfKey.Compatibility;
 
 class PfKeyImplTest {
@@ -138,21 +133,6 @@ class PfKeyImplTest {
         assertEquals(Compatibility.MAJOR, buildKey3.getCompatibility(someKey1));
     }
 
-    @Test
-    void testValidityConceptKey() {
-        assertTrue(someKey0.validate("").isValid());
-        assertTrue(someKey1.validate("").isValid());
-        assertTrue(someKey2.validate("").isValid());
-        assertTrue(someKey3.validate("").isValid());
-        assertTrue(someKey4.validate("").isValid());
-        assertTrue(someKey5.validate("").isValid());
-        assertTrue(someKey6.validate("").isValid());
-        assertTrue(buildKey1.validate("").isValid());
-        assertTrue(buildKey2.validate("").isValid());
-        assertTrue(buildKey3.validate("").isValid());
-        assertTrue(buildKey4.validate("").isValid());
-    }
-
     @Test
     void testCleanConceptKey() {
         someKey0.clean();
@@ -190,41 +170,14 @@ class PfKeyImplTest {
             .hasMessageMatching("^name is marked non-null but is null$");
     }
 
-    @Test
-    void testValidation() throws Exception {
-        MyKey testKey = new MyKey("TheKey", VERSION001);
-        assertEquals("TheKey:0.0.1", testKey.getId());
-
-        Field nameField = testKey.getClass().getDeclaredField(NAME);
-        nameField.setAccessible(true);
-        nameField.set(testKey, "Key Name");
-        ValidationResult validationResult = testKey.validate("");
-        nameField.set(testKey, "TheKey");
-        nameField.setAccessible(false);
-        assertThat(validationResult.getResult()).contains("\"name\"").doesNotContain("\"version\"")
-            .contains("must match \"" + PfKey.NAME_REGEXP + "\"");
-
-        Field versionField = testKey.getClass().getDeclaredField("version");
-        versionField.setAccessible(true);
-        versionField.set(testKey, "Key Version");
-        ValidationResult validationResult2 = testKey.validate("");
-        versionField.set(testKey, VERSION001);
-        versionField.setAccessible(false);
-        assertThat(validationResult2.getResult()).doesNotContain("\"name\"").contains("\"version\"")
-                .contains("must match \"" + PfKey.VERSION_REGEXP + "\"");
-    }
-
     @Getter
     @Setter
     @EqualsAndHashCode(callSuper = false)
     @NoArgsConstructor
-    public static class MyKey extends PfKeyImpl {
+    private static class MyKey extends PfKeyImpl {
         private static final long serialVersionUID = 1L;
 
-        @Pattern(regexp = NAME_REGEXP)
         private String name;
-
-        @Pattern(regexp = VERSION_REGEXP)
         private String version;
 
         public MyKey(String name, String version) {
index 17fbeef..c3e1475 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy Models
  * ================================================================================
  * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021, 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2026 OpenInfra Foundation Europe. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,13 +23,8 @@ package org.onap.policy.models.tosca.authorative.concepts;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
-import org.onap.policy.common.parameters.ValidationResult;
 import org.onap.policy.models.base.PfConceptKey;
 
 /**
@@ -79,27 +74,6 @@ class ToscaConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaConceptIde
         assertEquals(origKey, new ToscaConceptIdentifier(origKey).asConceptKey());
     }
 
-    @Test
-    void testValidatePapRest() throws Exception {
-        ToscaConceptIdentifier ident = new ToscaConceptIdentifier(NAME, VERSION);
-        ValidationResult result = ident.validatePapRest();
-        assertNotNull(result);
-        assertTrue(result.isValid());
-        assertNull(result.getResult());
-
-        ident = makeIdent(NAME, null);
-        result = ident.validatePapRest();
-        assertNotNull(result);
-        assertFalse(result.isValid());
-        assertNotNull(result.getResult());
-
-        ident = makeIdent(null, VERSION);
-        result = ident.validatePapRest();
-        assertNotNull(result);
-        assertFalse(result.isValid());
-        assertNotNull(result.getResult());
-    }
-
     @Test
     @Override
     void testCompareTo() throws Exception {