Add supported ac elements to participants 49/132949/2
authorsaul.gill <saul.gill@est.tech>
Fri, 13 Jan 2023 17:24:23 +0000 (17:24 +0000)
committersaul.gill <saul.gill@est.tech>
Thu, 19 Jan 2023 13:07:33 +0000 (13:07 +0000)
Added new supported elements table
Added supported element names and versions
to participant application.yaml files

Issue-ID: POLICY-4512
Change-Id: I97d7f571f2906846514ac0804b4827f0601177d7
Signed-off-by: saul.gill <saul.gill@est.tech>
29 files changed:
models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java [new file with mode: 0644]
models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.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/JpaParticipantSupportedElementType.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantsSupportedElementTypesTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java [new file with mode: 0644]
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
models/src/test/resources/providers/TestParticipant.json
participant/participant-impl/participant-impl-a1pms/src/test/resources/application-test.yaml
participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml
participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml
participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java

index c6da3c3..56c0183 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.models.acm.concepts;
 
+import java.util.Map;
 import java.util.UUID;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -48,6 +49,9 @@ public class Participant extends ToscaEntity implements Comparable<Participant>
     @NonNull
     private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
 
+    @NonNull
+    private Map<UUID, ParticipantSupportedElementType> participantSupportedElementTypes;
+
     @Override
     public String getType() {
         return definition.getName();
index c2f61aa..a6a65fe 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java
new file mode 100644 (file)
index 0000000..3105771
--- /dev/null
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.concepts;
+
+import java.util.UUID;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.springframework.validation.annotation.Validated;
+
+@NoArgsConstructor
+@Getter
+@Setter
+@Validated
+public class ParticipantSupportedElementType {
+
+    @NotNull
+    private UUID id = UUID.randomUUID();
+
+    @NotNull
+    private String typeName;
+
+    @NotNull
+    private String typeVersion;
+
+    /**
+     * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy.
+     *
+     * @param otherParticipantSupportedElementType the other element to copy from
+     */
+    public ParticipantSupportedElementType(final ParticipantSupportedElementType otherParticipantSupportedElementType) {
+        this.id = otherParticipantSupportedElementType.getId();
+        this.typeName = otherParticipantSupportedElementType.getTypeName();
+        this.typeVersion = otherParticipantSupportedElementType.getTypeVersion();
+    }
+}
index 8b33d31..c6d5690 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index 7b315db..d8f9a4c 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * 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.clamp.models.acm.messages.dmaap.participant;
 
+import java.util.List;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
 
 /**
  * Class to represent the PARTICIPANT_REGISTER message that all the participants send to the ACM runtime.
@@ -32,6 +34,8 @@ import lombok.ToString;
 @ToString(callSuper = true)
 public class ParticipantRegister extends ParticipantMessage {
 
+    private List<ParticipantSupportedElementType> participantSupportedElementType;
+
     /**
      * Constructor for instantiating ParticipantRegister class with message name.
      *
@@ -47,5 +51,6 @@ public class ParticipantRegister extends ParticipantMessage {
      */
     public ParticipantRegister(final ParticipantRegister source) {
         super(source);
+        this.participantSupportedElementType = source.getParticipantSupportedElementType();
     }
 }
index 31a42c5..2412bdd 100644 (file)
@@ -28,6 +28,7 @@ import lombok.ToString;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
 import org.onap.policy.models.base.PfUtils;
 
 /**
@@ -47,10 +48,12 @@ public class ParticipantStatus extends ParticipantMessage {
     // List of AutomationCompositionInfo types with AutomationCompositionId and its state
     private List<AutomationCompositionInfo> automationCompositionInfoList = new ArrayList<>();
 
+    private List<ParticipantSupportedElementType> participantSupportedElementType;
     /**
      * Constructor for instantiating ParticipantStatus class with message name.
      *
      */
+
     public ParticipantStatus() {
         super(ParticipantMessageType.PARTICIPANT_STATUS);
     }
@@ -68,5 +71,6 @@ public class ParticipantStatus extends ParticipantMessage {
             PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
         this.automationCompositionInfoList =
             PfUtils.mapList(source.automationCompositionInfoList, AutomationCompositionInfo::new);
+        this.participantSupportedElementType = source.getParticipantSupportedElementType();
     }
 }
index 398daa2..7d043ac 100644 (file)
 package org.onap.policy.clamp.models.acm.persistence.concepts;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.UUID;
 import javax.persistence.AttributeOverride;
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.EmbeddedId;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ForeignKey;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
 import javax.persistence.Table;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -37,6 +44,7 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.onap.policy.clamp.models.acm.concepts.Participant;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
 import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
 import org.onap.policy.models.base.PfAuthorative;
 import org.onap.policy.models.base.PfConcept;
 import org.onap.policy.models.base.PfConceptKey;
