package org.onap.policy.clamp.models.acm.concepts;
+import java.util.Map;
import java.util.UUID;
import lombok.Data;
import lombok.EqualsAndHashCode;
@NonNull
private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
+ @NonNull
+ private Map<UUID, ParticipantSupportedElementType> participantSupportedElementTypes;
+
@Override
public String getType() {
return definition.getName();
/*-
* ============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.
--- /dev/null
+/*-
+ * ============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();
+ }
+}
/*-
* ============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.
/*-
* ============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.
@ToString(callSuper = true)
public class ParticipantRegister extends ParticipantMessage {
+ private List<ParticipantSupportedElementType> participantSupportedElementType;
+
/**
* Constructor for instantiating ParticipantRegister class with message name.
*
*/
public ParticipantRegister(final ParticipantRegister source) {
super(source);
+ this.participantSupportedElementType = source.getParticipantSupportedElementType();
}
}
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;
/**
// 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);
}
PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
this.automationCompositionInfoList =
PfUtils.mapList(source.automationCompositionInfoList, AutomationCompositionInfo::new);
+ this.participantSupportedElementType = source.getParticipantSupportedElementType();
}
}
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;
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;
@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.
*/
* @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<>());
}
/**
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;
}
/**
this.description = copyConcept.description;
this.participantType = copyConcept.participantType;
this.participantId = copyConcept.participantId;
+ this.supportedElements = copyConcept.supportedElements;
}
/**
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;
}
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
--- /dev/null
+/*-
+ * ============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();
+ }
+}
--- /dev/null
+/*-
+ * ============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);
+ }
+}
--- /dev/null
+/*-
+ * ============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;
+ }
+}
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;
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
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;
}
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;
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
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
var participant = participantProvider.getParticipantById(inputParticipants.get(0)
.getParticipantId());
- assertThat(participant).isEqualTo(inputParticipants.get(0));
+ assertThat(inputParticipants.get(0)).usingRecursiveComparison().isEqualTo(participant);
}
@Test
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);
}
}
"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"
+ }
}
}
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
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:
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
-
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:
/*-
* ============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");
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;
map.put("participantId", getParticipantId());
map.put("participantType", getParticipantId());
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
+ map.put("participantSupportedElementTypes", new ArrayList<>());
}
return map;
- 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
<?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" />
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:
port: 8085
servlet:
context-path: /onap/policy/clamp/acm/policyparticipant
+
/*-
* ============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.
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;
map.put("participantId", getParticipantId());
map.put("participantType", getParticipantId());
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
+ map.put("participantSupportedElementTypes", new ArrayList<>());
}
return map;
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
/*-
* ============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");
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);
}
/**
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);
}
/**
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;
private final Map<UUID, List<AutomationCompositionElementDefinition>> acElementDefsMap = new HashMap<>();
+ private final List<ParticipantSupportedElementType> supportedAcElementTypes;
+
/**
* Constructor, set the participant ID and sender.
*
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.publisher = publisher;
this.automationCompositionHandler = automationCompositionHandler;
+ this.supportedAcElementTypes = parameters.getIntermediaryParameters().getParticipantSupportedElementTypes();
}
/**
@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);
}
var participantRegister = new ParticipantRegister();
participantRegister.setParticipantId(participantId);
participantRegister.setParticipantType(participantType);
+ participantRegister.setParticipantSupportedElementType(supportedAcElementTypes);
publisher.sendParticipantRegister(participantRegister);
}
/*-
* ============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;
@NotNull
@ParameterGroupConstraint
private TopicParameterGroup clampAutomationCompositionTopics;
+
+ @NotNull
+ @Valid
+ private List<ParticipantSupportedElementType> participantSupportedElementTypes;
+
}
/*-
* ============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.
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;
map.put("participantType", getParticipantId());
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
+ map.put("participantSupportedElementTypes", new ArrayList<>());
return map;
}
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;
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);
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;
+ }
}
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;
var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
mock(ParticipantDeregisterAckPublisher.class));
+ participantRegisterMessage.setParticipantSupportedElementType(new ArrayList<>());
handler.handleParticipantMessage(participantRegisterMessage);
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());
}
}