As part of endpoint refactoring, refactor participantId as UUID in ACM.
Issue-ID: POLICY-4521
Change-Id: I8ac652d9b2fadf9ce3220febb9c2c3ac0d3786cc
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
- private ToscaConceptIdentifier participantId = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
+ private UUID participantId = UUID.randomUUID();
@NonNull
private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED;
this.id = otherElement.id;
this.definition = new ToscaConceptIdentifier(otherElement.definition);
this.participantType = new ToscaConceptIdentifier(otherElement.participantType);
- this.participantId = new ToscaConceptIdentifier(otherElement.participantId);
+ this.participantId = otherElement.participantId;
this.state = otherElement.state;
this.orderedState = otherElement.orderedState;
this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
-import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
/**
* Class to represent details of a running participant instance.
*/
@NoArgsConstructor
@Data
-@EqualsAndHashCode(callSuper = true)
-public class Participant extends ToscaEntity implements Comparable<Participant> {
+@EqualsAndHashCode
+public class Participant {
@NonNull
private UUID participantId;
- @NonNull
- private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
@NonNull
private ParticipantState participantState = ParticipantState.ON_LINE;
@NonNull
private Map<UUID, ParticipantSupportedElementType> participantSupportedElementTypes;
- @Override
- public String getType() {
- return definition.getName();
- }
-
- @Override
- public String getTypeVersion() {
- return definition.getVersion();
- }
-
- @Override
- public int compareTo(final Participant other) {
- return compareNameVersion(this, other);
- }
-
/**
* Copy constructor.
*
* @param otherParticipant the participant to copy from
*/
public Participant(Participant otherParticipant) {
- super(otherParticipant);
- this.definition = new ToscaConceptIdentifier(otherParticipant.definition);
this.participantState = otherParticipant.participantState;
this.participantType = otherParticipant.participantType;
this.participantId = otherParticipant.participantId;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ToString
public class ParticipantDefinition {
- private ToscaConceptIdentifier participantId;
+ private UUID participantId;
private ToscaConceptIdentifier participantType;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent a participant definition update instance.
@ToString
public class ParticipantUpdates {
- private ToscaConceptIdentifier participantId;
+ private UUID participantId;
// List of AutomationCompositionElement values for a particular participant
private List<AutomationCompositionElement> automationCompositionElementList = new ArrayList<>();
/**
* Participant ID, or {@code null} for messages from participants.
*/
- private ToscaConceptIdentifier participantId;
+ private UUID participantId;
/**
* Participant State, or {@code null} for messages from participants.
* @return {@code true} if this message applies to this participant, {@code false} otherwise
*/
public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType,
- @NonNull final ToscaConceptIdentifier participantId) {
+ @NonNull final UUID participantId) {
// Broadcast message to all participants
if (this.participantType == null) {
return true;
/**
* Participant ID, or {@code null} for messages from participants.
*/
- private ToscaConceptIdentifier participantId;
+ private UUID participantId;
/**
* Automation Composition ID, or {@code null} for messages to participants.
* @return {@code true} if this message applies to this participant, {@code false} otherwise
*/
public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType,
- @NonNull final ToscaConceptIdentifier participantId) {
+ @NonNull final UUID participantId) {
// Broadcast message to all participants
if (this.participantType == null) {
return true;
@AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
private PfConceptKey participantType;
+ @Column
@NotNull
- @AttributeOverride(name = "name", column = @Column(name = "participant_name"))
- @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
- private PfConceptKey participantId;
- // @formatter:on
+ private String participantId;
@Column
@NotNull
this.instanceId = copyConcept.instanceId;
this.definition = new PfConceptKey(copyConcept.definition);
this.participantType = new PfConceptKey(copyConcept.participantType);
- this.participantId = new PfConceptKey(copyConcept.participantId);
+ this.participantId = copyConcept.participantId;
this.state = copyConcept.state;
this.orderedState = copyConcept.orderedState;
this.description = copyConcept.description;
element.setId(UUID.fromString(elementId));
element.setDefinition(new ToscaConceptIdentifier(definition));
element.setParticipantType(new ToscaConceptIdentifier(participantType));
- element.setParticipantId(new ToscaConceptIdentifier(participantId));
+ element.setParticipantId(UUID.fromString(participantId));
element.setState(state);
element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
element.setDescription(description);
public void fromAuthorative(@NonNull final AutomationCompositionElement element) {
this.definition = element.getDefinition().asConceptKey();
this.participantType = element.getParticipantType().asConceptKey();
- this.participantId = element.getParticipantId().asConceptKey();
+ this.participantId = element.getParticipantId().toString();
this.state = element.getState();
this.orderedState = element.getOrderedState();
this.description = element.getDescription();
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.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
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;
-import org.onap.policy.models.base.PfKey;
-import org.onap.policy.models.base.validation.annotations.VerifyKey;
+import org.onap.policy.models.base.Validated;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Data
@EqualsAndHashCode(callSuper = false)
-public class JpaParticipant extends PfConcept implements PfAuthorative<Participant>, Serializable {
+public class JpaParticipant extends Validated
+ implements PfAuthorative<Participant>, Comparable<JpaParticipant>, Serializable {
private static final long serialVersionUID = -4697758484642403483L;
- @Column
+ @Id
@NotNull
private String participantId;
- @EmbeddedId
- @VerifyKey
- @NotNull
- private PfConceptKey key;
-
- // @formatter:off
- @VerifyKey
@NotNull
- @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
- @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
- private PfConceptKey definition;
- // @formatter:on
-
- @NotNull
- @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
+ @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
@AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
private PfConceptKey participantType;
* The Default Constructor creates a {@link JpaParticipant} object with a null key.
*/
public JpaParticipant() {
- this(new PfConceptKey());
- }
-
- /**
- * The Key Constructor creates a {@link JpaParticipant} object with the given concept key.
- *
- * @param key the key
- */
- public JpaParticipant(@NonNull final PfConceptKey key) {
- this(UUID.randomUUID().toString(), key, new PfConceptKey(), ParticipantState.ON_LINE, new ArrayList<>());
+ this(UUID.randomUUID().toString(), ParticipantState.ON_LINE, new ArrayList<>());
}
/**
* The Key Constructor creates a {@link JpaParticipant} object with all mandatory fields.
*
* @param participantId the participant id
- * @param key the key
- * @param definition the TOSCA definition of the participant
* @param participantState the state of the participant
*/
- public JpaParticipant(@NotNull String participantId,
- @NonNull final PfConceptKey key,
- @NonNull final PfConceptKey definition,
- @NonNull final ParticipantState participantState,
- @NonNull final List<JpaParticipantSupportedElementType> supportedAcElementTypes) {
- this.key = key;
- this.definition = definition;
- this.participantState = participantState;
+ public JpaParticipant(@NonNull String participantId, @NonNull final ParticipantState participantState,
+ @NonNull final List<JpaParticipantSupportedElementType> supportedElements) {
this.participantId = participantId;
- this.supportedElements = supportedAcElementTypes;
+ this.participantState = participantState;
+ this.supportedElements = supportedElements;
}
/**
* @param copyConcept the concept to copy from
*/
public JpaParticipant(@NonNull final JpaParticipant copyConcept) {
- super(copyConcept);
- this.key = new PfConceptKey(copyConcept.key);
- this.definition = new PfConceptKey(copyConcept.definition);
this.participantState = copyConcept.participantState;
this.description = copyConcept.description;
this.participantType = copyConcept.participantType;
public Participant toAuthorative() {
var participant = new Participant();
- participant.setName(key.getName());
- participant.setVersion(key.getVersion());
- participant.setDefinition(new ToscaConceptIdentifier(definition));
participant.setParticipantState(participantState);
- participant.setDescription(description);
participant.setParticipantType(new ToscaConceptIdentifier(participantType));
participant.setParticipantId(UUID.fromString(participantId));
participant.setParticipantSupportedElementTypes(new LinkedHashMap<>(this.supportedElements.size()));
@Override
public void fromAuthorative(@NonNull final Participant participant) {
- if (this.key == null || this.getKey().isNullKey()) {
- this.setKey(new PfConceptKey(participant.getName(), participant.getVersion()));
- }
-
- this.definition = participant.getDefinition().asConceptKey();
this.setParticipantState(participant.getParticipantState());
- this.setDescription(participant.getDescription());
this.participantType = participant.getParticipantType().asConceptKey();
this.participantId = participant.getParticipantId().toString();
this.supportedElements = new ArrayList<>(participant.getParticipantSupportedElementTypes().size());
}
@Override
- public List<PfKey> getKeys() {
- List<PfKey> keyList = getKey().getKeys();
-
- keyList.add(definition);
- keyList.add(participantType);
-
- return keyList;
- }
-
- @Override
- public void clean() {
- key.clean();
- definition.clean();
- description = (description == null ? null : description.trim());
- participantType.clean();
- }
-
- @Override
- public int compareTo(final PfConcept otherConcept) {
- if (otherConcept == null) {
+ public int compareTo(final JpaParticipant other) {
+ if (other == null) {
return -1;
}
- if (this == otherConcept) {
+ if (this == other) {
return 0;
}
- if (getClass() != otherConcept.getClass()) {
- return getClass().getName().compareTo(otherConcept.getClass().getName());
- }
-
- final JpaParticipant other = (JpaParticipant) otherConcept;
- int result = key.compareTo(other.key);
- if (result != 0) {
- return result;
- }
- result = definition.compareTo(other.definition);
+ var result = participantId.compareTo(other.participantId);
if (result != 0) {
return result;
}
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant;
import org.onap.policy.clamp.models.acm.persistence.repository.ParticipantRepository;
-import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
*
* @param participantId the id of the participant to get
* @return the participant found
- * @throws PfModelException on errors getting participant
*/
@Transactional(readOnly = true)
public Participant getParticipantById(UUID participantId) {
- var participant = participantRepository.findByParticipantId(participantId.toString());
+ var participant = participantRepository.findById(participantId.toString());
if (participant.isEmpty()) {
throw new PfModelRuntimeException(Status.NOT_FOUND,
"Participant Not Found with ID: " + participantId);
* @return the participant found
*/
@Transactional(readOnly = true)
- public Optional<Participant> findParticipant(@NonNull final ToscaConceptIdentifier participantId) {
- return participantRepository.findById(participantId.asConceptKey()).map(JpaParticipant::toAuthorative);
+ public Optional<Participant> findParticipant(@NonNull final UUID participantId) {
+ return participantRepository.findById(participantId.toString()).map(JpaParticipant::toAuthorative);
}
/**
* @return the participant created
*/
public Participant saveParticipant(@NonNull final Participant participant) {
- participant.setParticipantId(UUID.randomUUID());
var result = participantRepository
.save(ProviderUtils.getJpaAndValidate(participant, JpaParticipant::new, "participant"));
* @return the participant deleted
*/
public Participant deleteParticipant(@NonNull final UUID participantId) {
- var jpaDeleteParticipantOpt = participantRepository.findByParticipantId(participantId.toString());
+ var jpaDeleteParticipantOpt = participantRepository.findById(participantId.toString());
if (jpaDeleteParticipantOpt.isEmpty()) {
String errorMessage =
package org.onap.policy.clamp.models.acm.persistence.repository;
-import java.util.Optional;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaParticipant;
-import org.onap.policy.models.base.PfConceptKey;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface ParticipantRepository extends JpaRepository<JpaParticipant, PfConceptKey> {
+public interface ParticipantRepository extends JpaRepository<JpaParticipant, String> {
- Optional<JpaParticipant> findByParticipantId(String participantId);
}
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
class ParticipantTest {
- @Test
- void testParticipant() {
-
- Participant p0 = new Participant();
- p0.setDefinition(new ToscaConceptIdentifier("dfName", "1.2.3"));
- assertEquals("dfName", p0.getType());
- assertEquals("1.2.3", p0.getTypeVersion());
-
- Participant p1 = new Participant(p0);
- assertEquals(p0, p1);
-
- assertEquals(0, p0.compareTo(p1));
- }
@Test
void testParticipantLombok() {
Participant p1 = new Participant();
- p1.setDefinition(new ToscaConceptIdentifier("defName", "0.0.1"));
- p1.setDescription("Description");
- p1.setName("Name");
+ p1.setParticipantId(CommonTestData.getParticipantId());
p1.setParticipantState(ParticipantState.ON_LINE);
- p1.setVersion("0.0.1");
assertThat(p1.toString()).contains("Participant(");
assertNotEquals(0, p1.hashCode());
Participant p2 = new Participant();
// @formatter:off
- assertThatThrownBy(() -> p2.setDefinition(null)). isInstanceOf(NullPointerException.class);
assertThatThrownBy(() -> p2.setParticipantState(null)).isInstanceOf(NullPointerException.class);
// @formatter:on
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;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
-import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
*/
class JpaParticipantTest {
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+ private static final String NULL_KEY_ERROR = "participantId is marked .*ull but is null";
@Test
void testJpaParticipantConstructor() {
assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null))
.hasMessageMatching("copyConcept is marked .*ull but is null");
- assertThatThrownBy(() -> new JpaParticipant((PfConceptKey) null)).hasMessageMatching(NULL_KEY_ERROR);
+ assertThatThrownBy(() -> new JpaParticipant(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, null))
- .hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> new JpaParticipant(null, null, null, ParticipantState.ON_LINE, null))
- .hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(
- () -> new JpaParticipant(null, null, null, ParticipantState.ON_LINE, null))
- .hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), null, null))
- .hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> new JpaParticipant(null, null, new PfConceptKey(), null, null))
+ assertThatThrownBy(() -> new JpaParticipant(null, ParticipantState.ON_LINE, new ArrayList<>()))
.hasMessageMatching(NULL_KEY_ERROR);
- 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, null))
- .hasMessageMatching(NULL_KEY_ERROR);
-
- 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, null))
- .hasMessageMatching("definition is marked .*ull but is null");
-
- 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, null
- )).hasMessageMatching("definition is marked .*ull but is null");
-
- assertThatThrownBy(() -> new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), null, null))
+ assertThatThrownBy(() -> new JpaParticipant(UUID.randomUUID().toString(), null, new ArrayList<>()))
.hasMessageMatching("participantState is marked .*ull but is null");
- assertThatThrownBy(
- () -> new JpaParticipant(null, new PfConceptKey(), new PfConceptKey(), null, null))
- .hasMessageMatching("participantState is marked .*ull but is null");
+ assertThatThrownBy(() -> new JpaParticipant(UUID.randomUUID().toString(), ParticipantState.ON_LINE, null))
+ .hasMessageMatching("supportedElements 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, new ArrayList<>()));
- assertNotNull(new JpaParticipant(UUID.randomUUID().toString(), new PfConceptKey(),
- new PfConceptKey(), ParticipantState.ON_LINE, new ArrayList<>()));
+ assertNotNull(new JpaParticipant(UUID.randomUUID().toString(), ParticipantState.ON_LINE, new ArrayList<>()));
+
}
@Test
void testJpaParticipant() {
- JpaParticipant testJpaParticipant = createJpaParticipantInstance();
+ var testJpaParticipant = createJpaParticipantInstance();
- Participant participant = createParticipantInstance();
+ var participant = createParticipantInstance();
participant.setParticipantId(testJpaParticipant.toAuthorative().getParticipantId());
assertThatThrownBy(() -> new JpaParticipant((JpaParticipant) null)).isInstanceOf(NullPointerException.class);
- JpaParticipant testJpaParticipantFa = new JpaParticipant();
- testJpaParticipantFa.setKey(null);
+ var testJpaParticipantFa = new JpaParticipant();
testJpaParticipantFa.fromAuthorative(participant);
testJpaParticipantFa.setParticipantId(testJpaParticipant.getParticipantId());
assertEquals(testJpaParticipant, testJpaParticipantFa);
- testJpaParticipantFa.setKey(PfConceptKey.getNullKey());
- testJpaParticipantFa.fromAuthorative(participant);
- assertEquals(testJpaParticipant, testJpaParticipantFa);
- testJpaParticipantFa.setKey(new PfConceptKey("participant", "0.0.1"));
- testJpaParticipantFa.fromAuthorative(participant);
- assertEquals(testJpaParticipant, testJpaParticipantFa);
-
- assertEquals("participant", testJpaParticipant.getKey().getName());
- assertEquals("participant", new JpaParticipant(createJpaParticipantInstance()).getKey().getName());
- assertEquals("participant",
- ((PfConceptKey) new JpaParticipant(createJpaParticipantInstance()).getKeys().get(0)).getName());
-
- testJpaParticipant.clean();
- assertEquals("participant", testJpaParticipant.getKey().getName());
- testJpaParticipant.setDescription(" A Message ");
- testJpaParticipant.clean();
- assertEquals("A Message", testJpaParticipant.getDescription());
-
- JpaParticipant testJpaParticipant2 = new JpaParticipant(testJpaParticipant);
+ var testJpaParticipant2 = new JpaParticipant(testJpaParticipant);
testJpaParticipant2.setParticipantId(testJpaParticipant.getParticipantId());
assertEquals(testJpaParticipant, testJpaParticipant2);
}
@Test
void testJpaParticipantValidation() {
- JpaParticipant testJpaParticipant = createJpaParticipantInstance();
+ var testJpaParticipant = createJpaParticipantInstance();
assertThatThrownBy(() -> testJpaParticipant.validate(null))
.hasMessageMatching("fieldName is marked .*ull but is null");
@Test
void testJpaParticipantCompareTo() {
- JpaParticipant testJpaParticipant = createJpaParticipantInstance();
+ var testJpaParticipant = createJpaParticipantInstance();
- JpaParticipant otherJpaParticipant = new JpaParticipant(testJpaParticipant);
+ var otherJpaParticipant = new JpaParticipant(testJpaParticipant);
otherJpaParticipant.setParticipantId(testJpaParticipant.getParticipantId());
assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
assertEquals(-1, testJpaParticipant.compareTo(null));
assertEquals(0, testJpaParticipant.compareTo(testJpaParticipant));
assertNotEquals(0, testJpaParticipant.compareTo(new DummyJpaParticipantChild()));
- testJpaParticipant.setKey(new PfConceptKey("BadValue", "0.0.1"));
- assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
- testJpaParticipant.setKey(new PfConceptKey("participant", "0.0.1"));
- assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
-
- testJpaParticipant.setDefinition(new PfConceptKey("BadValue", "0.0.1"));
- assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
- testJpaParticipant.setDefinition(new PfConceptKey("participantDefinitionName", "0.0.1"));
- assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
-
testJpaParticipant.setParticipantState(ParticipantState.OFF_LINE);
assertNotEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
testJpaParticipant.setParticipantState(ParticipantState.ON_LINE);
assertEquals(0, testJpaParticipant.compareTo(otherJpaParticipant));
assertEquals(testJpaParticipant, new JpaParticipant(testJpaParticipant));
- JpaParticipant newJpaParticipant = new JpaParticipant(testJpaParticipant);
+ var newJpaParticipant = new JpaParticipant(testJpaParticipant);
newJpaParticipant.setParticipantId(testJpaParticipant.getParticipantId());
assertEquals(testJpaParticipant, newJpaParticipant);
}
@Test
void testJpaParticipantLombok() {
assertNotNull(new Participant());
- JpaParticipant p0 = new JpaParticipant();
+ var p0 = new JpaParticipant();
assertThat(p0.toString()).contains("JpaParticipant(");
assertThat(p0.hashCode()).isNotZero();
assertNotEquals(null, p0);
- JpaParticipant p1 = new JpaParticipant();
-
- p1.setDefinition(new PfConceptKey("defName", "0.0.1"));
- p1.setDescription("Description");
- p1.setKey(new PfConceptKey("participant", "0.0.1"));
+ var p1 = new JpaParticipant();
p1.setParticipantState(ParticipantState.ON_LINE);
assertThat(p1.toString()).contains("Participant(");
assertNotEquals(p1, p0);
- JpaParticipant p2 = new JpaParticipant();
+ var p2 = new JpaParticipant();
p2.setParticipantId(p0.getParticipantId());
assertEquals(p2, p0);
}
private JpaParticipant createJpaParticipantInstance() {
- Participant testParticipant = createParticipantInstance();
- JpaParticipant testJpaParticipant = new JpaParticipant();
- testJpaParticipant.setKey(null);
+ var testParticipant = createParticipantInstance();
+ var testJpaParticipant = new JpaParticipant();
testParticipant.setParticipantId(UUID.fromString(testJpaParticipant.getParticipantId()));
testJpaParticipant.fromAuthorative(testParticipant);
- testJpaParticipant.setKey(PfConceptKey.getNullKey());
testJpaParticipant.fromAuthorative(testParticipant);
return testJpaParticipant;
}
private Participant createParticipantInstance() {
- Participant testParticipant = new Participant();
- testParticipant.setName("participant");
- testParticipant.setVersion("0.0.1");
- testParticipant.setDefinition(new ToscaConceptIdentifier("participantDefinitionName", "0.0.1"));
+ var testParticipant = new Participant();
+ testParticipant.setParticipantId(UUID.randomUUID());
testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1"));
testParticipant.setParticipantSupportedElementTypes(new LinkedHashMap<>());
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantProviderTest {
private static final Coder CODER = new StandardCoder();
private static final String PARTICIPANT_JSON = "src/test/resources/providers/TestParticipant.json";
private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
- private static final ToscaConceptIdentifier INVALID_ID = new ToscaConceptIdentifier("invalid_name", "1.0.1");
+ private static final UUID INVALID_ID = UUID.randomUUID();
private final List<Participant> inputParticipants = new ArrayList<>();
private List<JpaParticipant> jpaParticipantList;
private final String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_JSON);
@BeforeEach
- void beforeSetupDao() throws Exception {
+ void beforeSetup() throws Exception {
inputParticipants.add(CODER.decode(originalJson, Participant.class));
jpaParticipantList = ProviderUtils.getJpaAndValidateList(inputParticipants, JpaParticipant::new, "participant");
}
void testParticipantSave() {
var participantRepository = mock(ParticipantRepository.class);
for (var participant : jpaParticipantList) {
- when(participantRepository.getById(new PfConceptKey(participant.getName(), participant.getVersion())))
+ when(participantRepository.getById(participant.getParticipantId()))
.thenReturn(participant);
}
var participantProvider = new ParticipantProvider(participantRepository);
when(participantRepository.save(any())).thenReturn(jpaParticipantList.get(0));
- Participant savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0));
+ var savedParticipant = participantProvider.saveParticipant(inputParticipants.get(0));
savedParticipant.setParticipantId(inputParticipants.get(0).getParticipantId());
assertThat(savedParticipant).usingRecursiveComparison().isEqualTo(inputParticipants.get(0));
void testParticipantUpdate() {
var participantRepository = mock(ParticipantRepository.class);
for (var participant : jpaParticipantList) {
- when(participantRepository.getById(new PfConceptKey(participant.getName(), participant.getVersion())))
+ when(participantRepository.getById(participant.getParticipantId()))
.thenReturn(participant);
}
var participantProvider = new ParticipantProvider(participantRepository);
when(participantRepository.save(any())).thenReturn(jpaParticipantList.get(0));
- Participant updatedParticipant = participantProvider.updateParticipant(inputParticipants.get(0));
+ var updatedParticipant = participantProvider.updateParticipant(inputParticipants.get(0));
updatedParticipant.setParticipantId(inputParticipants.get(0).getParticipantId());
assertThat(updatedParticipant).usingRecursiveComparison().isEqualTo(inputParticipants.get(0));
}
when(participantRepository.findAll()).thenReturn(jpaParticipantList);
assertThat(participantProvider.getParticipants()).hasSize(inputParticipants.size());
- when(participantRepository.findByParticipantId(any())).thenReturn(
+ when(participantRepository.findById(any())).thenReturn(
Optional.ofNullable(jpaParticipantList.get(0)));
var participant = participantProvider.getParticipantById(inputParticipants.get(0)
var participantRepository = mock(ParticipantRepository.class);
var participantProvider = new ParticipantProvider(participantRepository);
- var participantId = UUID.randomUUID();
+ var participantId = inputParticipants.get(0).getParticipantId();
assertThatThrownBy(() -> participantProvider.deleteParticipant(participantId))
.hasMessageMatching(".*.failed, participant does not exist");
- when(participantRepository.findByParticipantId(participantId.toString()))
+ when(participantRepository.findById(participantId.toString()))
.thenReturn(Optional.of(jpaParticipantList.get(0)));
- Participant deletedParticipant =
- participantProvider.deleteParticipant(participantId);
+ var deletedParticipant = participantProvider.deleteParticipant(participantId);
assertThat(inputParticipants.get(0)).usingRecursiveComparison().isEqualTo(deletedParticipant);
}
}
package org.onap.policy.clamp.models.acm.utils;
-import org.onap.policy.models.base.PfConceptKey;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import java.util.UUID;
/**
* Class to hold/create all parameters for test cases.
*/
public class CommonTestData {
- public static final ToscaConceptIdentifier PARTCICIPANT_ID = new ToscaConceptIdentifier("id", "1.2.3");
+ public static final UUID PARTCICIPANT_ID = UUID.randomUUID();
/**
* Returns participantId for test cases.
*
* @return participant Id
*/
- public static ToscaConceptIdentifier getParticipantId() {
+ public static UUID getParticipantId() {
return PARTCICIPANT_ID;
}
*
* @return participant Id
*/
- public static PfConceptKey getJpaParticipantId() {
- return PARTCICIPANT_ID.asConceptKey();
+ public static String getJpaParticipantId() {
+ return PARTCICIPANT_ID.toString();
}
/**
- * Returns second participantId for test cases.
+ * Returns random participantId for test cases.
*
* @return participant Id
*/
- public static ToscaConceptIdentifier getRndParticipantId() {
- return new ToscaConceptIdentifier("idDiff", "1.2.3");
+ public static UUID getRndParticipantId() {
+ return UUID.randomUUID();
}
}
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: A1PMSParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c00
participantType:
name: org.onap.policy.clamp.acm.A1PMSParticipant
version: 2.3.4
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: HttpParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c01
participantType:
name: org.onap.policy.clamp.acm.HttpParticipant
version: 2.3.4
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: K8sParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c02
participantType:
name: org.onap.policy.clamp.acm.KubernetesParticipant
version: 2.3.4
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: org.onap.PM_Policy
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c03
participantType:
name: org.onap.policy.clamp.acm.PolicyParticipant
version: 2.3.1
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: A1PMSParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c00
participantType:
name: org.onap.policy.clamp.acm.A1PMSParticipant
version: 2.3.4
intermediaryParameters:
reportingTimeInterval: 120000
description: Participant Description
- participantId:
- name: A1PMSParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c00
participantType:
name: org.onap.policy.clamp.acm.A1PMSParticipant
version: 2.3.4
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: HttpParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c01
participantType:
name: org.onap.policy.clamp.acm.HttpParticipant
version: 2.3.4
intermediaryParameters:
reportingTimeInterval: 120000
description: Participant Description
- participantId:
- version: 1.0.0
- name: HttpParticipant0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c01
participantType:
version: 2.3.4
name: org.onap.clamp.acm.HttpParticipant
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: K8sParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c02
participantType:
name: org.onap.policy.clamp.acm.KubernetesParticipant
version: 2.3.4
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("description", DESCRIPTION);
map.put("participantId", getParticipantId());
- map.put("participantType", getParticipantId());
+ map.put("participantType", getParticipantType());
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
map.put("participantSupportedElementTypes", new ArrayList<>());
}
}
/**
- * Returns participantId for test cases.
+ * Returns participantType for test cases.
*
- * @return participant Id
+ * @return participant Type
*/
- public static ToscaConceptIdentifier getParticipantId() {
- final ToscaConceptIdentifier participantId = new ToscaConceptIdentifier();
+ public static ToscaConceptIdentifier getParticipantType() {
+ final var participantId = new ToscaConceptIdentifier();
participantId.setName("K8sParticipant0");
participantId.setVersion("1.0.0");
return participantId;
}
+ /**
+ * Returns participantId for test cases.
+ *
+ * @return participant Id
+ */
+ public static UUID getParticipantId() {
+ return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c02");
+ }
/**
* Returns a property map for a TopicParameters map for test cases.
name: Participant parameters
description: Participant Description
reportingTimeInterval: 120000
- participantId:
- name: K8sParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c02
participantType:
version: 2.3.4
name: org.onap.k8s.acm.K8SAutomationCompositionParticipant
intermediaryParameters:
reportingTimeIntervalMs: 120000
description: Participant Description
- participantId:
- name: org.onap.PM_Policy
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c03
participantType:
name: org.onap.policy.clamp.acm.PolicyParticipant
version: 2.3.1
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import java.util.UUID;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
*
* @return participant Id
*/
- public static ToscaConceptIdentifier getParticipantId() {
- return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
+ public static UUID getParticipantId() {
+ return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03");
}
}
intermediaryParameters:
reportingTimeInterval: 120000
description: Participant Description
- participantId:
- version: 1.0.0
- name: org.onap.PM_Policy
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c03
participantType:
version: 1.0.0
name: org.onap.PM_CDS_Blueprint
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionHandler.class);
private final ToscaConceptIdentifier participantType;
- private final ToscaConceptIdentifier participantId;
+ private final UUID participantId;
private final ParticipantMessagePublisher publisher;
@Getter
private final ToscaConceptIdentifier participantType;
@Getter
- private final ToscaConceptIdentifier participantId;
+ private final UUID participantId;
private final AutomationCompositionHandler automationCompositionHandler;
private final ParticipantMessagePublisher publisher;
package org.onap.policy.clamp.acm.participant.intermediary.parameters;
import java.util.List;
+import java.util.UUID;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
// The ID and description of this participant
@NotNull
@Valid
- private ToscaConceptIdentifier participantId;
+ private UUID participantId;
@NotBlank
private String description;
private static final Object lockit = new Object();
public static final UUID AC_ID_0 = UUID.randomUUID();
public static final UUID AC_ID_1 = UUID.randomUUID();
- public static final ToscaConceptIdentifier PARTCICIPANT_ID =
- new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
+ public static final UUID PARTCICIPANT_ID = UUID.randomUUID();
/**
* Get ParticipantIntermediaryParameters.
*
* @return participant Id
*/
- public static ToscaConceptIdentifier getParticipantId() {
+ public static UUID getParticipantId() {
return PARTCICIPANT_ID;
}
- public static ToscaConceptIdentifier getRndParticipantId() {
- return new ToscaConceptIdentifier("diff", "0.0.0");
+ public static UUID getRndParticipantId() {
+ return UUID.randomUUID();
}
public static ToscaConceptIdentifier getDefinition() {
* @return a map suitable for elementsOnThisParticipant
*/
public Map<UUID, AutomationCompositionElement> setAutomationCompositionElementTest(UUID uuid,
- ToscaConceptIdentifier definition, ToscaConceptIdentifier participantId) {
+ ToscaConceptIdentifier definition, UUID participantId) {
var acElement = new AutomationCompositionElement();
acElement.setId(uuid);
acElement.setParticipantId(participantId);
* @return a AutomationCompositionHander with elements
*/
public AutomationCompositionHandler setTestAutomationCompositionHandler(ToscaConceptIdentifier definition,
- UUID uuid, ToscaConceptIdentifier participantId) {
+ UUID uuid, UUID participantId) {
var ach = getMockAutomationCompositionHandler();
var key = getTestAutomationCompositionMap().keySet().iterator().next();
* @param state a AutomationCompositionOrderedState
* @return a AutomationCompositionStateChange
*/
- public AutomationCompositionStateChange getStateChange(ToscaConceptIdentifier participantId, UUID uuid,
+ public AutomationCompositionStateChange getStateChange(UUID participantId, UUID uuid,
AutomationCompositionOrderedState state) {
var stateChange = new AutomationCompositionStateChange();
stateChange.setAutomationCompositionId(UUID.randomUUID());
var result = new BeanValidationResult("AutomationComposition", automationComposition);
var participantMap = participants.stream()
- .collect(Collectors.toMap(participant -> participant.getKey().asIdentifier(), Function.identity()));
+ .collect(Collectors.toMap(participant -> participant.getParticipantId(), Function.identity()));
for (var element : automationComposition.getElements().values()) {
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantStatusReqPublisher;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantInformation;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@Service
@Transactional
+@RequiredArgsConstructor
public class AcmParticipantProvider {
private static final Logger LOGGER = LoggerFactory.getLogger(AcmParticipantProvider.class);
private final ParticipantProvider participantProvider;
private final ParticipantStatusReqPublisher participantStatusReqPublisher;
- public AcmParticipantProvider(ParticipantProvider participantProvider,
- ParticipantStatusReqPublisher participantStatusReqPublisher) {
- this.participantProvider = participantProvider;
- this.participantStatusReqPublisher = participantStatusReqPublisher;
- }
-
/**
* Get all participants.
*
* @return A list of available participants
*/
public List<ParticipantInformation> getAllParticipants() {
- List<Participant> participants = this.participantProvider.getParticipants();
+ var participants = this.participantProvider.getParticipants();
List<ParticipantInformation> participantInformationList = new ArrayList<>();
participants.forEach(participant -> {
* @return The participant
*/
public ParticipantInformation getParticipantById(UUID participantId) {
- Participant participant = this.participantProvider.getParticipantById(participantId);
- ParticipantInformation participantInformation = new ParticipantInformation();
+ var participant = this.participantProvider.getParticipantById(participantId);
+ var participantInformation = new ParticipantInformation();
participantInformation.setParticipant(participant);
return participantInformation;
}
* @param participantId The UUID of the participant to send request to
*/
public void sendParticipantStatusRequest(UUID participantId) {
- Participant participant = this.participantProvider.getParticipantById(participantId);
- ToscaConceptIdentifier id = participant.getKey().asIdentifier();
+ var participant = this.participantProvider.getParticipantById(participantId);
LOGGER.debug("Requesting Participant Status Now ParticipantStatusReq");
- participantStatusReqPublisher.send(id);
+ participantStatusReqPublisher.send(participantId);
participant.setParticipantState(ParticipantState.OFF_LINE);
participantProvider.updateParticipant(participant);
}
*
*/
public void sendAllParticipantStatusRequest() {
- this.participantStatusReqPublisher.send((ToscaConceptIdentifier) null);
+ this.participantStatusReqPublisher.send((UUID) null);
}
}
if (participantOpt.isEmpty()) {
ParticipantRegister registerMessage = (ParticipantRegister) participantMessage;
var participant = new Participant();
- participant.setName(registerMessage.getParticipantId().getName());
- participant.setVersion(registerMessage.getParticipantId().getVersion());
- participant.setDefinition(registerMessage.getParticipantId());
+ participant.setParticipantId(participantMessage.getParticipantId());
participant.setParticipantType(registerMessage.getParticipantType());
participant.setParticipantSupportedElementTypes(listToMap(registerMessage
.getParticipantSupportedElementType()));
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
private final HandleCounter<UUID> automationCompositionCounter = new HandleCounter<>();
- private final HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>();
+ private final HandleCounter<UUID> participantStatusCounter = new HandleCounter<>();
private final Map<UUID, Integer> phaseMap = new HashMap<>();
}
private void scanParticipantStatus(Participant participant) {
- var id = participant.getKey().asIdentifier();
+ var id = participant.getParticipantId();
if (participantStatusCounter.isFault(id)) {
LOGGER.debug("report Participant fault");
return;
/**
* handle participant Status message.
*/
- public void handleParticipantStatus(ToscaConceptIdentifier id) {
+ public void handleParticipantStatus(UUID id) {
participantStatusCounter.clear(id);
}
* @param participantType the participant Type
*/
@Timed(value = "publisher.participant_register_ack", description = "PARTICIPANT_REGISTER_ACK messages published")
- public void send(UUID responseTo, ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) {
+ public void send(UUID responseTo, UUID participantId, ToscaConceptIdentifier participantType) {
var message = new ParticipantRegisterAck();
message.setParticipantId(participantId);
message.setParticipantType(participantType);
import io.micrometer.core.annotation.Timed;
import java.time.Instant;
+import java.util.UUID;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
* @param participantId the participant Id
*/
@Timed(value = "publisher.participant_status_req", description = "PARTICIPANT_STATUS_REQ messages published")
- public void send(ToscaConceptIdentifier participantId) {
+ public void send(UUID participantId) {
ParticipantStatusReq message = new ParticipantStatusReq();
message.setParticipantId(participantId);
message.setTimestamp(Instant.now());
* @param participantId the ParticipantId
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
- public void sendCommissioning(ToscaConceptIdentifier participantType, ToscaConceptIdentifier participantId) {
+ public void sendCommissioning(ToscaConceptIdentifier participantType, UUID participantId) {
var list = acDefinitionProvider.getAllAcDefinitions();
if (list.isEmpty()) {
LOGGER.warn("No tosca service template found, cannot send participantupdate");
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
public void sendCommissioning(AutomationCompositionDefinition acmDefinition,
- ToscaConceptIdentifier participantType, ToscaConceptIdentifier participantId) {
+ ToscaConceptIdentifier participantType, UUID participantId) {
var message = new ParticipantUpdate();
message.setCompositionId(acmDefinition.getCompositionId());
message.setParticipantType(participantType);
"name": "org.onap.policy.clamp.acm.HttpParticipant",
"version": "2.3.4"
},
- "participantId": {
- "name": "HttpParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Sink Automation Composition Element for the Demo",
"name": "org.onap.policy.clamp.acm.HttpParticipant",
"version": "2.3.4"
},
- "participantId": {
- "name": "HttpParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Bridge Automation Composition Element for the Demo",
"name": "org.onap.policy.clamp.acm.HttpParticipant",
"version": "2.3.4"
},
- "participantId": {
- "name": "HttpParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"description": "Starter Automation Composition Element for the Demo",
participantType:
name: org.onap.policy.clamp.acm.HttpParticipant
version: 2.3.4
- participantId:
- name: HttpParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c01
state: UNINITIALISED
orderedState: UNINITIALISED
description: Sink Automation Composition Element for the Demo
participantType:
name: org.onap.policy.clamp.acm.HttpParticipant
version: 2.3.4
- participantId:
- name: HttpParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c01
state: UNINITIALISED
orderedState: UNINITIALISED
description: Bridge Automation Composition Element for the Demo
participantType:
name: org.onap.policy.clamp.acm.HttpParticipant
version: 2.3.4
- participantId:
- name: HttpParticipant0
- version: 1.0.0
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c01
state: UNINITIALISED
orderedState: UNINITIALISED
description: Starter Automation Composition Element for the Demo
package org.onap.policy.clamp.acm.runtime.supervision;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
mock(ParticipantUpdatePublisher.class), AutomationCompositionOrderedState.PASSIVE,
AutomationCompositionState.UNINITIALISED);
- handler.handleParticipantMessage(participantUpdateAckMessage);
+ assertThatCode(() -> handler.handleParticipantMessage(participantUpdateAckMessage)).doesNotThrowAnyException();
}
@Test
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
acRuntimeParameterGroup);
- supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
+ supervisionScanner.handleParticipantStatus(participant.getParticipantId());
supervisionScanner.run(true);
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
}
var participant = CommonTestData.createParticipant(PARTICIPANT_TYPE, CommonTestData.getParticipantId());
participant.setParticipantState(ParticipantState.OFF_LINE);
- participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.getParticipants()).thenReturn(List.of(participant));
automationCompositionStateChangePublisher, automationCompositionUpdatePublisher, participantProvider,
acRuntimeParameterGroup);
- supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
+ supervisionScanner.handleParticipantStatus(participant.getParticipantId());
supervisionScanner.run(true);
- verify(participantProvider, times(0)).updateParticipant(any());
+ verify(participantProvider, times(0)).saveParticipant(any());
supervisionScanner.run(true);
verify(participantProvider, times(1)).updateParticipant(any());
package org.onap.policy.clamp.acm.runtime.util;
import java.util.List;
+import java.util.UUID;
import javax.ws.rs.core.Response.Status;
import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
public static List<Participant> createParticipants() {
var participant1 = createParticipant(
new ToscaConceptIdentifier("org.onap.policy.clamp.acm.KubernetesParticipant", "2.3.4"),
- new ToscaConceptIdentifier("K8sParticipant0", "1.0.0"));
+ UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c02"));
var participant2 = createParticipant(
new ToscaConceptIdentifier("org.onap.policy.clamp.acm.HttpParticipant", "2.3.4"),
- new ToscaConceptIdentifier("HttpParticipant0", "1.0.0"));
+ UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c01"));
var participant3 = createParticipant(
new ToscaConceptIdentifier("org.onap.policy.clamp.acm.PolicyParticipant", "2.3.1"),
- new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0"));
+ UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03"));
return List.of(participant1, participant2, participant3);
}
* @return a new Participant
*/
public static Participant createParticipant(ToscaConceptIdentifier participantType,
- ToscaConceptIdentifier participantId) {
+ UUID participantId) {
var participant = new Participant();
- participant.setDefinition(participantId);
+ participant.setParticipantId(participantId);
participant.setParticipantType(participantType);
- participant.setName(participantId.getName());
- participant.setVersion(participantId.getVersion());
return participant;
}
- public static ToscaConceptIdentifier getParticipantId() {
- return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");
+ public static UUID getParticipantId() {
+ return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03");
}
}
"name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "K8sParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02",
"participantType": {
"name": "org.onap.policy.clamp.acm.KubernetesParticipant",
"version": "2.3.4"
"name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "HttpParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
"participantType": {
"name": "org.onap.policy.clamp.acm.HttpParticipant",
"version": "2.3.4"
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
"participantType": {
"name": "org.onap.policy.clamp.acm.PolicyParticipant",
"version": "2.3.1"
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
"participantType": {
"name": "org.onap.policy.clamp.acm.PolicyParticipant",
"version": "2.3.1"
"name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "HttpParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
"participantType": {
"name": "org.onap.policy.clamp.acm.HttpParticipant",
"version": "2.3.4"
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
"participantType": {
"name": "org.onap.policy.clamp.acm.PolicyParticipant",
"version": "2.3.1"
"name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "K8sParticipant0t",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02",
"participantType": {
"name": "org.onap.policy.clamp.acm.KubernetesParticipant",
"version": "2.3.4"
"name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "K8sParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c02",
"participantType": {
"name": "org.onap.policy.clamp.acm.KubernetesParticipant",
"version": "2.3.4"
"name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "HttpParticipant0",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c01",
"participantType": {
"name": "org.onap.policy.clamp.acm.HttpParticipant",
"version": "2.3.4"
"name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
"version": "1.2.3"
},
- "participantId": {
- "name": "org.onap.PM_Policy",
- "version": "1.0.0"
- },
+ "participantId": "101c62b3-8918-41b9-a747-d21eb79c6c03",
"participantType": {
"name": "org.onap.policy.clamp.acm.PolicyParticipant",
"version": "2.3.1"