@@ -86,6 +94,12 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
     @Column
     private String description;
 
+    @NotNull
+    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
+    @JoinColumn(name = "participantId", referencedColumnName = "participantId",
+        foreignKey = @ForeignKey(name = "supported_element_fk"))
+    private List<@NotNull @Valid JpaParticipantSupportedElementType> supportedElements;
+
     /**
      * The Default Constructor creates a {@link JpaParticipant} object with a null key.
      */
@@ -99,7 +113,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
      * @param key the key
      */
     public JpaParticipant(@NonNull final PfConceptKey key) {
-        this(UUID.randomUUID().toString(), key, new PfConceptKey(), ParticipantState.ON_LINE);
+        this(UUID.randomUUID().toString(), key, new PfConceptKey(), ParticipantState.ON_LINE, new ArrayList<>());
     }
 
     /**
@@ -113,11 +127,13 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
     public JpaParticipant(@NotNull String participantId,
                           @NonNull final PfConceptKey key,
                           @NonNull final PfConceptKey definition,
-                          @NonNull final ParticipantState participantState) {
+                          @NonNull final ParticipantState participantState,
+                          @NonNull final List<JpaParticipantSupportedElementType> supportedAcElementTypes) {
         this.key = key;
         this.definition = definition;
         this.participantState = participantState;
         this.participantId = participantId;
+        this.supportedElements = supportedAcElementTypes;
     }
 
     /**
@@ -133,6 +149,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         this.description = copyConcept.description;
         this.participantType = copyConcept.participantType;
         this.participantId = copyConcept.participantId;
+        this.supportedElements = copyConcept.supportedElements;
     }
 
     /**
@@ -155,6 +172,11 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         participant.setDescription(description);
         participant.setParticipantType(new ToscaConceptIdentifier(participantType));
         participant.setParticipantId(UUID.fromString(participantId));
+        participant.setParticipantSupportedElementTypes(new LinkedHashMap<>(this.supportedElements.size()));
+        for (var element : this.supportedElements) {
+            participant.getParticipantSupportedElementTypes()
+                .put(UUID.fromString(element.getId()), element.toAuthorative());
+        }
 
         return participant;
     }
@@ -170,6 +192,14 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
         this.setDescription(participant.getDescription());
         this.participantType = participant.getParticipantType().asConceptKey();
         this.participantId = participant.getParticipantId().toString();
+        this.supportedElements = new ArrayList<>(participant.getParticipantSupportedElementTypes().size());
+
+        for (var elementEntry : participant.getParticipantSupportedElementTypes().entrySet()) {
+            var jpaParticipantSupportedElementType = new JpaParticipantSupportedElementType();
+            jpaParticipantSupportedElementType.setParticipantId(this.participantId);
+            jpaParticipantSupportedElementType.fromAuthorative(elementEntry.getValue());
+            this.supportedElements.add(jpaParticipantSupportedElementType);
+        }
     }
 
     @Override
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java
new file mode 100644 (file)
index 0000000..906f66f
--- /dev/null
@@ -0,0 +1,176 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.persistence.concepts;
+
+import java.util.UUID;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
+import org.onap.policy.common.parameters.annotations.NotNull;
+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
+    implements PfAuthorative<ParticipantSupportedElementType>, Comparable<JpaParticipantSupportedElementType> {
+
+    @NotNull
+    @Column
+    @Id
+    private String id;
+    @NotNull
+    @Column
+    private String participantId;
+
+    @NotNull
+    @Column
+    private String typeName;
+
+    @NotNull
+    @Column
+    private String typeVersion;
+
+    /**
+     * The default Constructor creates a {@link JpaParticipantSupportedElementType} with a generated id.
+     *
+     */
+    public JpaParticipantSupportedElementType() {
+        this(UUID.randomUUID().toString());
+    }
+
+    /**
+     * The Key Constructor creates a {@link JpaParticipantSupportedElementType} with just a generated id parameter.
+     *
+     * @param id the main id of the element type
+     */
+    public JpaParticipantSupportedElementType(@NonNull String id) {
+        this(id, UUID.randomUUID().toString());
+    }
+
+    /**
+     * The Key Constructor creates a {@link JpaParticipantSupportedElementType} with id and participantId.
+     *
+     * @param id the main id of the element type
+     * @param participantId the participant id
+     */
+    public JpaParticipantSupportedElementType(@NonNull String id, @NonNull String participantId) {
+        this(id, participantId, "", "");
+    }
+
+    /**
+     * The Key Constructor creates a {@link JpaParticipantSupportedElementType} object with all mandatory fields.
+     *
+     * @param id the main id of the element type
+     * @param participantId the participant id
+     * @param typeName the type name of the supported element
+     * @param typeVersion the type version of the supported element
+     */
+    public JpaParticipantSupportedElementType(@NonNull String id,
+                                              @NonNull String participantId,
+                                              @NonNull String typeName,
+                                              @NonNull String typeVersion) {
+        this.id = id;
+        this.participantId = participantId;
+        this.typeName = typeName;
+        this.typeVersion = typeVersion;
+    }
+
+    /**
+     * Copy constructor.
+     *
+     * @param copyConcept the concept to copy from
+     */
+    public JpaParticipantSupportedElementType(@NonNull final JpaParticipantSupportedElementType copyConcept) {
+        this.id = copyConcept.id;
+        this.participantId = copyConcept.participantId;
+        this.typeName = copyConcept.typeName;
+        this.typeVersion = copyConcept.typeVersion;
+    }
+
+    /**
+     * Authorative constructor.
+     *
+     * @param authorativeConcept the authorative concept to copy from
+     */
+    public JpaParticipantSupportedElementType(@NonNull final ParticipantSupportedElementType authorativeConcept) {
+        this.fromAuthorative(authorativeConcept);
+    }
+
+    @Override
+    public int compareTo(final JpaParticipantSupportedElementType other) {
+        if (other == null) {
+            return -1;
+        }
+        if (this == other) {
+            return 0;
+        }
+
+        var result = ObjectUtils.compare(participantId, other.participantId);
+        if (result != 0) {
+            return result;
+        }
+
+        result = ObjectUtils.compare(typeName, other.typeName);
+        if (result != 0) {
+            return result;
+        }
+
+        result = ObjectUtils.compare(id, other.id);
+        if (result != 0) {
+            return result;
+        }
+
+        result = typeVersion.compareTo(other.typeVersion);
+        if (result != 0) {
+            return result;
+        }
+
+        return 0;
+    }
+
+    @Override
+    public ParticipantSupportedElementType toAuthorative() {
+        var element = new ParticipantSupportedElementType();
+        element.setId(UUID.fromString(id));
+        element.setTypeName(typeName);
+        element.setTypeVersion(typeVersion);
+        return element;
+    }
+
+    @Override
+    public void fromAuthorative(@NonNull ParticipantSupportedElementType participantSupportedElementType) {
+        this.id = participantSupportedElementType.getId().toString();
+        this.typeName = participantSupportedElementType.getTypeName();
+        this.typeVersion = participantSupportedElementType.getTypeVersion();
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantsSupportedElementTypesTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantsSupportedElementTypesTest.java
new file mode 100644 (file)
index 0000000..fac9804
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.concepts;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+
+public class ParticipantsSupportedElementTypesTest {
+
+    private static final String ID = "a95757ba-b34a-4049-a2a8-46773abcbe5e";
+    private static final String PARTICIPANT_ID = "a78757co-b34a-8949-a2a8-46773abcbe2a";
+
+    @Test
+    void testParticipant() {
+
+        ParticipantSupportedElementType p0 = new ParticipantSupportedElementType();
+        p0.setId(UUID.fromString(ID));
+        assertEquals(ID, p0.getId().toString());
+
+        ParticipantSupportedElementType p1 = new ParticipantSupportedElementType(p0);
+
+        assertThat(p0).usingRecursiveComparison().isEqualTo(p1);
+    }
+
+    @Test
+    void testParticipantLombok() {
+        assertNotNull(new ParticipantSupportedElementType());
+        ParticipantSupportedElementType p0 = new ParticipantSupportedElementType();
+
+        assertThat(p0.toString()).contains("org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType");
+        assertThat(p0.hashCode()).isNotZero();
+        assertThat(p0).usingRecursiveComparison().isEqualTo(new ParticipantSupportedElementType(p0));
+        assertNotEquals(null, p0);
+
+
+        ParticipantSupportedElementType p1 = new ParticipantSupportedElementType();
+
+        p1.setId(UUID.fromString(ID));
+        p1.setTypeName("name");
+        p1.setTypeVersion("1.0.0");
+
+        assertThat(p1.toString()).contains("org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType");
+        assertNotEquals(0, p1.hashCode());
+        assertNotEquals(p1, p0);
+        assertNotEquals(null, p1);
+
+
+        ParticipantSupportedElementType p2 = new ParticipantSupportedElementType();
+        p2.setId(p0.getId());
+
+        assertThat(p0).usingRecursiveComparison().isEqualTo(p2);
+    }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java
new file mode 100644 (file)
index 0000000..2faf9e1
--- /dev/null
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * 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.persistence.concepts;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
+
+/**
+ * Test the {@link JpaParticipantSupportedElementType} class.
+ */
+public class JpaParticipantSupportedElementTypeTest {
+
+    private static final String NULL_PARTICIPANT_ID_ERROR = "participantId is marked .*ull but is null";
+    private static final String NULL_ID_ERROR = "id is marked .*ull but is null";
+    private static final String NULL_ERROR = " is marked .*ull but is null";
+    private static final String ID = "a95757ba-b34a-4049-a2a8-46773abcbe5e";
+    private static final String PARTICIPANT_ID = "a78757co-b34a-8949-a2a8-46773abcbe2a";
+
+    @Test
+    void testJpaAutomationCompositionElementConstructor() {
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType((JpaParticipantSupportedElementType) null);
+        }).hasMessageMatching("copyConcept is marked .*ull but is null");
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType("key", null);
+        }).hasMessageMatching(NULL_PARTICIPANT_ID_ERROR);
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType(null, "key");
+        }).hasMessageMatching(NULL_ID_ERROR);
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType(null, null);
+        }).hasMessageMatching(NULL_ID_ERROR);
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType(null, null, null, null);
+        }).hasMessageMatching(NULL_ID_ERROR);
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType("key", null, null, null);
+        }).hasMessageMatching(NULL_PARTICIPANT_ID_ERROR);
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType("key", "key", null, "1.0.0");
+        }).hasMessageMatching("typeName" + NULL_ERROR);
+
+        assertThatThrownBy(() -> {
+            new JpaParticipantSupportedElementType("key", "key", "name", null);
+        }).hasMessageMatching("typeVersion" + NULL_ERROR);
+
+        assertNotNull(new JpaParticipantSupportedElementType());
+        assertNotNull(new JpaParticipantSupportedElementType("key", "key"));
+        assertNotNull(new JpaParticipantSupportedElementType("key", "key", "name",
+            "1.0.0"));
+    }
+
+    @Test
+    void testJpaParticipantSupportedElementType() {
+        var testJpaSupportElement = createJpaParticipantSupportedElementType();
+
+        var testSupportedElement = createParticipantSupportedElementType();
+        assertEquals(testSupportedElement.getId(), testJpaSupportElement.toAuthorative().getId());
+        assertEquals(testSupportedElement.getTypeName(), testJpaSupportElement.toAuthorative().getTypeName());
+        assertEquals(testSupportedElement.getTypeVersion(), testJpaSupportElement.toAuthorative().getTypeVersion());
+
+        assertThatThrownBy(() -> {
+            testJpaSupportElement.fromAuthorative(null);
+        }).hasMessageMatching("participantSupportedElementType is marked .*ull but is null");
+
+        assertThatThrownBy(() -> new JpaParticipantSupportedElementType((JpaParticipantSupportedElementType) null))
+            .isInstanceOf(NullPointerException.class);
+
+        var testJpaSupportElementFa =
+            new JpaParticipantSupportedElementType(testSupportedElement.getId().toString(),
+                testJpaSupportElement.getParticipantId());
+        testJpaSupportElementFa.fromAuthorative(testSupportedElement);
+        assertEquals(testJpaSupportElement, testJpaSupportElementFa);
+
+        assertEquals(ID, testJpaSupportElement.getId());
+
+        var testJpaSupportElement2 = new JpaParticipantSupportedElementType(testJpaSupportElement);
+        assertEquals(testJpaSupportElement, testJpaSupportElement2);
+    }
+
+    @Test
+    void testJpaAutomationCompositionElementCompareTo() {
+        var testJpaSupportElement = createJpaParticipantSupportedElementType();
+
+        var otherJpaSupportElement =
+            new JpaParticipantSupportedElementType(testJpaSupportElement);
+        assertEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+        assertEquals(-1, testJpaSupportElement.compareTo(null));
+        assertEquals(0, testJpaSupportElement.compareTo(testJpaSupportElement));
+
+        testJpaSupportElement.setId("BadValue");
+        assertNotEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+        testJpaSupportElement.setId(ID);
+        assertEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+
+        testJpaSupportElement.setParticipantId("BadValue");
+        assertNotEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+        testJpaSupportElement.setParticipantId(PARTICIPANT_ID);
+        assertEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+
+        testJpaSupportElement.setTypeName("BadName");
+        assertNotEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+        testJpaSupportElement.setTypeName("type");
+        assertEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+
+        testJpaSupportElement.setTypeVersion("BadVersion");
+        assertNotEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+        testJpaSupportElement.setTypeVersion("1.0.0");
+        assertEquals(0, testJpaSupportElement.compareTo(otherJpaSupportElement));
+
+        assertEquals(testJpaSupportElement,
+            new JpaParticipantSupportedElementType(otherJpaSupportElement));
+    }
+
+    private JpaParticipantSupportedElementType createJpaParticipantSupportedElementType() {
+        var testSupportedElement = createParticipantSupportedElementType();
+        var testJpaSupportElement = new JpaParticipantSupportedElementType(testSupportedElement.getId().toString(),
+            PARTICIPANT_ID);
+
+        testJpaSupportElement.fromAuthorative(testSupportedElement);
+
+        return testJpaSupportElement;
+    }
+
+    private ParticipantSupportedElementType createParticipantSupportedElementType() {
+        var testSupportedElement = new ParticipantSupportedElementType();
+        testSupportedElement.setId(UUID.fromString(ID));
+        testSupportedElement.setTypeName("type");
+        testSupportedElement.setTypeVersion("1.0.0");
+
+        return testSupportedElement;
+    }
+}
index 0fbdaa2..b798fb0 100644 (file)
@@ -27,6 +27,9 @@ 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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.Participant;
@@ -48,54 +51,55 @@ class JpaParticipantTest {
 
         assertThatThrownBy(() -> new JpaParticipant((PfConceptKey) null)).hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, null, null)).hasMessageMatching(NULL_KEY_ERROR);
