/*-
* ============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.
@NonNull
private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
- @NonNull
- private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier(PfConceptKey.getNullKey());
-
@NonNull
private UUID participantId = UUID.randomUUID();
public AutomationCompositionElement(final AutomationCompositionElement otherElement) {
this.id = otherElement.id;
this.definition = new ToscaConceptIdentifier(otherElement.definition);
- this.participantType = new ToscaConceptIdentifier(otherElement.participantType);
this.participantId = otherElement.participantId;
this.state = otherElement.state;
this.orderedState = otherElement.orderedState;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent details of a running participant instance.
@NonNull
private ParticipantState participantState = ParticipantState.ON_LINE;
- @NonNull
- private ToscaConceptIdentifier participantType = new ToscaConceptIdentifier();
-
@NonNull
private Map<UUID, ParticipantSupportedElementType> participantSupportedElementTypes = new HashMap<>();
*/
public Participant(Participant otherParticipant) {
this.participantState = otherParticipant.participantState;
- this.participantType = otherParticipant.participantType;
this.participantId = otherParticipant.participantId;
this.participantSupportedElementTypes = PfUtils.mapMap(otherParticipant.getParticipantSupportedElementTypes(),
ParticipantSupportedElementType::new);
/*-
* ============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.
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.
private UUID participantId;
- private ToscaConceptIdentifier participantType;
// List of AutomationCompositionElementDefinition values for a particular participant
private List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>();
*/
public ParticipantDefinition(final ParticipantDefinition participantDefinition) {
this.participantId = participantDefinition.participantId;
- this.participantType = participantDefinition.participantType;
this.automationCompositionElementDefinitionList =
PfUtils.mapList(participantDefinition.automationCompositionElementDefinitionList,
AutomationCompositionElementDefinition::new);
/*-
* ============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.concepts;
import java.util.Map;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.onap.policy.common.utils.coder.Coder;
-import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
private static final String AUTOMATION_COMPOSITION_ELEMENT =
"org.onap.policy.clamp.acm.AutomationCompositionElement";
- /**
- * Finds participantType from a map of properties.
- *
- * @param properties Map of properties
- * @return participantType
- */
- public static ToscaConceptIdentifier findParticipantType(Map<String, Object> properties) {
- var objParticipantType = properties.get("participantType");
- if (objParticipantType != null) {
- try {
- return CODER.decode(objParticipantType.toString(), ToscaConceptIdentifier.class);
- } catch (CoderException e) {
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e);
- }
- }
- return null;
- }
-
/**
* Get the First StartPhase.
*
* @return startPhase
*/
public static int findStartPhase(Map<String, Object> properties) {
- var objParticipantType = properties.get("startPhase");
- if (objParticipantType != null) {
- return Integer.valueOf(objParticipantType.toString());
+ var objStartPhase = properties.get("startPhase");
+ if (objStartPhase != null) {
+ return Integer.valueOf(objStartPhase.toString());
}
return 0;
}
/*-
* ============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.
import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent participant Ack message.
private ParticipantMessageType messageType;
- /**
- * Participant Type, or {@code null} for messages from participants.
- */
- private ToscaConceptIdentifier participantType;
-
/**
* Participant ID, or {@code null} for messages from participants.
*/
this.result = source.result;
this.message = source.message;
this.messageType = source.messageType;
- this.participantType = source.participantType;
this.participantId = source.participantId;
this.state = source.state;
}
/**
* Determines if this message applies to this participant type.
*
- * @param participantType type of the participant to match against
* @param participantId id of the participant to match against
* @return {@code true} if this message applies to this participant, {@code false} otherwise
*/
- public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType,
- @NonNull final UUID participantId) {
+ public boolean appliesTo(@NonNull final UUID participantId) {
// Broadcast message to all participants
- if (this.participantType == null) {
- return true;
- }
-
- if (!participantType.equals(this.participantType)) {
- return false;
- }
-
- // Broadcast message to all automation composition elements on this participant
if (this.participantId == null) {
return true;
}
/*-
* ============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.
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent the base class for various messages that will be exchanged between the ACM runtime and
*/
private Instant timestamp = Instant.now();
- /**
- * Participant Type, or {@code null} for messages from participants.
- */
- private ToscaConceptIdentifier participantType;
-
/**
* Participant ID, or {@code null} for messages from participants.
*/
*/
public ParticipantMessage(final ParticipantMessage source) {
this.messageType = source.messageType;
- this.participantType = source.participantType;
this.participantId = source.participantId;
this.automationCompositionId = source.automationCompositionId;
this.compositionId = source.compositionId;
/**
* Determines if this message applies to this participant type.
*
- * @param participantType type of the participant to match against
* @param participantId id of the participant to match against
* @return {@code true} if this message applies to this participant, {@code false} otherwise
*/
- public boolean appliesTo(@NonNull final ToscaConceptIdentifier participantType,
- @NonNull final UUID participantId) {
+ public boolean appliesTo(@NonNull final UUID participantId) {
// Broadcast message to all participants
- if (this.participantType == null) {
- return true;
- }
-
- if (!participantType.equals(this.participantType)) {
- return false;
- }
-
- // Broadcast message to all automation composition elements on this participant
if (this.participantId == null) {
return true;
}
/*-
* ============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.
* ================================================================================
@AttributeOverride(name = "version", column = @Column(name = "definition_version"))
private PfConceptKey definition;
- @VerifyKey
- @NotNull
- @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
- @AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
- private PfConceptKey participantType;
-
- @Column
@NotNull
private String participantId;
* @param instanceId The id of the automation composition instance
*/
public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId) {
- this(elementId, instanceId, new PfConceptKey(), new PfConceptKey(), AutomationCompositionState.UNINITIALISED);
+ this(elementId, instanceId, new PfConceptKey(), AutomationCompositionState.UNINITIALISED);
}
/**
* @param elementId The id of the automation composition instance Element
* @param instanceId The id of the automation composition instance
* @param definition the TOSCA definition of the automation composition element
- * @param participantType the TOSCA definition of the participant running the automation composition element
* @param state the state of the automation composition
*/
public JpaAutomationCompositionElement(@NonNull final String elementId, @NonNull final String instanceId,
- @NonNull final PfConceptKey definition, @NonNull final PfConceptKey participantType,
+ @NonNull final PfConceptKey definition,
@NonNull final AutomationCompositionState state) {
this.elementId = elementId;
this.instanceId = instanceId;
this.definition = definition;
- this.participantType = participantType;
this.state = state;
}
this.elementId = copyConcept.elementId;
this.instanceId = copyConcept.instanceId;
this.definition = new PfConceptKey(copyConcept.definition);
- this.participantType = new PfConceptKey(copyConcept.participantType);
this.participantId = copyConcept.participantId;
this.state = copyConcept.state;
this.orderedState = copyConcept.orderedState;
element.setId(UUID.fromString(elementId));
element.setDefinition(new ToscaConceptIdentifier(definition));
- element.setParticipantType(new ToscaConceptIdentifier(participantType));
element.setParticipantId(UUID.fromString(participantId));
element.setState(state);
element.setOrderedState(orderedState != null ? orderedState : state.asOrderedState());
@Override
public void fromAuthorative(@NonNull final AutomationCompositionElement element) {
this.definition = element.getDefinition().asConceptKey();
- this.participantType = element.getParticipantType().asConceptKey();
this.participantId = element.getParticipantId().toString();
this.state = element.getState();
this.orderedState = element.getOrderedState();
return result;
}
- result = participantType.compareTo(other.participantType);
- if (result != 0) {
- return result;
- }
-
result = participantId.compareTo(other.participantId);
if (result != 0) {
return result;
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.Entity;
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.PfConceptKey;
import org.onap.policy.models.base.Validated;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent a participant in the database.
@NotNull
private String participantId;
- @NotNull
- @AttributeOverride(name = "name", column = @Column(name = "participant_type_name"))
- @AttributeOverride(name = "version", column = @Column(name = "participant_type_version"))
- private PfConceptKey participantType;
-
@Column
@NotNull
private ParticipantState participantState;
public JpaParticipant(@NonNull final JpaParticipant copyConcept) {
this.participantState = copyConcept.participantState;
this.description = copyConcept.description;
- this.participantType = copyConcept.participantType;
this.participantId = copyConcept.participantId;
this.supportedElements = copyConcept.supportedElements;
}
var participant = new Participant();
participant.setParticipantState(participantState);
- participant.setParticipantType(new ToscaConceptIdentifier(participantType));
participant.setParticipantId(UUID.fromString(participantId));
participant.setParticipantSupportedElementTypes(new LinkedHashMap<>(this.supportedElements.size()));
for (var element : this.supportedElements) {
@Override
public void fromAuthorative(@NonNull final Participant participant) {
this.setParticipantState(participant.getParticipantState());
- this.participantType = participant.getParticipantType().asConceptKey();
this.participantId = participant.getParticipantId().toString();
this.supportedElements = new ArrayList<>(participant.getParticipantSupportedElementTypes().size());
return result;
}
- result = ObjectUtils.compare(participantType, other.participantType);
- if (result != 0) {
- return result;
- }
-
return ObjectUtils.compare(description, other.description);
}
}
/*-
* ============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.
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
/**
* Prepare ParticipantDefinitionUpdate to set in the message.
*
- * @param acParticipantType participant type
+ * @param acParticipantId participant id
* @param entryKey key for the entry
* @param entryValue value relates to toscaNodeTemplate
* @param participantDefinitionUpdates list of participantDefinitionUpdates
*/
- public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier acParticipantType, String entryKey,
- ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates) {
+ public static void prepareParticipantDefinitionUpdate(UUID acParticipantId, String entryKey,
+ ToscaNodeTemplate entryValue,
+ List<ParticipantDefinition> participantDefinitionUpdates) {
var acDefinition = new AutomationCompositionElementDefinition();
acDefinition.setAcElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion()));
List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList = new ArrayList<>();
if (participantDefinitionUpdates.isEmpty()) {
- participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantType,
+ participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantId,
automationCompositionElementDefinitionList));
} else {
var participantExists = false;
for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) {
- if (participantDefinitionUpdate.getParticipantType().equals(acParticipantType)) {
- participantDefinitionUpdate.getAutomationCompositionElementDefinitionList().add(acDefinition);
- participantExists = true;
+ if (acParticipantId != null || participantDefinitionUpdate.getParticipantId() != null) {
+ if (participantDefinitionUpdate.getParticipantId().equals(acParticipantId)) {
+ participantDefinitionUpdate.getAutomationCompositionElementDefinitionList().add(acDefinition);
+ participantExists = true;
+ }
}
}
if (!participantExists) {
- participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantType,
+ participantDefinitionUpdates.add(getParticipantDefinition(acDefinition, acParticipantId,
automationCompositionElementDefinitionList));
}
}
}
private static ParticipantDefinition getParticipantDefinition(AutomationCompositionElementDefinition acDefinition,
- ToscaConceptIdentifier acParticipantType,
+ UUID acParticipantId,
List<AutomationCompositionElementDefinition> automationCompositionElementDefinitionList) {
var participantDefinition = new ParticipantDefinition();
- participantDefinition.setParticipantType(acParticipantType);
+ participantDefinition.setParticipantId(acParticipantId);
automationCompositionElementDefinitionList.add(acDefinition);
participantDefinition.setAutomationCompositionElementDefinitionList(automationCompositionElementDefinitionList);
return participantDefinition;
/*-
* ============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.
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
private static final String PARTICIPANT_AUTOMATION_COMPOSITION_ELEMENT = "org.onap.policy.clamp.acm.Participant";
private static final StandardYamlCoder YAML_TRANSLATOR = new StandardYamlCoder();
- @Test
- void testFindParticipantType() throws CoderException {
- var identifier = new ToscaConceptIdentifier("Identifier", "1.0.1");
- var result = ParticipantUtils.findParticipantType(Map.of("participantType", CODER.encode(identifier)));
- assertThat(result).isEqualTo(identifier);
- }
-
@Test
void testFindStartPhase() {
var identifier = 13;
/*-
* ============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.
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.utils.CommonTestData;
import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class AutomationCompositionAckTest {
// verify with all values
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
- var id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setParticipantType(id);
var acElementResult = new AutomationCompositionElementAck(AutomationCompositionState.UNINITIALISED,
true, "AutomationCompositionElement result");
final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult);
/*-
* ============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.
var participantId = CommonTestData.getParticipantId();
acElement.setParticipantId(participantId);
- acElement.setParticipantType(id);
var property = new ToscaProperty();
property.setName("test");
/*-
* ============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.
@Test
void testAppliesTo_NullParticipantId() {
message = makeMessage();
-
- assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class);
- var participantId = CommonTestData.getParticipantId();
- assertThatThrownBy(() -> message.appliesTo(null, participantId)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> message.appliesTo(null)).isInstanceOf(NullPointerException.class);
}
@Test
message = makeMessage();
// ParticipantId matches
- assertTrue(message.appliesTo(PTYPE_456, CommonTestData.getParticipantId()));
- assertFalse(message.appliesTo(PTYPE_456, CommonTestData.getRndParticipantId()));
- assertFalse(message.appliesTo(PTYPE_457, CommonTestData.getParticipantId()));
+ assertTrue(message.appliesTo(CommonTestData.getParticipantId()));
+ assertFalse(message.appliesTo(CommonTestData.getRndParticipantId()));
}
@Test
message = makeMessage();
// ParticipantId does not match
- ToscaConceptIdentifier id = new ToscaConceptIdentifier();
- id.setName("id1111");
- id.setVersion("3.2.1");
- assertFalse(message.appliesTo(id, CommonTestData.getRndParticipantId()));
- message.setParticipantType(null);
- assertTrue(message.appliesTo(id, CommonTestData.getRndParticipantId()));
+ assertFalse(message.appliesTo(CommonTestData.getRndParticipantId()));
+ assertTrue(message.appliesTo(CommonTestData.getParticipantId()));
}
private ParticipantAckMessage makeMessage() {
ParticipantAckMessage msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK);
- msg.setParticipantType(PTYPE_456);
msg.setParticipantId(CommonTestData.getParticipantId());
msg.setMessage("Successfull Ack");
msg.setResult(true);
/*-
* ============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.
id.setVersion("1.2.3");
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
- orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
void testAppliesTo_NullParticipantId() {
message = makeMessage();
- assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class);
- var participantId = CommonTestData.getParticipantId();
- assertThatThrownBy(() -> message.appliesTo(null, participantId)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> message.appliesTo(null)).isInstanceOf(NullPointerException.class);
}
@Test
message = makeMessage();
// ParticipantId matches
- assertTrue(message.appliesTo(PTYPE_456, CommonTestData.getParticipantId()));
- assertFalse(message.appliesTo(PTYPE_456, CommonTestData.getRndParticipantId()));
- assertFalse(message.appliesTo(PTYPE_457, CommonTestData.getParticipantId()));
+ assertTrue(message.appliesTo(CommonTestData.getParticipantId()));
+ assertFalse(message.appliesTo(CommonTestData.getRndParticipantId()));
}
@Test
void testAppliesTo_ParticipantIdNoMatch() {
message = makeMessage();
-
- // ParticipantId does not match
- var id = new ToscaConceptIdentifier();
- id.setName("id1111");
- id.setVersion("3.2.1");
- assertFalse(message.appliesTo(id, CommonTestData.getRndParticipantId()));
- message.setParticipantType(null);
- assertTrue(message.appliesTo(id, CommonTestData.getRndParticipantId()));
+ assertFalse(message.appliesTo(CommonTestData.getRndParticipantId()));
+ assertTrue(message.appliesTo(CommonTestData.getParticipantId()));
}
private ParticipantMessage makeMessage() {
var msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
- msg.setParticipantType(PTYPE_456);
msg.setParticipantId(CommonTestData.getParticipantId());
msg.setMessageId(UUID.randomUUID());
msg.setTimestamp(Instant.ofEpochMilli(3000));
/*-
* ============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.
id.setVersion("1.2.3");
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
- orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
/*-
* ============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.
// verify with all values
orig.setParticipantId(CommonTestData.getParticipantId());
orig.setAutomationCompositionId(null);
- orig.setParticipantType(null);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
var participantId = CommonTestData.getParticipantId();
orig.setParticipantId(participantId);
var type = new ToscaConceptIdentifier("type", "2.3.4");
- orig.setParticipantType(type);
orig.setMessageId(UUID.randomUUID());
orig.setState(ParticipantState.ON_LINE);
orig.setTimestamp(Instant.ofEpochMilli(3000));
var participantDefinitionUpdate = new ParticipantDefinition();
participantDefinitionUpdate.setParticipantId(participantId);
- participantDefinitionUpdate.setParticipantType(type);
var acDefinition = getAcElementDefinition(new ToscaConceptIdentifier("id", "1.2.3"));
participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
/*-
* ============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.
// verify with all values
orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(CommonTestData.getParticipantId());
- var type = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setParticipantType(type);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
toscaNodeTemplate.setVersion("1.2.3");
var participantDefinitionUpdate = new ParticipantDefinition();
- participantDefinitionUpdate.setParticipantType(type);
+ var type = new ToscaConceptIdentifier("id", "1.2.3");
var acDefinition = getAcElementDefinition(type);
participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
/*-
* ============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.
}).hasMessageMatching(NULL_ELEMENT_ID_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement(null, null, null, null, null);
+ new JpaAutomationCompositionElement(null, null, null, null);
}).hasMessageMatching(NULL_ELEMENT_ID_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement("key", null, null, null, AutomationCompositionState.UNINITIALISED);
+ new JpaAutomationCompositionElement("key", null, null, AutomationCompositionState.UNINITIALISED);
}).hasMessageMatching(NULL_INSTANCE_ID_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement("key", "key", null, new PfConceptKey("participant", "0.0.1"), null);
- }).hasMessageMatching("definition" + NULL_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement("key", "key", new PfConceptKey(), null,
- AutomationCompositionState.UNINITIALISED);
- }).hasMessageMatching("participantType" + NULL_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationCompositionElement("key", "key", new PfConceptKey(), new PfConceptKey(), null);
+ new JpaAutomationCompositionElement("key", "key", new PfConceptKey(), null);
}).hasMessageMatching("state" + NULL_ERROR);
assertNotNull(new JpaAutomationCompositionElement());
assertNotNull(new JpaAutomationCompositionElement("key", "key"));
- assertNotNull(new JpaAutomationCompositionElement("key", "key", new PfConceptKey(),
- new PfConceptKey("participant", "0.0.1"), AutomationCompositionState.UNINITIALISED));
+ assertNotNull(new JpaAutomationCompositionElement("key", "key",
+ new PfConceptKey(), AutomationCompositionState.UNINITIALISED));
}
@Test
testJpaAutomationCompositionElement.setState(AutomationCompositionState.UNINITIALISED);
assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
- testJpaAutomationCompositionElement.setParticipantType(new PfConceptKey("dummy", "0.0.1"));
- assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
- testJpaAutomationCompositionElement.setParticipantType(new PfConceptKey("participantType", "0.0.1"));
assertEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
+ testJpaAutomationCompositionElement.setParticipantId(UUID.randomUUID().toString());
+ assertNotEquals(0, testJpaAutomationCompositionElement.compareTo(otherJpaAutomationCompositionElement));
assertEquals(testJpaAutomationCompositionElement,
new JpaAutomationCompositionElement(testJpaAutomationCompositionElement));
var automationCompositionElement = new AutomationCompositionElement();
automationCompositionElement.setId(UUID.fromString(ELEMENT_ID));
automationCompositionElement.setDefinition(new ToscaConceptIdentifier("aceDef", "0.0.1"));
- automationCompositionElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1"));
automationCompositionElement.setParticipantId(CommonTestData.getParticipantId());
automationCompositionElement.setProperties(Map.of("key", "{}"));
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.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Test the {@link JpaParticipant} class.
private Participant createParticipantInstance() {
var testParticipant = new Participant();
testParticipant.setParticipantId(UUID.randomUUID());
- testParticipant.setParticipantType(new ToscaConceptIdentifier("participantTypeName", "0.0.1"));
testParticipant.setParticipantSupportedElementTypes(new LinkedHashMap<>());
return testParticipant;
/*-
* ============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.
assertNotEquals(participantId, participantUpdates.get(0).getParticipantId());
acElement.setParticipantId(participantId);
- acElement.setParticipantType(TYPE);
AcmUtils.prepareParticipantUpdate(acElement, participantUpdates);
assertEquals(participantId, participantUpdates.get(1).getParticipantId());
}
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class CommonTestData {
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("description", DESCRIPTION);
map.put("participantId", getParticipantId());
- map.put("participantType", getParticipantType());
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
map.put("participantSupportedElementTypes", new ArrayList<>());
}
return map;
}
- /**
- * Returns participantType for test cases.
- *
- * @return participant Type
- */
- public static ToscaConceptIdentifier getParticipantType() {
- final var participantId = new ToscaConceptIdentifier();
- participantId.setName("K8sParticipant0");
- participantId.setVersion("1.0.0");
- return participantId;
- }
-
/**
* Returns participantId for test cases.
*
/*-
* ============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");
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
final ParticipantRegister participantRegisterMsg = new ParticipantRegister();
participantRegisterMsg.setParticipantId(CommonTestData.getParticipantId());
participantRegisterMsg.setTimestamp(Instant.now());
- participantRegisterMsg.setParticipantType(getParticipantType());
synchronized (lockit) {
ParticipantMessagePublisher participantMessagePublisher =
final ParticipantDeregister participantDeregisterMsg = new ParticipantDeregister();
participantDeregisterMsg.setParticipantId(CommonTestData.getParticipantId());
participantDeregisterMsg.setTimestamp(Instant.now());
- participantDeregisterMsg.setParticipantType(getParticipantType());
synchronized (lockit) {
ParticipantMessagePublisher participantMessagePublisher =
assertThatCode(() -> publisher.sendHeartbeat(heartbeat)).doesNotThrowAnyException();
}
}
-
- private ToscaConceptIdentifier getParticipantType() {
- return new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
- }
}
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to hold/create all parameters for test cases.
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("description", DESCRIPTION);
map.put("participantId", getParticipantId());
- map.put("participantType", getParticipantType());
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
map.put("participantSupportedElementTypes", new ArrayList<>());
}
return topicParams;
}
- /**
- * Returns participantType for test cases.
- *
- * @return participant Type
- */
- public static ToscaConceptIdentifier getParticipantType() {
- return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
- }
-
-
/**
* Returns participantId for test cases.
*
/*-
* ============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.
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.common.utils.coder.YamlJsonTranslator;
import org.onap.policy.common.utils.resources.ResourceUtils;
-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;
public static ParticipantUpdate createParticipantUpdateMsg() {
final var participantUpdateMsg = new ParticipantUpdate();
var participantId = CommonTestData.getParticipantId();
- var participantType =
- new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
participantUpdateMsg.setParticipantId(participantId);
participantUpdateMsg.setTimestamp(Instant.now());
- participantUpdateMsg.setParticipantType(participantType);
participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
participantUpdateMsg.setMessageId(UUID.randomUUID());
/*-
* ============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 class AutomationCompositionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionHandler.class);
- private final ToscaConceptIdentifier participantType;
private final UUID participantId;
private final ParticipantMessagePublisher publisher;
* @param publisher the ParticipantMessage Publisher
*/
public AutomationCompositionHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher) {
- this.participantType = parameters.getIntermediaryParameters().getParticipantType();
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.publisher = publisher;
}
var automationCompositionStateChangeAck =
new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionStateChangeAck.setParticipantId(participantId);
- automationCompositionStateChangeAck.setParticipantType(participantType);
automationCompositionStateChangeAck.setAutomationCompositionId(automationCompositionId);
acElement.setOrderedState(orderedState);
acElement.setState(newState);
var automationCompositionAck =
new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionAck.setParticipantId(participantId);
- automationCompositionAck.setParticipantType(participantType);
automationCompositionAck.setMessage("Automation composition " + stateChangeMsg.getAutomationCompositionId()
+ " does not use this participant " + participantId);
automationCompositionAck.setResult(false);
public void handleAutomationCompositionUpdate(AutomationCompositionUpdate updateMsg,
List<AutomationCompositionElementDefinition> acElementDefinitions) {
- if (!updateMsg.appliesTo(participantType, participantId)) {
+ if (!updateMsg.appliesTo(participantId)) {
return;
}
var automationCompositionUpdateAck =
new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK);
automationCompositionUpdateAck.setParticipantId(participantId);
- automationCompositionUpdateAck.setParticipantType(participantType);
automationCompositionUpdateAck.setMessage("Automation composition " + updateMsg.getAutomationCompositionId()
+ " already defined on participant " + participantId);
var acElementList = updateMsg.getParticipantUpdatesList().stream()
.flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
- .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+ .filter(element -> participantId.equals(element.getParticipantId())).collect(Collectors.toList());
handleAutomationCompositionElementUpdate(acElementList, acElementDefinitions, updateMsg.getStartPhase(),
updateMsg.getAutomationCompositionId());
List<ParticipantUpdates> participantUpdates) {
var acElementList = participantUpdates.stream()
.flatMap(participantUpdate -> participantUpdate.getAutomationCompositionElementList().stream())
- .filter(element -> participantType.equals(element.getParticipantType())).collect(Collectors.toList());
+ .filter(element -> participantId.equals(element.getParticipantId())).collect(Collectors.toList());
for (var element : acElementList) {
elementsOnThisParticipant.put(element.getId(), element);
var automationCompositionAck =
new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionAck.setParticipantId(participantId);
- automationCompositionAck.setParticipantType(participantType);
automationCompositionAck.setMessage("Automation composition is already in state " + orderedState);
automationCompositionAck.setResult(false);
automationCompositionAck.setAutomationCompositionId(automationComposition.getInstanceId());
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatusReq;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
public class ParticipantHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantHandler.class);
- @Getter
- private final ToscaConceptIdentifier participantType;
-
@Getter
private final UUID participantId;
*/
public ParticipantHandler(ParticipantParameters parameters, ParticipantMessagePublisher publisher,
AutomationCompositionHandler automationCompositionHandler) {
- this.participantType = parameters.getIntermediaryParameters().getParticipantType();
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.publisher = publisher;
this.automationCompositionHandler = automationCompositionHandler;
* @return true if it applies, false otherwise
*/
public boolean appliesTo(ParticipantMessage participantMsg) {
- return participantMsg.appliesTo(participantType, participantId);
+ return participantMsg.appliesTo(participantId);
}
/**
* @return true if it applies, false otherwise
*/
public boolean appliesTo(ParticipantAckMessage participantMsg) {
- return participantMsg.appliesTo(participantType, participantId);
+ return participantMsg.appliesTo(participantId);
}
/**
public void sendParticipantRegister() {
var participantRegister = new ParticipantRegister();
participantRegister.setParticipantId(participantId);
- participantRegister.setParticipantType(participantType);
participantRegister.setParticipantSupportedElementType(supportedAcElementTypes);
publisher.sendParticipantRegister(participantRegister);
public void sendParticipantDeregister() {
var participantDeregister = new ParticipantDeregister();
participantDeregister.setParticipantId(participantId);
- participantDeregister.setParticipantType(participantType);
publisher.sendParticipantDeregister(participantDeregister);
}
if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) {
// This message is to commission the automation composition
for (var participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) {
- if (participantDefinition.getParticipantType().equals(participantType)) {
+ if (participantDefinition.getParticipantId().equals(participantId)) {
acElementDefsMap.get(participantUpdateMsg.getCompositionId())
.addAll(participantDefinition.getAutomationCompositionElementDefinitionList());
break;
participantUpdateAck.setMessage("Participant Update Ack message");
participantUpdateAck.setResult(true);
participantUpdateAck.setParticipantId(participantId);
- participantUpdateAck.setParticipantType(participantType);
participantUpdateAck.setState(ParticipantState.ON_LINE);
publisher.sendParticipantUpdateAck(participantUpdateAck);
}
public ParticipantStatus makeHeartbeat(boolean responseToParticipantStatusReq) {
var heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(participantId);
- heartbeat.setParticipantType(participantType);
heartbeat.setState(ParticipantState.ON_LINE);
heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList());
for (var acElementDefsOnThisParticipant : acElementDefsMap.values()) {
var participantDefinition = new ParticipantDefinition();
participantDefinition.setParticipantId(participantId);
- participantDefinition.setParticipantType(participantType);
participantDefinition.setAutomationCompositionElementDefinitionList(acElementDefsOnThisParticipant);
participantDefinitionList.add(participantDefinition);
}
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;
/**
* Class to hold all parameters needed for participant component.
@NotBlank
private String description;
- // The participant type of this participant
- @NotNull
- @Valid
- private ToscaConceptIdentifier participantType;
-
// The time interval for periodic reporting of status to the CLAMP ACM server
@Valid
@Positive
/*-
* ============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.
var participantUpdate = new ParticipantUpdates();
participantUpdate.setParticipantId(partecipantId);
var element = new AutomationCompositionElement();
- element.setParticipantType(definition);
element.setDefinition(definition);
participantUpdate.setAutomationCompositionElementList(List.of(element));
updateMsg.setParticipantUpdatesList(List.of(participantUpdate));
stateChangePassive.setParticipantId(CommonTestData.getRndParticipantId());
assertDoesNotThrow(() -> ach.handleAutomationCompositionStateChange(stateChangePassive, List.of()));
}
-
}
/*-
* ============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.
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class ParticipantHandlerTest {
var participantHandler = commonTestData.getMockParticipantHandler();
- var participantType = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
var participantId = CommonTestData.getParticipantId();
participantUpdateMsg.setAutomationCompositionId(CommonTestData.AC_ID_1);
participantUpdateMsg.setCompositionId(CommonTestData.AC_ID_1);
participantUpdateMsg.setParticipantId(participantId);
- participantUpdateMsg.setParticipantType(participantType);
participantUpdateMsg.setMessageId(UUID.randomUUID());
participantUpdateMsg.setTimestamp(Instant.ofEpochMilli(3000));
private ParticipantUpdate setListParticipantDefinition(ParticipantUpdate participantUpdateMsg) {
var def = new ParticipantDefinition();
def.setParticipantId(CommonTestData.getParticipantId());
- def.setParticipantType(new ToscaConceptIdentifier(ID_NAME, ID_VERSION));
participantUpdateMsg.setParticipantDefinitionUpdates(List.of(def));
return participantUpdateMsg;
}
new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATUS);
assertTrue(participantHandler.appliesTo(participantMsg));
- var emptyid = new ToscaConceptIdentifier("", ID_VERSION);
- participantMsg.setParticipantType(emptyid);
+ var randomId = UUID.randomUUID();
+ participantMsg.setParticipantId(randomId);
assertFalse(participantHandler.appliesTo(participantMsg));
}
map.put("name", name);
map.put("participantId", getParticipantId());
map.put("description", DESCRIPTION);
- map.put("participantType", getDefinition());
map.put("reportingTimeIntervalMs", TIME_INTERVAL);
map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
map.put("participantSupportedElementTypes", new ArrayList<>());
/*-
* ============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");
subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE,
element.getDefinition().getName(), ValidationStatus.INVALID,
"Participant with ID " + element.getParticipantId() + " is not registered"));
- } else if (!p.getParticipantType().equals(element.getParticipantType())) {
+ } else if (!p.getParticipantId().equals(element.getParticipantId())) {
subResult.addResult(new ObjectValidationResult(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE,
element.getDefinition().getName(), ValidationStatus.INVALID,
- "Participant with ID " + element.getParticipantType() + " - " + element.getParticipantId()
+ "Participant with ID " + " - " + element.getParticipantId()
+ " is not registered"));
}
result.addResult(subResult);
saveParticipantStatus(participantRegisterMsg);
participantRegisterAckPublisher.send(participantRegisterMsg.getMessageId(),
- participantRegisterMsg.getParticipantId(), participantRegisterMsg.getParticipantType());
+ participantRegisterMsg.getParticipantId());
}
/**
ParticipantRegister registerMessage = (ParticipantRegister) participantMessage;
var participant = new Participant();
participant.setParticipantId(participantMessage.getParticipantId());
- participant.setParticipantType(registerMessage.getParticipantType());
participant.setParticipantSupportedElementTypes(listToMap(registerMessage
.getParticipantSupportedElementType()));
participant.setParticipantState(ParticipantState.ON_LINE);
/*-
* ============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.
import io.micrometer.core.annotation.Timed;
import java.util.UUID;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Component;
/**
*
* @param responseTo the original request id in the request.
* @param participantId the participant Id
- * @param participantType the participant Type
*/
@Timed(value = "publisher.participant_register_ack", description = "PARTICIPANT_REGISTER_ACK messages published")
- public void send(UUID responseTo, UUID participantId, ToscaConceptIdentifier participantType) {
+ public void send(UUID responseTo, UUID participantId) {
var message = new ParticipantRegisterAck();
message.setParticipantId(participantId);
- message.setParticipantType(participantType);
message.setResponseTo(responseTo);
message.setMessage("Participant Register Ack");
message.setResult(true);
/*-
* ============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.
* ================================================================================
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
public void sendComissioningBroadcast(AutomationCompositionDefinition acmDefinition) {
- sendCommissioning(acmDefinition, null, null);
+ sendCommissioning(acmDefinition, null);
}
/**
* Send ParticipantUpdate to Participant
- * if participantType and participantId are null then message is broadcast.
+ * if participantId is null then message is broadcast.
*
- * @param participantType the ParticipantType
* @param participantId the ParticipantId
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
- public void sendCommissioning(ToscaConceptIdentifier participantType, UUID participantId) {
+ public void sendCommissioning(UUID participantId) {
var list = acDefinitionProvider.getAllAcDefinitions();
if (list.isEmpty()) {
LOGGER.warn("No tosca service template found, cannot send participantupdate");
}
for (var acmDefinition : list) {
- sendCommissioning(acmDefinition, participantType, participantId);
+ sendCommissioning(acmDefinition, participantId);
}
}
/**
* Send ParticipantUpdate to Participant
- * if participantType and participantId are null then message is broadcast.
+ * if participantId is null then message is broadcast.
*
* @param acmDefinition the AutomationComposition Definition
- * @param participantType the ParticipantType
* @param participantId the ParticipantId
*/
@Timed(value = "publisher.participant_update", description = "PARTICIPANT_UPDATE messages published")
public void sendCommissioning(AutomationCompositionDefinition acmDefinition,
- ToscaConceptIdentifier participantType, UUID participantId) {
+ UUID participantId) {
var message = new ParticipantUpdate();
message.setCompositionId(acmDefinition.getCompositionId());
- message.setParticipantType(participantType);
message.setParticipantId(participantId);
message.setTimestamp(Instant.now());
if (ParticipantUtils.checkIfNodeTemplateIsAutomationCompositionElement(toscaInputEntry.getValue(),
toscaServiceTemplate)) {
AcmUtils.prepareParticipantDefinitionUpdate(
- ParticipantUtils.findParticipantType(toscaInputEntry.getValue().getProperties()),
+ participantId,
toscaInputEntry.getKey(), toscaInputEntry.getValue(), participantDefinitionUpdates);
}
}
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionHandlerTest {
private static final String AC_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/acm/AutomationComposition.json";
private static final UUID IDENTIFIER = UUID.randomUUID();
- private static final ToscaConceptIdentifier PARTICIPANT_TYPE =
- new ToscaConceptIdentifier("ParticipantType", "1.0.0");
@Test
void testTriggerAutomationCompositionSupervision() throws AutomationCompositionException {
var automationCompositionAckMessage =
new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE_ACK);
automationCompositionAckMessage.setParticipantId(CommonTestData.getParticipantId());
- automationCompositionAckMessage.setParticipantType(PARTICIPANT_TYPE);
automationCompositionAckMessage.setAutomationCompositionResultMap(Map.of());
automationCompositionAckMessage.setAutomationCompositionId(IDENTIFIER);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
void testParticipantUpdateAck() {
var participantUpdateAckMessage = new ParticipantUpdateAck();
participantUpdateAckMessage.setParticipantId(CommonTestData.getParticipantId());
- participantUpdateAckMessage.setParticipantType(PARTICIPANT_TYPE);
participantUpdateAckMessage.setState(ParticipantState.ON_LINE);
var handler = createSupervisionHandler(mock(AutomationCompositionProvider.class),
mock(AutomationCompositionUpdatePublisher.class), mock(AutomationCompositionStateChangePublisher.class),
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionParticipantHandlerTest {
- private static final ToscaConceptIdentifier PARTICIPANT_TYPE =
- new ToscaConceptIdentifier("ParticipantType", "1.0.0");
+ private static final ToscaConceptIdentifier PARTICIPANT_ID = new ToscaConceptIdentifier("ParticipantId", "1.0.0");
@Test
void testHandleParticipantDeregister() {
- var participant = CommonTestData.createParticipant(PARTICIPANT_TYPE, CommonTestData.getParticipantId());
+ var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
var participantDeregisterMessage = new ParticipantDeregister();
participantDeregisterMessage.setMessageId(UUID.randomUUID());
participantDeregisterMessage.setParticipantId(CommonTestData.getParticipantId());
- participantDeregisterMessage.setParticipantType(PARTICIPANT_TYPE);
var participantDeregisterAckPublisher = mock(ParticipantDeregisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider,
mock(ParticipantRegisterAckPublisher.class), participantDeregisterAckPublisher);
var participantRegisterMessage = new ParticipantRegister();
participantRegisterMessage.setMessageId(UUID.randomUUID());
participantRegisterMessage.setParticipantId(CommonTestData.getParticipantId());
- participantRegisterMessage.setParticipantType(PARTICIPANT_TYPE);
var participantProvider = mock(ParticipantProvider.class);
var participantRegisterAckPublisher = mock(ParticipantRegisterAckPublisher.class);
var handler = new SupervisionParticipantHandler(participantProvider, participantRegisterAckPublisher,
verify(participantProvider).saveParticipant(any());
verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(),
- CommonTestData.getParticipantId(), PARTICIPANT_TYPE);
+ CommonTestData.getParticipantId());
}
@Test
void testHandleParticipantStatus() {
var participantStatusMessage = new ParticipantStatus();
participantStatusMessage.setParticipantId(CommonTestData.getParticipantId());
- 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 = CommonTestData.createParticipant(PARTICIPANT_TYPE, CommonTestData.getParticipantId());
+ var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
.thenReturn(Optional.of(participant));
handler.handleParticipantMessage(participantStatusMessage);
.thenReturn(List.of(automationComposition));
var participantProvider = mock(ParticipantProvider.class);
- var participant = CommonTestData.createParticipant(PARTICIPANT_TYPE, CommonTestData.getParticipantId());
+ var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.getParticipants()).thenReturn(List.of(participant));
var automationCompositionUpdatePublisher = mock(AutomationCompositionUpdatePublisher.class);
acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().setMaxWaitMs(-1);
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
- var participant = CommonTestData.createParticipant(PARTICIPANT_TYPE, CommonTestData.getParticipantId());
+ var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
participant.setParticipantState(ParticipantState.OFF_LINE);
var participantProvider = mock(ParticipantProvider.class);
when(participantProvider.getParticipants()).thenReturn(List.of(participant));
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class SupervisionMessagesTest {
var publisher = new ParticipantRegisterAckPublisher();
var topicSink = mock(TopicSink.class);
publisher.active(List.of(topicSink));
- publisher.send(UUID.randomUUID(), CommonTestData.getParticipantId(), getParticipantType());
+ publisher.send(UUID.randomUUID(), CommonTestData.getParticipantId());
verify(topicSink).send(anyString());
}
- private ToscaConceptIdentifier getParticipantType() {
- return new ToscaConceptIdentifier("org.onap.policy.acm.PolicyAutomationCompositionParticipant", "2.3.1");
- }
-
@Test
void testParticipantDeregisterAckPublisher() {
var publisher = new ParticipantDeregisterAckPublisher();
/*-
* ============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.
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to hold/create all parameters for test cases.
* @return a List of Participants
*/
public static List<Participant> createParticipants() {
- var participant1 = createParticipant(
- new ToscaConceptIdentifier("org.onap.policy.clamp.acm.KubernetesParticipant", "2.3.4"),
- UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c02"));
- var participant2 = createParticipant(
- new ToscaConceptIdentifier("org.onap.policy.clamp.acm.HttpParticipant", "2.3.4"),
- UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c01"));
- var participant3 = createParticipant(
- new ToscaConceptIdentifier("org.onap.policy.clamp.acm.PolicyParticipant", "2.3.1"),
- UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03"));
+ var participant1 = createParticipant(UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c02"));
+ var participant2 = createParticipant(UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c01"));
+ var participant3 = createParticipant(UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03"));
return List.of(participant1, participant2, participant3);
}
/**
* Create a new Participant.
*
- * @param participantType the participant Type
* @param participantId the participant id
* @return a new Participant
*/
- public static Participant createParticipant(ToscaConceptIdentifier participantType,
- UUID participantId) {
+ public static Participant createParticipant(UUID participantId) {
var participant = new Participant();
participant.setParticipantId(participantId);
- participant.setParticipantType(participantType);
return participant;
}