Add Unit tests for code coverage in ACM 67/142467/1
authorFrancescoFioraEst <francesco.fiora@est.tech>
Tue, 18 Nov 2025 11:21:14 +0000 (11:21 +0000)
committerFrancesco Fiora <francesco.fiora@est.tech>
Fri, 21 Nov 2025 10:23:48 +0000 (10:23 +0000)
Issue-ID: POLICY-5403
Change-Id: I99e8197ace28c781fcfc10afabde516d8cf97442
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
21 files changed:
models/src/main/java/org/onap/policy/clamp/models/acm/document/base/DocConceptKey.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/base/DocUtil.java
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/DocToscaCapabilityAssignment.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaDataType.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaNodeTemplate.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaNodeType.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaRequirement.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaServiceTemplate.java
models/src/main/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaWithToscaProperties.java
models/src/test/java/org/onap/policy/clamp/models/acm/document/base/DocUtilTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidationTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaNodeTemplateTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaServiceTemplateTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaTopologyTemplateTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/PropertiesUpdateTest.java [new file with mode: 0644]
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3.java
participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3Test.java
participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/MsgExecutorTest.java
runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java

index eb6df02..735d453 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022,2025 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.
@@ -65,15 +65,6 @@ public class DocConceptKey extends PfKeyImpl {
         super(copyConcept);
     }
 
-    /**
-     * Copy constructor.
-     *
-     * @param copyConcept the concept to copy from
-     */
-    public DocConceptKey(final DocConceptKey copyConcept) {
-        this(copyConcept.getName(), copyConcept.getVersion());
-    }
-
     /**
      * Temporary Constructor to create a key with the specified name and version.
      *
index 143ee23..55b62f0 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022,2025 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.
@@ -153,20 +153,6 @@ public final class DocUtil {
         }
     }
 
-    /**
-     * Convenience method to apply a mapping function to all of the values of a list of maps, generating a new map.
-     *
-     * @param source list of maps whose values are to be mapped, or {@code null}
-     * @param mapFunc mapping function
-     * @return a new map, containing mappings of all of the items in the original map, or {@code null} if the source is
-     *         {@code null}
-     */
-    public static <A extends ToscaEntity, R> Map<String, R> listToDocMap(List<Map<String, A>> source,
-            Function<A, R> mapFunc) {
-
-        return listToDocMap(source, mapFunc, null);
-    }
-
     /**
      * Convenience method to apply a mapping function to all of the values of a list of maps, generating a new map.
      *
index 0053ca0..c13ca94 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2023 Nordix Foundation.
+ *  Copyright (C) 2022-2023,2025 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.
@@ -46,7 +46,7 @@ public final class ToscaServiceTemplateValidation {
      * @param result the result
      * @param serviceTemplate the serviceTemplate to validate
      */