+        assertThatThrownBy(() -> new JpaParticipant(null, null, null, null, null)).hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, null, null))
+        assertThatThrownBy(() -> new JpaParticipant(null, null, null, null, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, null, ParticipantState.ON_LINE))
+        assertThatThrownBy(() -> new JpaParticipant(null, null, null, ParticipantState.ON_LINE, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
         assertThatThrownBy(
-            () -> new JpaParticipant(null, null, null, ParticipantState.ON_LINE))
+            () -> new JpaParticipant(null, null, null, ParticipantState.ON_LINE, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), null))
+        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), null, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), null))
+        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), null, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), ParticipantState.ON_LINE))
+        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), ParticipantState.ON_LINE, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), ParticipantState.ON_LINE))
+        assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), ParticipantState.ON_LINE, null))
             .hasMessageMatching(NULL_KEY_ERROR);
 
-        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, null))
+        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, null, null))
             .hasMessageMatching("definition is marked .*ull but is null");
 
-        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, null))
+        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, null, null))
             .hasMessageMatching("definition is marked .*ull but is null");
 
-        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, ParticipantState.ON_LINE))
+        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, ParticipantState.ON_LINE, null))
             .hasMessageMatching("definition is marked .*ull but is null");
 
-        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, ParticipantState.ON_LINE
+        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), null, ParticipantState.ON_LINE, null
         )).hasMessageMatching("definition is marked .*ull but is null");
 
