summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2023-01-13 17:24:23 +0000
committersaul.gill <saul.gill@est.tech>2023-01-19 13:07:33 +0000
commit46964ab900060a560b9b41f7d34ab0e26ac7fd61 (patch)
treed4d15350f492cc19ee657df6cb926349bd724919
parent48df549e1fd90c2768a78c0c88e87dc3834b6222 (diff)
Add supported ac elements to participants
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>
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java55
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java7
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java34
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java176
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantsSupportedElementTypesTest.java76
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java163
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java37
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java13
-rw-r--r--models/src/test/resources/providers/TestParticipant.json14
-rwxr-xr-xparticipant/participant-impl/participant-impl-a1pms/src/test/resources/application-test.yaml9
-rw-r--r--participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml7
-rw-r--r--participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml5
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml11
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java4
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml7
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml11
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml8
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java4
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml7
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java6
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java9
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java5
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java23
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java7
29 files changed, 668 insertions, 48 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
index c6da3c3d1..56c01837f 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/Participant.java
@@ -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();
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
index c2f61aa74..a6a65fec5 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantInformation.java
@@ -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
index 000000000..310577167
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantSupportedElementType.java
@@ -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();
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
index 8b33d3172..c6d56904d 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessage.java
@@ -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.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
index 7b315dbe0..d8f9a4caf 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegister.java
@@ -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.
@@ -20,9 +20,11 @@
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();
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
index 31a42c548..2412bddcb 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatus.java
@@ -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();
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
index 398daa245..7d043ace0 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipant.java
@@ -21,14 +21,21 @@
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
index 000000000..906f66fa9
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementType.java
@@ -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
index 000000000..fac98043d
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantsSupportedElementTypesTest.java
@@ -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
index 000000000..2faf9e17a
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java
@@ -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;
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
index 0fbdaa2bc..b798fb093 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
@@ -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;
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
index ccb20ea8e..325272b69 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/ParticipantProviderTest.java
@@ -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);
}
}
diff --git a/models/src/test/resources/providers/TestParticipant.json b/models/src/test/resources/providers/TestParticipant.json
index 99284cb6a..2f4f910f1 100644
--- a/models/src/test/resources/providers/TestParticipant.json
+++ b/models/src/test/resources/providers/TestParticipant.json
@@ -11,5 +11,19 @@
"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"
+ }
}
}
diff --git a/participant/participant-impl/participant-impl-a1pms/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-a1pms/src/test/resources/application-test.yaml
index be33b5249..867357e93 100755
--- a/participant/participant-impl/participant-impl-a1pms/src/test/resources/application-test.yaml
+++ b/participant/participant-impl/participant-impl-a1pms/src/test/resources/application-test.yaml
@@ -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
diff --git a/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml
index 44cdf95a6..1f60ffc97 100644
--- a/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-http/src/main/resources/config/application.yaml
@@ -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:
diff --git a/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml
index 535508e2a..1effd4e4c 100644
--- a/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml
+++ b/participant/participant-impl/participant-impl-http/src/test/resources/application-test.yaml
@@ -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
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
index 0158c2c63..a906cb6fa 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
@@ -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:
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
index 97d2fbbd2..8a9619dce 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/parameters/CommonTestData.java
@@ -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;
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
index cd36f61e7..7fc792878 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/application-test.yaml
@@ -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
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
index 383bc7418..d5eae7390 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/META-INF/persistence.xml
@@ -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.
@@ -52,11 +52,10 @@
<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" />
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
index a1fea4d1b..6af516e71 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
@@ -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
+
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
index ac6451260..bfba15551 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/parameters/CommonTestData.java
@@ -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;
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml b/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml
index 13ef55f10..434df0dfe 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/application-test.yaml
@@ -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
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java
index 11f277885..9023d9460 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/comm/ParticipantMessagePublisher.java
@@ -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);
}
/**
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
index 6edf1ffd4..f9023be1a 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java
@@ -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);
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
index dcbfd1b2e..953084890 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/parameters/ParticipantIntermediaryParameters.java
@@ -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.
@@ -20,12 +20,14 @@
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;
+
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index 10c438f93..0e35c480b 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -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;
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
index 2c9e84ba7..6f0f5cc7b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -21,11 +21,17 @@
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;
+ }
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
index f7c18b67b..05e356b55 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -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());
}
}