-    public static void validate(final BeanValidationResult result, DocToscaServiceTemplate serviceTemplate,
+    public static void validate(final @NonNull BeanValidationResult result, DocToscaServiceTemplate serviceTemplate,
                                 String toscaCompositionName) {
 
         var references = DocUtil.getToscaReferences(serviceTemplate);
@@ -96,7 +96,7 @@ public final class ToscaServiceTemplateValidation {
      * @param topologyTemplate the ToscaServiceTemplate
      * @param toscaCompositionName the name of the ToscaComposition
      */
-    public static void validateToscaTopologyTemplate(BeanValidationResult result,
+    public static void validateToscaTopologyTemplate(final @NonNull BeanValidationResult result,
             DocToscaTopologyTemplate topologyTemplate, String toscaCompositionName) {
         String acNodeTypeNotPresent =
                 "NodeTemplate with type " + toscaCompositionName + " must exist!";
@@ -188,14 +188,14 @@ public final class ToscaServiceTemplateValidation {
     }
 
     private static boolean isTypePresent(String key, Set<String> reference) {
-        if (reference == null || reference.isEmpty()) {
+        if (reference.isEmpty()) {
             return false;
         }
         return reference.contains(key);
     }
 
     private static boolean isTypePresent(DocConceptKey key, Set<String> reference) {
-        if (reference == null || reference.isEmpty()) {
+        if (reference.isEmpty()) {
             return false;
         }
         return reference.contains(key.getId());
@@ -225,7 +225,7 @@ public final class ToscaServiceTemplateValidation {
      * @param result the result of the ancestor search with any warnings or errors
      */
     private static void validEntityTypeAncestors(Map<String, ? extends DocToscaEntity<?>> entityTypes,
-            Set<String> reference, @NonNull final BeanValidationResult result) {
+            Set<String> reference, final BeanValidationResult result) {
         if (entityTypes != null) {
             for (var entityType : entityTypes.values()) {
                 var parentEntityTypeKey = extractDerivedFrom(entityType, result);
@@ -246,7 +246,7 @@ public final class ToscaServiceTemplateValidation {
      * @param result the result of the ancestor search with any warnings or errors
      */
     private static <T extends DocToscaEntity<?>> void validEntityTypeAncestors(List<Map<String, T>> entityTypesList,
-            Set<String> reference, @NonNull final BeanValidationResult result) {
+            Set<String> reference, final BeanValidationResult result) {
         if (entityTypesList != null) {
             for (var entityTypes : entityTypesList) {
                 for (var entityType : entityTypes.values()) {
index e675e23..64aa45e 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022,2024 Nordix Foundation.
+ *  Copyright (C) 2022,2024-2025 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.
@@ -90,10 +90,6 @@ public class DocToscaCapabilityAssignment extends DocToscaWithTypeAndStringPrope
 
     @Override
     public int compareTo(DocToscaEntity<ToscaCapabilityAssignment> otherConcept) {
-        if (this == otherConcept) {
-            return 0;
-        }
-
         int result = super.compareTo(otherConcept);
         if (result != 0) {
             return result;
index e305f5d..dffb4cf 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022,2025 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.
@@ -73,10 +73,6 @@ public class DocToscaDataType extends DocToscaWithToscaProperties<ToscaDataType>
 
     @Override
     public int compareTo(DocToscaEntity<ToscaDataType> otherConcept) {
-        if (this == otherConcept) {
-            return 0;
-        }
-
         int result = super.compareTo(otherConcept);
         if (result != 0) {
             return result;
index 4a3d92c..8a20c12 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022,2025 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.
@@ -93,10 +93,6 @@ public class DocToscaNodeTemplate extends DocToscaWithTypeAndStringProperties<To
 
     @Override
     public int compareTo(DocToscaEntity<ToscaNodeTemplate> otherConcept) {
-        if (this == otherConcept) {
-            return 0;
-        }
-
         int result = super.compareTo(otherConcept);
         if (result != 0) {
             return result;
index 3d42582..6e40592 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022,2025 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.
@@ -76,10 +76,6 @@ public class DocToscaNodeType extends DocToscaWithToscaProperties<ToscaNodeType>
 
     @Override
     public int compareTo(DocToscaEntity<ToscaNodeType> otherConcept) {
-        if (this == otherConcept) {
-            return 0;
-        }
-
         int result = super.compareTo(otherConcept);
         if (result != 0) {
             return result;
index 9d3cc10..1aeb66d 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022,2024 Nordix Foundation.
+ *  Copyright (C) 2022,2024-2025 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.
@@ -60,7 +60,9 @@ public class DocToscaRequirement extends DocToscaWithTypeAndStringProperties<Tos
         this.capability = copyConcept.capability;
         this.node = copyConcept.node;
         this.relationship = copyConcept.relationship;
-        this.occurrences = new ArrayList<>(copyConcept.occurrences);
+        if (copyConcept.occurrences != null) {
+            this.occurrences = new ArrayList<>(copyConcept.occurrences);
+        }
     }
 
     @Override
@@ -95,10 +97,6 @@ public class DocToscaRequirement extends DocToscaWithTypeAndStringProperties<Tos
 
     @Override
     public int compareTo(DocToscaEntity<ToscaRequirement> otherConcept) {
-        if (this == otherConcept) {
-            return 0;
-        }
-
         int result = super.compareTo(otherConcept);
         if (result != 0) {
             return result;
index 904cbfc..42f7099 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022,2025 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.
@@ -118,7 +118,9 @@ public class DocToscaServiceTemplate extends DocToscaEntity<ToscaServiceTemplate
                 .setRelationshipTypes(DocUtil.docMapToMap(relationshipTypes, DocToscaRelationshipType::toAuthorative));
         toscaServiceTemplate.setNodeTypes(DocUtil.docMapToMap(nodeTypes, DocToscaNodeType::toAuthorative));
         toscaServiceTemplate.setPolicyTypes(DocUtil.docMapToMap(policyTypes, DocToscaPolicyType::toAuthorative));
-        toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate.toAuthorative());
+        if (toscaTopologyTemplate != null) {
+            toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate.toAuthorative());
+        }
 
         return toscaServiceTemplate;
     }
@@ -135,18 +137,21 @@ public class DocToscaServiceTemplate extends DocToscaEntity<ToscaServiceTemplate
 
         toscaDefinitionsVersion = toscaServiceTemplate.getToscaDefinitionsVersion();
 
-        dataTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getDataTypes(), DocToscaDataType::new);
+        dataTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getDataTypes(), DocToscaDataType::new,
+                new LinkedHashMap<>());
 
-        capabilityTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getCapabilityTypes(), DocToscaCapabilityType::new);
+        capabilityTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getCapabilityTypes(), DocToscaCapabilityType::new,
+                new LinkedHashMap<>());
 
         relationshipTypes =
-                DocUtil.mapToDocMap(toscaServiceTemplate.getRelationshipTypes(), DocToscaRelationshipType::new);
+                DocUtil.mapToDocMap(toscaServiceTemplate.getRelationshipTypes(), DocToscaRelationshipType::new,
+                        new LinkedHashMap<>());
 
-        nodeTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getNodeTypes(), DocToscaNodeType::new);
+        nodeTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getNodeTypes(), DocToscaNodeType::new,
+                new LinkedHashMap<>());
 
-        if (toscaServiceTemplate.getPolicyTypes() != null) {
-            policyTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getPolicyTypes(), DocToscaPolicyType::new);
-        }
+        policyTypes = DocUtil.mapToDocMap(toscaServiceTemplate.getPolicyTypes(), DocToscaPolicyType::new,
+                new LinkedHashMap<>());
 
         if (toscaServiceTemplate.getToscaTopologyTemplate() != null) {
             toscaTopologyTemplate = new DocToscaTopologyTemplate(toscaServiceTemplate.getToscaTopologyTemplate());
@@ -191,27 +196,18 @@ public class DocToscaServiceTemplate extends DocToscaEntity<ToscaServiceTemplate
     }
 
     /**
-     * Compare this service template to another service template, ignoring contained entitites.
+     * Compare this service template to another service template, ignoring contained entities.
      *
      * @param otherConcept the other topology template
      * @return the result of the comparison
      */
     public int compareToWithoutEntities(final DocToscaEntity<ToscaServiceTemplate> otherConcept) {
-        if (otherConcept == null) {
-            return -1;
-        }
-        if (this == otherConcept) {
-            return 0;
-        }
-        if (getClass() != otherConcept.getClass()) {
-            return getClass().getName().compareTo(otherConcept.getClass().getName());
+        int result = super.compareTo(otherConcept);
+        if (result != 0) {
+            return result;
         }
 
         final var other = (DocToscaServiceTemplate) otherConcept;
-        if (!super.equals(other)) {
-            return super.compareTo(other);
-        }
-
         return ObjectUtils.compare(toscaDefinitionsVersion, other.toscaDefinitionsVersion);
     }
 }
index bcb63a2..5aa3aad 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022,2024 Nordix Foundation.
+ *  Copyright (C) 2022,2024-2025 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.
@@ -126,10 +126,6 @@ public class DocToscaWithToscaProperties<T extends ToscaWithToscaProperties> ext
 
     @Override
     public int compareTo(final DocToscaEntity<T> otherConcept) {
-        if (this == otherConcept) {
-            return 0;
-        }
-
         int result = super.compareTo(otherConcept);
         if (result != 0) {
             return result;
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/document/base/DocUtilTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/document/base/DocUtilTest.java
new file mode 100644 (file)
index 0000000..4a643c3
--- /dev/null
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 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.clamp.models.acm.document.base;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaTopologyTemplate;
+import org.onap.policy.models.base.PfNameVersion;
+
+class DocUtilTest {
+
+    @Test
+    void testDocMapToList() {
+        Map<String, PfNameVersion> map = null;
+        List<Map<String, PfNameVersion>> defaultValue = List.of();
+        var result = DocUtil.docMapToList(map, Function.identity(), defaultValue);
+        assertThat(result).isEqualTo(defaultValue);
+    }
+
+    @Test
+    void testGetToscaReferences() {
+        var docServiceTemplate = new DocToscaServiceTemplate();
+        var result = DocUtil.getToscaReferences(docServiceTemplate);
+        assertThat(result).isNotEmpty();
+        docServiceTemplate.setToscaTopologyTemplate(new DocToscaTopologyTemplate());
+        result = DocUtil.getToscaReferences(docServiceTemplate);
+        assertThat(result).isNotEmpty();
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidationTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/document/base/ToscaServiceTemplateValidationTest.java
new file mode 100644 (file)
index 0000000..1568af1
--- /dev/null
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 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.clamp.models.acm.document.base;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaDataType;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaNodeTemplate;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaPolicy;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaProperty;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaRequirement;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
+import org.onap.policy.clamp.models.acm.document.concepts.DocToscaTopologyTemplate;
+import org.onap.policy.common.parameters.BeanValidationResult;
+
+class ToscaServiceTemplateValidationTest {
+
+    public static final String AUTOMATION_COMPOSITION_ELEMENT =
+            "org.onap.policy.clamp.acm.AutomationCompositionElement";
+    public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
+    private static final String NAME_VERSION1 = "name:1.0.0";
+    private static final String NAME_VERSION2 = "name:1.0.1";
+    private static final String NAME = "name";
+    private static final String TYPE = "type";
+    private static final String VERSION = "1.0.0";
+
+    @Test
+    void testValidate() {
+        var doc = new DocToscaServiceTemplate();
+        assertThatThrownBy(
+                () -> ToscaServiceTemplateValidation.validate(null, doc, AUTOMATION_COMPOSITION_NODE_TYPE))
+                .isInstanceOf(NullPointerException.class);
+        var result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        var docDataType = new DocToscaDataType();
+        docDataType.setName(NAME);
+        docDataType.setVersion(VERSION);
+        var docProperty = new DocToscaProperty();
+        docProperty.setType(TYPE);
+        docProperty.setTypeVersion(VERSION);
+        docDataType.setProperties(Map.of(NAME_VERSION1, docProperty));
+        docDataType.setDerivedFrom("NotExist");
+        doc.setDataTypes(Map.of(NAME_VERSION1, docDataType));
+        result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        // ancestor of itself
+        docDataType.setDerivedFrom(NAME);
+        result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        doc.setDataTypes(null);
+        var docTopologyTemplate = new DocToscaTopologyTemplate();
+        doc.setToscaTopologyTemplate(docTopologyTemplate);
+        result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        var docPolicy = new DocToscaPolicy();
+        docPolicy.setType(TYPE);
+        docPolicy.setTypeVersion(VERSION);
+        docTopologyTemplate.setPolicies(Map.of(NAME_VERSION1, docPolicy));
+        result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        docTopologyTemplate.setPolicies(null);
+        var docNodeTemplates = new DocToscaNodeTemplate();
+        docNodeTemplates.setType(TYPE);
+        docNodeTemplates.setTypeVersion(VERSION);
+        var docRequirement = new DocToscaRequirement();
+        docRequirement.setType(TYPE);
+        docRequirement.setTypeVersion(VERSION);
+        docNodeTemplates.setRequirements(List.of(Map.of(NAME_VERSION1, docRequirement)));
+        docTopologyTemplate.setNodeTemplates(Map.of(NAME_VERSION1, docNodeTemplates));
+        result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        docRequirement.setDerivedFrom("NotExist");
+        result = getValidate(doc);
+        assertThat(result.isValid()).isFalse();
+    }
+
+    private BeanValidationResult getValidate(DocToscaServiceTemplate doc) {
+        var result = new BeanValidationResult("DocToscaServiceTemplate", doc);
+        ToscaServiceTemplateValidation.validate(result, doc, AUTOMATION_COMPOSITION_NODE_TYPE);
+        return result;
+    }
+
+    @Test
+    void testValidateToscaTopologyTemplate() {
+        var result = getValidateToscaTopologyTemplate(null);
+        assertThat(result.isValid()).isFalse();
+
+        var doc = new DocToscaTopologyTemplate();
+        assertThatThrownBy(() -> ToscaServiceTemplateValidation
+                .validateToscaTopologyTemplate(null, doc, AUTOMATION_COMPOSITION_NODE_TYPE))
+                .isInstanceOf(NullPointerException.class);
+        result = getValidateToscaTopologyTemplate(doc);
+        assertThat(result.isValid()).isFalse();
+
+        var docNodeTemplate1 = new DocToscaNodeTemplate();
+        docNodeTemplate1.setType(AUTOMATION_COMPOSITION_NODE_TYPE);
+        docNodeTemplate1.setTypeVersion(VERSION);
+        var docNodeTemplate2 = new DocToscaNodeTemplate();
+        docNodeTemplate2.setType(AUTOMATION_COMPOSITION_NODE_TYPE);
+        docNodeTemplate2.setTypeVersion("1.0.1");
+        doc.setNodeTemplates(Map.of(NAME_VERSION1, docNodeTemplate1, NAME_VERSION2, docNodeTemplate2));
+        result = getValidateToscaTopologyTemplate(doc);
+        assertThat(result.isValid()).isFalse();
+    }
+
+    private BeanValidationResult getValidateToscaTopologyTemplate(DocToscaTopologyTemplate doc) {
+        var result = new BeanValidationResult("DocToscaTopologyTemplate", doc);
+        ToscaServiceTemplateValidation.validateToscaTopologyTemplate(result, doc, AUTOMATION_COMPOSITION_NODE_TYPE);
+        return result;
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaNodeTemplateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaNodeTemplateTest.java
new file mode 100644 (file)
index 0000000..d987725
--- /dev/null
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 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.clamp.models.acm.document.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityAssignment;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaRequirement;
+
+class DocToscaNodeTemplateTest {
+
+    private static final String NAME = "name";
+    private static final String TYPE = "type";
+    private static final String VERSION = "1.0.0";
+    private static final String NAME_VERSION = "name:0.0.0";
+
+    @Test
+    void testToscaNodeTemplate() {
+        var nodeTemplate = new ToscaNodeTemplate();
+        nodeTemplate.setType(TYPE);
+        nodeTemplate.setTypeVersion(VERSION);
+        var doc = new DocToscaNodeTemplate(nodeTemplate);
+        assertThat(doc)
+                .isNotEqualByComparingTo(null)
+                .isEqualByComparingTo(doc);
+
+        var requirement = new ToscaRequirement();
+        requirement.setType(TYPE);
+        requirement.setTypeVersion(VERSION);
+        nodeTemplate.setRequirements(List.of(Map.of(NAME, requirement)));
+        var doc2 = new DocToscaNodeTemplate(doc);
+        doc = new DocToscaNodeTemplate(nodeTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setRequirements(doc.getRequirements());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        var capabilityAssignment = new ToscaCapabilityAssignment();
+        capabilityAssignment.setType(TYPE);
+        capabilityAssignment.setTypeVersion(VERSION);
+        nodeTemplate.setCapabilities(Map.of(NAME, capabilityAssignment));
+        doc = new DocToscaNodeTemplate(nodeTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setCapabilities(doc.getCapabilities());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        capabilityAssignment.setAttributes(Map.of("key", "value"));
+        doc = new DocToscaNodeTemplate(nodeTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        var docCapabilityAssignment = doc.getCapabilities().get(NAME_VERSION);
+        assertThat(docCapabilityAssignment)
+                .isNotEqualByComparingTo(null)
+                .isEqualByComparingTo(docCapabilityAssignment);
+
+        doc2.getCapabilities().get(NAME_VERSION).setAttributes(docCapabilityAssignment.getAttributes());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+        doc2 = new DocToscaNodeTemplate(doc);
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+
+        capabilityAssignment.setAttributes(null);
+        capabilityAssignment.setOccurrences(List.of(NAME));
+        doc = new DocToscaNodeTemplate(nodeTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        docCapabilityAssignment = doc.getCapabilities().get(NAME_VERSION);
+
+        doc2.getCapabilities().get(NAME_VERSION).setAttributes(docCapabilityAssignment.getAttributes());
+        doc2.getCapabilities().get(NAME_VERSION).setOccurrences(docCapabilityAssignment.getOccurrences());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+        doc2 = new DocToscaNodeTemplate(doc);
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaServiceTemplateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaServiceTemplateTest.java
new file mode 100644 (file)
index 0000000..0f18e8e
--- /dev/null
@@ -0,0 +1,241 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 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.clamp.models.acm.document.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.document.base.DocConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaRequirement;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
+
+class DocToscaServiceTemplateTest {
+
+    private static final String NAME = "name";
+    private static final String NAME_VERSION = "name:0.0.0";
+
+    @Test
+    void test() {
+        var serviceTemplate = new ToscaServiceTemplate();
+        serviceTemplate.setName(PfKey.NULL_KEY_NAME);
+        serviceTemplate.setVersion(PfKey.NULL_KEY_VERSION);
+        var doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc.toAuthorative()).isNotNull();
+        assertThat(doc).isNotEqualByComparingTo(null)
+                .isEqualByComparingTo(doc);
+
+        var doc2 = new DocToscaServiceTemplate(doc);
+        assertThat(doc2.toAuthorative()).isNotNull();
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setToscaTopologyTemplate(new ToscaTopologyTemplate());
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setToscaTopologyTemplate(doc.getToscaTopologyTemplate());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setDataTypes(Map.of(NAME, new ToscaDataType()));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setDataTypes(doc.getDataTypes());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setCapabilityTypes(Map.of(NAME, new ToscaCapabilityType()));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setCapabilityTypes(doc.getCapabilityTypes());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setRelationshipTypes(Map.of(NAME, new ToscaRelationshipType()));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setRelationshipTypes(doc.getRelationshipTypes());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setNodeTypes(Map.of(NAME, new ToscaNodeType()));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setNodeTypes(doc.getNodeTypes());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setPolicyTypes(Map.of(NAME, new ToscaPolicyType()));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        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");
+        doc.fromAuthorative(serviceTemplate);
+        assertThat(doc.toAuthorative()).isNotNull();
+    }
+
+    @Test
+    void testToscaDataType() {
+        var serviceTemplate = new ToscaServiceTemplate();
+        var dataType = new ToscaDataType();
+        serviceTemplate.setDataTypes(Map.of(NAME, dataType));
+        var toscaConstraint = new ToscaConstraint();
+        toscaConstraint.setRangeValues(List.of("value"));
+        toscaConstraint.setValidValues(List.of("value"));
+        var doc = new DocToscaServiceTemplate(serviceTemplate);
+        var doc2 = new DocToscaServiceTemplate(doc);
+
+        dataType.setConstraints(List.of(toscaConstraint));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setDataTypes(Map.of(NAME_VERSION, doc.getDataTypes().get(NAME_VERSION)));
+        assertThat(doc).isEqualByComparingTo(doc2);
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+
+        var property = new ToscaProperty();
+        property.setType("type");
+        dataType.setProperties(Map.of(NAME, property));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+    }
+
+    @Test
+    void testDocToscaEntity() {
+        var serviceTemplate = new ToscaServiceTemplate();
+        var doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc.getType()).isNull();
+        assertThat(doc.getTypeVersion()).isNull();
+        assertThat(doc.getDefinedName()).isEqualTo("tosca");
+        assertThat(doc.getDefinedVersion()).isEqualTo("1.0.0");
+
+        serviceTemplate.setDerivedFrom(NAME);
+        var doc2 = new DocToscaServiceTemplate(doc);
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setDerivedFrom(doc.getDerivedFrom());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setDescription("Description");
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setDescription(doc.getDescription());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        serviceTemplate.setMetadata(Map.of("key", "value"));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setMetadata(doc.getMetadata());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        var d = new DocToscaEntity<ToscaServiceTemplate>();
+        var result = doc.compareTo(d);
+        assertThat(result).isNotZero();
+    }
+
+    @Test
+    void testDocToscaNodeType() {
+        var serviceTemplate = new ToscaServiceTemplate();
+        var nodeType = new ToscaNodeType();
+        serviceTemplate.setNodeTypes(Map.of(NAME, nodeType));
+        var doc = new DocToscaServiceTemplate(serviceTemplate);
+        var doc2 = new DocToscaServiceTemplate(doc);
+        var docNodeType = doc.getNodeTypes().get(NAME_VERSION);
+        doc2.setNodeTypes(Map.of(NAME_VERSION, docNodeType));
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        var requirement = new ToscaRequirement();
+        requirement.setType(NAME);
+        requirement.setTypeVersion("1.0.0");
+        nodeType.setRequirements(List.of(Map.of(NAME, requirement)));
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        docNodeType = doc.getNodeTypes().get(NAME_VERSION);
+        doc2.getNodeTypes().get(NAME_VERSION).setRequirements(docNodeType.getRequirements());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        var docRequirement = docNodeType.getRequirements().get(0).get(NAME_VERSION);
+        assertThat(docRequirement)
+                .isNotEqualByComparingTo(null)
+                .isEqualByComparingTo(docRequirement);
+
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+        doc2 = new DocToscaServiceTemplate(doc);
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+    }
+
+    @Test
+    void testDocToscaProperty() {
+        var serviceTemplate = new ToscaServiceTemplate();
+        var property = new ToscaProperty();
+        property.setType("type");
+        var nodeType = new ToscaNodeType();
+        nodeType.setProperties(Map.of(NAME, property));
+        serviceTemplate.setNodeTypes(Map.of(NAME, nodeType));
+        var doc = new DocToscaServiceTemplate(serviceTemplate);
+        var doc2 = new DocToscaServiceTemplate(doc);
+
+        property.setDescription("Description");
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        var docNodeType = doc2.getNodeTypes().get(NAME_VERSION);
+        var docProperty = docNodeType.getProperties().get(NAME);
+        docProperty.setDescription(property.getDescription());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        property.setRequired(true);
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        docProperty.setRequired(property.isRequired());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        property.setDefaultValue("Default");
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        docProperty.setDefaultValue(property.getDefaultValue());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        property.setStatus(ToscaProperty.Status.SUPPORTED);
+        doc = new DocToscaServiceTemplate(serviceTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        docProperty.setStatus(property.getStatus());
+        assertThat(doc).isEqualByComparingTo(doc2);
+    }
+
+    @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);
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaTopologyTemplateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/document/concepts/DocToscaTopologyTemplateTest.java
new file mode 100644 (file)
index 0000000..40611ff
--- /dev/null
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 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.clamp.models.acm.document.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaParameter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
+
+class DocToscaTopologyTemplateTest {
+
+    private static final String NAME = "name";
+
+    @Test
+    void testToscaTopologyTemplate() {
+        var topologyTemplate =  new ToscaTopologyTemplate();
+        var doc = new DocToscaTopologyTemplate(topologyTemplate);
+        assertThat(doc)
+                .isNotEqualByComparingTo(null)
+                .isEqualByComparingTo(doc);
+        var doc2 = new DocToscaTopologyTemplate(doc);
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        var nodeTemplate = new ToscaNodeTemplate();
+        nodeTemplate.setType("type");
+        nodeTemplate.setTypeVersion("1.0.0");
+        topologyTemplate.setNodeTemplates(Map.of(NAME, nodeTemplate));
+        doc = new DocToscaTopologyTemplate(topologyTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setNodeTemplates(doc.getNodeTemplates());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        var toscaPolicy = new ToscaPolicy();
+        toscaPolicy.setType("type");
+        toscaPolicy.setTypeVersion("1.0.0");
+        topologyTemplate.setPolicies(List.of(Map.of(NAME, toscaPolicy)));
+        doc = new DocToscaTopologyTemplate(topologyTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setPolicies(doc.getPolicies());
+        assertThat(doc).isEqualByComparingTo(doc2);
+
+        topologyTemplate.setInputs(Map.of(NAME, new ToscaParameter()));
+        doc = new DocToscaTopologyTemplate(topologyTemplate);
+        assertThat(doc).isNotEqualByComparingTo(doc2);
+        doc2.setInputs(doc.getInputs());
+        assertThat(doc).isEqualByComparingTo(doc2);
+        var docParameter = doc.getInputs().get(NAME);
+        assertThat(docParameter)
+                .isNotEqualByComparingTo(null)
+                .isEqualByComparingTo(docParameter);
+
+        doc2 = new DocToscaTopologyTemplate(doc);
+        assertThat(doc.toAuthorative()).isEqualTo(doc2.toAuthorative());
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/PropertiesUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/PropertiesUpdateTest.java
new file mode 100644 (file)
index 0000000..7ad2cfb
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2025 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.clamp.models.acm.messages.kafka.participant;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.util.List;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+class PropertiesUpdateTest {
+
+    @Test
+    void testCopyConstructor() throws CoderException {
+        var acElement = new AcElementDeploy();
+        acElement.setId(UUID.randomUUID());
+        var id = new ToscaConceptIdentifier("id", "1.2.3");
+        acElement.setDefinition(id);
+        var participantDeploy = new ParticipantDeploy();
+        participantDeploy.setParticipantId(CommonTestData.getParticipantId());
+        participantDeploy.setAcElementList(List.of(acElement));
+        var orig = new PropertiesUpdate();
+        orig.setParticipantUpdatesList(List.of(participantDeploy));
+        orig.setCompositionId(UUID.randomUUID());
+        orig.setRevisionIdComposition(UUID.randomUUID());
+        orig.setAutomationCompositionId(UUID.randomUUID());
+        orig.setRevisionIdInstance(UUID.randomUUID());
+
+        var other = new PropertiesUpdate(orig);
+        assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+        assertSerializable(orig, PropertiesUpdate.class);
+    }
+}
index 1c6c3a7..8f13c2d 100644 (file)
@@ -45,4 +45,10 @@ public abstract class AcElementListenerV3 extends AcElementListenerV4
                 instanceElement.elementId(), DeployState.UNDEPLOYED, null,\r
                 StateChangeResult.NO_ERROR, "Prepare completed");\r
     }\r
+\r
+    @Override\r
+    public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement, int nextStage)\r
+            throws PfModelException {\r
+        prepare(compositionElement, instanceElement);\r
+    }\r
 }\r
index 4856d03..273d8aa 100644 (file)
@@ -158,7 +158,7 @@ class AcElementListenerV3Test {
         var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
                 Map.of(), Map.of());
         var instanceElement = new InstanceElementDto(UUID.randomUUID(), UUID.randomUUID(), Map.of(), Map.of());
-        acElementListener.prepare(compositionElement, instanceElement);
+        acElementListener.prepare(compositionElement, instanceElement, 0);
         verify(intermediaryApi).updateAutomationCompositionElementState(instanceElement.instanceId(),
                 instanceElement.elementId(), DeployState.UNDEPLOYED, null,
                 StateChangeResult.NO_ERROR, "Prepare completed");
index 5d602fb..cb42e4c 100644 (file)
@@ -277,4 +277,19 @@ class ParticipantIntermediaryApiImplTest {
         result = apiImpl.getRollbackNextStage(compositionElementTarget, 0);
         assertEquals(0, result);
     }
+
+    @Test
+    void testGetPrepareNextStage() {
+        var cacheProvider = mock(CacheProvider.class);
+        var automationCompositionHandler = mock(AutomationCompositionOutHandler.class);
+        var apiImpl = new ParticipantIntermediaryApiImpl(automationCompositionHandler, cacheProvider);
+        var prepare = Map.of("prepare", List.of(0, 2));
+        Map<String, Object> stageSet = Map.of("stage", prepare);
+        var compositionElementTarget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+                stageSet, Map.of());
+        var result = apiImpl.getPrepareNextStage(compositionElementTarget, 0);
+        assertEquals(2, result);
+        result = apiImpl.getPrepareNextStage(compositionElementTarget, 2);
+        assertEquals(2, result);
+    }
 }
index 0a7fcb4..c12b40f 100644 (file)
@@ -79,7 +79,7 @@ class MsgExecutorTest {
                 CommonTestData.createAutomationCompositionElementDefinitionList(automationComposition);
         cacheProvider.addElementDefinition(compositionId, definitions, revisionIdComposition);
         msgExecutor.check();
-        verify(automationCompositionHandler, timeout(100)).handleAutomationCompositionDeploy(updateMsg);
+        verify(automationCompositionHandler, timeout(200)).handleAutomationCompositionDeploy(updateMsg);
         assertThat(cacheProvider.getMessagesOnHold()).isEmpty();
     }
 
index 776499a..6568cd6 100644 (file)
@@ -53,6 +53,7 @@ import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMe
 import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantPrimeAck;
 import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantRegister;
 import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantRegisterAck;
+import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantReqSync;
 import org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantStatus;
 import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
 import org.onap.policy.clamp.models.acm.utils.AcmUtils;
@@ -372,4 +373,13 @@ class SupervisionMessagesTest {
         acStateChangeAckListener.onTopicEvent(INFRA, TOPIC, null, automationCompositionAck);
         verify(supervisionHandler).handleAutomationCompositionStateChangeAckMessage(automationCompositionAck);
     }
+
+    @Test
+    void testParticipantReqSyncListener() {
+        final var participantReqSync = new ParticipantReqSync();
+        var supervisionParticipantHandler = mock(SupervisionParticipantHandler.class);
+        var reqSyncListener = new ParticipantReqSyncListener(supervisionParticipantHandler);
+        reqSyncListener.onTopicEvent(INFRA, TOPIC, null, participantReqSync);
+        verify(supervisionParticipantHandler).handleParticipantReqSync(participantReqSync);
+    }
 }