-        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), null))
+        assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), null, null))
             .hasMessageMatching("participantState is marked .*ull but is null");
 
         assertThatThrownBy(
-            () -> new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), null))
+            () -> new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), null, null))
             .hasMessageMatching("participantState is marked .*ull but is null");
 
         assertNotNull(new JpaParticipant());
         assertNotNull(new JpaParticipant((new PfConceptKey())));
-        assertNotNull(new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), ParticipantState.ON_LINE));
+        assertNotNull(new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(),
+            ParticipantState.ON_LINE, new ArrayList<>()));
         assertNotNull(new JpaParticipant(UUID.randomUUID().toString(), new PfConceptKey(),
-            new PfConceptKey(), ParticipantState.ON_LINE));
+            new PfConceptKey(), ParticipantState.ON_LINE, new ArrayList<>()));
     }
 
     @Test
@@ -232,6 +236,7 @@ class JpaParticipantTest {
         testParticipant.setVersion("0.0.1");
         testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1"));
         testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1"));
+        testParticipant.setParticipantSupportedElementTypes(new LinkedHashMap<>());
 
         return testParticipant;
     }
index ccb20ea..325272b 100644 (file)
@@ -22,7 +22,6 @@ package org.onap.policy.clamp.models.acm.persistence.provider;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -74,7 +73,8 @@ class ParticipantProviderTest {
 
         Participant savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0));
         savedParticipant.setParticipantId(inputParticipants.get(0).getParticipantId());
-        assertEquals(savedParticipant, inputParticipants.get(0));
+
+        assertThat(savedParticipant).usingRecursiveComparison().isEqualTo(inputParticipants.get(0));
     }
 
     @Test
@@ -93,7 +93,7 @@ class ParticipantProviderTest {
 
         Participant updatedParticipant = participantProvider.updateParticipant(inputParticipants.get(0));
         updatedParticipant.setParticipantId(inputParticipants.get(0).getParticipantId());
-        assertEquals(updatedParticipant, inputParticipants.get(0));
+        assertThat(updatedParticipant).usingRecursiveComparison().isEqualTo(inputParticipants.get(0));
     }
 
     @Test
@@ -112,7 +112,7 @@ class ParticipantProviderTest {
         var participant = participantProvider.getParticipantById(inputParticipants.get(0)
             .getParticipantId());
 
-        assertThat(participant).isEqualTo(inputParticipants.get(0));
+        assertThat(inputParticipants.get(0)).usingRecursiveComparison().isEqualTo(participant);
     }
 
     @Test
@@ -127,7 +127,8 @@ class ParticipantProviderTest {
         when(participantRepository.findByParticipantId(participantId.toString()))
             .thenReturn(Optional.of(jpaParticipantList.get(0)));
 
-        var deletedParticipant = participantProvider.deleteParticipant(participantId);
-        assertEquals(inputParticipants.get(0), deletedParticipant);
+        Participant deletedParticipant =
+            participantProvider.deleteParticipant(participantId);
+        assertThat(inputParticipants.get(0)).usingRecursiveComparison().isEqualTo(deletedParticipant);
     }
 }
index 99284cb..2f4f910 100644 (file)
   "participantType":{
     "name": "org.onap.domain.pmsh.PolicyAutomationCompositionDefinition",
     "version": "1.0.0"
+  },
+  "participantSupportedElementTypes": {
+    "68fe8c61-7629-4be7-99d8-18bc6a92d178": {
+      "id": "68fe8c61-7629-4be7-99d8-18bc6a92d178",
+      "participantId": "82fd8ef9-1d1e-4343-9b28-7f9564ee3de6",
+      "typeName": "org.onap.policy.clamp.acm.PolicyAutomationCompositionElement",
+      "typeVersion": "1.0.0"
+    },
+    "e2429b9d-7195-4690-a5ea-8ccebff19a14": {
+      "id": "e2429b9d-7195-4690-a5ea-8ccebff19a14",
+      "participantId": "82fd8ef9-1d1e-4343-9b28-7f9564ee3de6",
+      "typeName": "org.onap.policy.clamp.acm.AutomationCompositionElement",
+      "typeVersion": "1.0.0"
+    }
   }
 }
index be33b52..867357e 100755 (executable)
@@ -21,4 +21,11 @@ participant:
           topicCommInfrastructure: dmaap
           servers:
             - localhost
-          topic: POLICY-ACRUNTIME-PARTICIPANT
\ No newline at end of file
+          topic: POLICY-ACRUNTIME-PARTICIPANT
+    participantSupportedElementTypes:
+      -
+        typeName: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+        typeVersion: 1.0.0
+      -
+        typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+        typeVersion: 1.0.0
index 44cdf95..1f60ffc 100644 (file)
@@ -34,6 +34,13 @@ participant:
           servers:
             - ${topicServer:localhost}
           topicCommInfrastructure: dmaap
+    participantSupportedElementTypes:
+      -
+        typeName: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+        typeVersion: 1.0.0
+      -
+        typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+        typeVersion: 1.0.0
 management:
   endpoints:
     web:
index 535508e..1effd4e 100644 (file)
@@ -22,3 +22,8 @@ participant:
           servers:
             - localhost
           topic: POLICY-ACRUNTIME-PARTICIPANT
+      participantSupportedElementTypes:
+        - typeName: org.onap.policy.clamp.acm.HttpAutomationCompositionElement
+          typeVersion: 1.0.0
+        - typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+          typeVersion: 1.0.0
index 0158c2c..a906cb6 100644 (file)
@@ -30,15 +30,22 @@ participant:
         -
           topic: POLICY-ACRUNTIME-PARTICIPANT
           servers:
-            - ${topicServer:localhost}
+            - ${topicServer:localhost:30227}
           topicCommInfrastructure: dmaap
           fetchTimeout: 15000
       topicSinks:
         -
           topic: POLICY-ACRUNTIME-PARTICIPANT
           servers:
-            - ${topicServer:localhost}
+            - ${topicServer:localhost:30227}
           topicCommInfrastructure: dmaap
+    participantSupportedElementTypes:
+      -
+        typeName: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
+        typeVersion: 1.0.0
+      -
+        typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+        typeVersion: 1.0.0
 
 management:
   endpoints:
index 97d2fbb..8a9619d 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
 
 package org.onap.policy.clamp.acm.participant.kubernetes.parameters;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -105,6 +106,7 @@ public class CommonTestData {
             map.put("participantId", getParticipantId());
             map.put("participantType", getParticipantId());
             map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
+            map.put("participantSupportedElementTypes", new ArrayList<>());
         }
 
         return map;
index cd36f61..7fc7928 100644 (file)
@@ -29,3 +29,10 @@ participant:
             - localhost
           topicCommInfrastructure: dmaap
       name: AutomationComposition Topics
+    participantSupportedElementTypes:
+      -
+        typeName: org.onap.policy.clamp.acm.K8SMicroserviceAutomationCompositionElement
+        typeVersion: 1.0.0
+      -
+        typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+        typeVersion: 1.0.0
index 383bc74..d5eae73 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
   ============LICENSE_START=======================================================
-   Copyright (C) 2021 Nordix Foundation.
+   Copyright (C) 2021-2023 Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
         <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate</class>
         <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
         <class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</class>
-        <class>org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaAutomationComposition</class>
-        <class>org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaAutomationCompositionElement</class>
-        <class>org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaParticipant</class>
-        <class>org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaParticipantStatistics</class>
-        <class>org.onap.policy.clamp.acm.models.acm.persistence.concepts.JpaAcElementStatistics</class>
+        <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition</class>
+        <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionElement</class>
+        <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant</class>
+        <class>org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipantSupportedElementType</class>
         <properties>
             <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
             <property name="eclipselink.ddl-generation.output-mode" value="database" />
index a1fea4d..6af516e 100644 (file)
@@ -52,6 +52,13 @@ participant:
           servers:
             - ${topicServer:localhost}
           topicCommInfrastructure: dmaap
+    participantSupportedElementTypes:
+      -
+        typeName: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement
+        typeVersion: 1.0.0
+      -
+        typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+        typeVersion: 1.0.0
 management:
   endpoints:
     web:
@@ -62,3 +69,4 @@ server:
   port: 8085
   servlet:
     context-path: /onap/policy/clamp/acm/policyparticipant
+
index ac64512..bfba155 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.clamp.acm.participant.policy.main.parameters;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
@@ -123,6 +124,7 @@ public class CommonTestData {
             map.put("participantId", getParticipantId());
             map.put("participantType", getParticipantId());
             map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
+            map.put("participantSupportedElementTypes", new ArrayList<>());
         }
 
         return map;
index 13ef55f..434df0d 100644 (file)
@@ -22,3 +22,10 @@ participant:
           servers:
             - localhost
           topic: POLICY-ACRUNTIME-PARTICIPANT
+    participantSupportedElementTypes:
+      -
+        typeName: org.onap.policy.clamp.acm.PolicyAutomationCompositionElement
+        typeVersion: 1.0.0
+      -
+        typeName: org.onap.policy.clamp.acm.AutomationCompositionElement
+        typeVersion: 1.0.0
index 11f2778..9023d94 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -72,7 +72,7 @@ public class ParticipantMessagePublisher implements Publisher {
     public void sendParticipantStatus(final ParticipantStatus participantStatus) {
         validate();
         topicSinkClient.send(participantStatus);
-        LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus);
+        LOGGER.info("Sent Participant Status message to CLAMP - {}", participantStatus);
     }
 
     /**
@@ -84,7 +84,7 @@ public class ParticipantMessagePublisher implements Publisher {
     public void sendParticipantRegister(final ParticipantRegister participantRegister) {
         validate();
         topicSinkClient.send(participantRegister);
-        LOGGER.debug("Sent Participant Register message to CLAMP - {}", participantRegister);
+        LOGGER.info("Sent Participant Register message to CLAMP - {}", participantRegister);
     }
 
     /**
index 6edf1ff..f9023be 100644 (file)
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDef
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantAckMessage;
@@ -70,6 +71,8 @@ public class ParticipantHandler {
 
     private final Map<UUID, List<AutomationCompositionElementDefinition>> acElementDefsMap = new HashMap<>();
 
+    private final List<ParticipantSupportedElementType> supportedAcElementTypes;
+
     /**
      * Constructor, set the participant ID and sender.
      *
@@ -82,6 +85,7 @@ public class ParticipantHandler {
         this.participantId = parameters.getIntermediaryParameters().getParticipantId();
         this.publisher = publisher;
         this.automationCompositionHandler = automationCompositionHandler;
+        this.supportedAcElementTypes = parameters.getIntermediaryParameters().getParticipantSupportedElementTypes();
     }
 
     /**
@@ -92,6 +96,7 @@ public class ParticipantHandler {
     @Timed(value = "listener.participant_status_req", description = "PARTICIPANT_STATUS_REQ messages received")
     public void handleParticipantStatusReq(final ParticipantStatusReq participantStatusReqMsg) {
         var participantStatus = makeHeartbeat(true);
+        participantStatus.setParticipantSupportedElementType(this.supportedAcElementTypes);
         publisher.sendParticipantStatus(participantStatus);
     }
 
@@ -148,6 +153,7 @@ public class ParticipantHandler {
         var participantRegister = new ParticipantRegister();
         participantRegister.setParticipantId(participantId);
         participantRegister.setParticipantType(participantType);
+        participantRegister.setParticipantSupportedElementType(supportedAcElementTypes);
 
         publisher.sendParticipantRegister(participantRegister);
     }
index dcbfd1b..9530848 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * 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.clamp.acm.participant.intermediary.parameters;
 
+import java.util.List;
 import javax.validation.Valid;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Positive;
 import lombok.Getter;
 import lombok.Setter;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
 import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
 import org.onap.policy.common.parameters.validation.ParameterGroupConstraint;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -58,4 +60,9 @@ public class ParticipantIntermediaryParameters {
     @NotNull
     @ParameterGroupConstraint
     private TopicParameterGroup clampAutomationCompositionTopics;
+
+    @NotNull
+    @Valid
+    private List<ParticipantSupportedElementType> participantSupportedElementTypes;
+
 }
index 10c438f..0e35c48 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,9 @@
 package org.onap.policy.clamp.acm.participant.intermediary.main.parameters;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -111,6 +113,7 @@ public class CommonTestData {
         map.put("participantType", getParticipantId());
         map.put("reportingTimeIntervalMs", TIME_INTERVAL);
         map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
+        map.put("participantSupportedElementTypes", new ArrayList<>());
 
         return map;
     }
index 2c9e84b..6f0f5cc 100644 (file)
 package org.onap.policy.clamp.acm.runtime.supervision;
 
 import io.micrometer.core.annotation.Timed;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import lombok.AllArgsConstructor;
+import org.apache.commons.collections4.MapUtils;
 import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantDeregisterAckPublisher;
 import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantRegisterAckPublisher;
 import org.onap.policy.clamp.models.acm.concepts.Participant;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantSupportedElementType;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregister;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage;
 import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister;
@@ -98,11 +104,14 @@ public class SupervisionParticipantHandler {
         var participantOpt = participantProvider.findParticipant(participantMessage.getParticipantId());
 
         if (participantOpt.isEmpty()) {
+            ParticipantRegister registerMessage = (ParticipantRegister) participantMessage;
             var participant = new Participant();
-            participant.setName(participantMessage.getParticipantId().getName());
-            participant.setVersion(participantMessage.getParticipantId().getVersion());
-            participant.setDefinition(participantMessage.getParticipantId());
-            participant.setParticipantType(participantMessage.getParticipantType());
+            participant.setName(registerMessage.getParticipantId().getName());
+            participant.setVersion(registerMessage.getParticipantId().getVersion());
+            participant.setDefinition(registerMessage.getParticipantId());
+            participant.setParticipantType(registerMessage.getParticipantType());
+            participant.setParticipantSupportedElementTypes(listToMap(registerMessage
+                .getParticipantSupportedElementType()));
             participant.setParticipantState(ParticipantState.ON_LINE);
 
             participantProvider.saveParticipant(participant);
@@ -113,4 +122,10 @@ public class SupervisionParticipantHandler {
             participantProvider.updateParticipant(participant);
         }
     }
+
+    private Map<UUID, ParticipantSupportedElementType> listToMap(List<ParticipantSupportedElementType> elementList) {
+        Map<UUID, ParticipantSupportedElementType> map = new HashMap<>();
+        MapUtils.populateMap(map, elementList, ParticipantSupportedElementType::getId);
+        return map;
+    }
 }
index f7c18b6..05e356b 100644 (file)
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import java.util.ArrayList;
 import java.util.Optional;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
@@ -82,6 +83,7 @@ class SupervisionParticipantHandlerTest {
         var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
         var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
             mock(ParticipantDeregisterAckPublisher.class));
+        participantRegisterMessage.setParticipantSupportedElementType(new ArrayList<>());
 
         handler.handleParticipantMessage(participantRegisterMessage);
 
@@ -96,12 +98,15 @@ class SupervisionParticipantHandlerTest {
         participantStatusMessage.setParticipantId(PARTICIPANT_ID);
         participantStatusMessage.setParticipantType(PARTICIPANT_TYPE);
         participantStatusMessage.setState(ParticipantState.ON_LINE);
+        participantStatusMessage.setParticipantSupportedElementType(new ArrayList<>());
 
         var participantProvider = mock(ParticipantProvider.class);
         var handler = new SupervisionParticipantHandler(participantProvider,
             mock(ParticipantRegisterAckPublisher.class), mock(ParticipantDeregisterAckPublisher.class));
+        var participant = new Participant();
+        when(participantProvider.findParticipant(PARTICIPANT_ID)).thenReturn(Optional.of(participant));
         handler.handleParticipantMessage(participantStatusMessage);
 
-        verify(participantProvider).saveParticipant(any());
+        verify(participantProvider).updateParticipant(any());
     }
 }