From 7f762dfa19f673241f8ea1b2ff3d56d2d58bdcdb Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Mon, 30 Jan 2023 13:43:10 +0000 Subject: Refactor ACM Update message to ACM Deploy message in ACM Refactor ACM Update message to ACM Deploy message in ACM and add AcElementDeploy in Deploy message. AutomationCompositionElement will be removed from the message after POLICY-4506 and POLICY-4507. Issue-ID: POLICY-4543 Change-Id: I8444e15b3b4cb1209ffd083fb965e0707fbd9625 Signed-off-by: FrancescoFioraEst --- .../clamp/models/acm/concepts/AcElementDeploy.java | 67 +++++++++++++++++ .../models/acm/concepts/AcElementDeployAck.java | 45 +++++++++++ .../concepts/AutomationCompositionElementAck.java | 42 ----------- .../models/acm/concepts/ParticipantDeploy.java | 60 +++++++++++++++ .../models/acm/concepts/ParticipantUpdates.java | 56 -------------- .../participant/AutomationCompositionAck.java | 69 ----------------- .../participant/AutomationCompositionDeploy.java | 64 ++++++++++++++++ .../AutomationCompositionDeployAck.java | 70 +++++++++++++++++ .../participant/AutomationCompositionUpdate.java | 64 ---------------- .../dmaap/participant/ParticipantMessageType.java | 10 +-- .../policy/clamp/models/acm/utils/AcmUtils.java | 10 +-- .../participant/AutomationCompositionAckTest.java | 66 ---------------- .../AutomationCompositionDeployAckTest.java | 66 ++++++++++++++++ .../AutomationCompositionDeployTest.java | 87 ++++++++++++++++++++++ .../AutomationCompositionUpdateTest.java | 87 ---------------------- .../dmaap/participant/ParticipantPojosTest.java | 13 ++-- .../clamp/models/acm/utils/AcmUtilsTest.java | 4 +- 17 files changed, 476 insertions(+), 404 deletions(-) create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDeploy.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAck.java delete mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java create mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java delete mode 100644 models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java (limited to 'models') diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java new file mode 100644 index 000000000..6b6eda319 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeploy.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.function.UnaryOperator; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to represent a automation composition instance to send for deploy. + */ +@NoArgsConstructor +@Data +@ToString +public class AcElementDeploy { + + @NonNull + private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + @NonNull + private DeployOrder orderedState = DeployOrder.DEPLOY; + + private ToscaServiceTemplate toscaServiceTemplateFragment; + + // A map indexed by the property name. Each map entry is the serialized value of the property, + // which can be deserialized into an instance of the type of the property. + private Map properties = new LinkedHashMap<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param otherElement the other element to copy from + */ + public AcElementDeploy(final AcElementDeploy otherElement) { + this.definition = new ToscaConceptIdentifier(otherElement.definition); + this.orderedState = otherElement.orderedState; + this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment; + this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java new file mode 100644 index 000000000..2db1555bf --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementDeployAck.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@AllArgsConstructor +@ToString +public class AcElementDeployAck { + + // State of the AutomationCompositionElement + private AutomationCompositionState state; + + // State of the AutomationCompositionElement + private DeployState deployState; + + // Result: Success/Fail. + private Boolean result; + + // Message indicating reason for failure + private String message; +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java deleted file mode 100644 index b100f28c0..000000000 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementAck.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.concepts; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -@Getter -@Setter -@AllArgsConstructor -@ToString -public class AutomationCompositionElementAck { - - // State of the AutomationCompositionElement - private AutomationCompositionState state; - - // Result: Success/Fail. - private Boolean result; - - // Message indicating reason for failure - private String message; -} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDeploy.java new file mode 100644 index 000000000..337a09d17 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantDeploy.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.concepts; + +import java.util.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; + +/** + * Class to represent a participant definition instance for Deploy. + */ +@Getter +@NoArgsConstructor +@Data +@ToString +public class ParticipantDeploy { + + private UUID participantId; + + // List of AutomationCompositionElement values for a particular participant + private List automationCompositionElementList = new ArrayList<>(); + + // List of Automation Composition Element Deploy for a particular participant + private List acElementList = new ArrayList<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param copyConstructor the participant with updates to copy from + */ + public ParticipantDeploy(final ParticipantDeploy copyConstructor) { + this.participantId = copyConstructor.participantId; + this.automationCompositionElementList = PfUtils.mapList( + copyConstructor.automationCompositionElementList, AutomationCompositionElement::new); + this.acElementList = PfUtils.mapList(copyConstructor.acElementList, AcElementDeploy::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java deleted file mode 100644 index 031fd5c02..000000000 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantUpdates.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.concepts; - -import java.util.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; - -/** - * Class to represent a participant definition update instance. - */ -@Getter -@NoArgsConstructor -@Data -@ToString -public class ParticipantUpdates { - - private UUID participantId; - - // List of AutomationCompositionElement values for a particular participant - private List automationCompositionElementList = new ArrayList<>(); - - /** - * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. - * - * @param participantUpdates the participant with updates to copy from - */ - public ParticipantUpdates(final ParticipantUpdates participantUpdates) { - this.participantId = participantUpdates.participantId; - this.automationCompositionElementList = PfUtils.mapList( - participantUpdates.automationCompositionElementList, AutomationCompositionElement::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java deleted file mode 100644 index c1ec67c83..000000000 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.messages.dmaap.participant; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; -import java.util.function.UnaryOperator; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; -import org.onap.policy.models.base.PfUtils; - -/** - * Class to represent the AUTOMATION_COMPOSITION_ACK message that a participant sends - * to automation composition runtime as an acknowledgement to either AUTOMATION_COMPOSITION_UPDATE - * or AUTOMATION_COMPOSITION_STATE_CHANGE message. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class AutomationCompositionAck extends ParticipantAckMessage { - - private UUID automationCompositionId; - private Integer startPhase; - - // A map with AutomationCompositionElementID as its key, and a pair of result and message as value per - // AutomationCompositionElement. - private Map automationCompositionResultMap = new LinkedHashMap<>(); - - /** - * Constructor for instantiating ParticipantRegisterAck class with message name. - * - */ - public AutomationCompositionAck(final ParticipantMessageType messageType) { - super(messageType); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public AutomationCompositionAck(final AutomationCompositionAck source) { - super(source); - this.automationCompositionId = source.automationCompositionId; - this.automationCompositionResultMap = - PfUtils.mapMap(source.automationCompositionResultMap, UnaryOperator.identity()); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java new file mode 100644 index 000000000..f0ba43f2a --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeploy.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.ArrayList; +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; +import org.onap.policy.models.base.PfUtils; + +/** + * Class to represent the AUTOMATION_COMPOSITION_DEPLOY message that the automation composition runtime sends to a + * participant. When a participant receives this message, it creates the automation composition elements contained in + * the message and sets them to state PASSIVE. subsequent AUTOMATION_COMPOSITION_STATE_CHANGE messages are used to + * activate the automation compositions. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionDeploy extends ParticipantMessage { + + // A list of ParticipantUpdates instances which carries details of an updated participant. + private List participantUpdatesList = new ArrayList<>(); + private Integer startPhase = 0; + + /** + * Constructor for instantiating class with message name. + * + */ + public AutomationCompositionDeploy() { + super(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public AutomationCompositionDeploy(AutomationCompositionDeploy source) { + super(source); + this.startPhase = source.startPhase; + this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantDeploy::new); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAck.java new file mode 100644 index 000000000..8d52955cc --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAck.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck; +import org.onap.policy.models.base.PfUtils; + +/** + * Class to represent the AUTOMATION_COMPOSITION_ACK message that a participant sends + * to automation composition runtime as an acknowledgement to either AUTOMATION_COMPOSITION_UPDATE + * or AUTOMATION_COMPOSITION_STATE_CHANGE message. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class AutomationCompositionDeployAck extends ParticipantAckMessage { + + private UUID automationCompositionId; + private Integer startPhase; + + // A map with AutomationCompositionElementID as its key, and a pair of result and message as value per + // AutomationCompositionElement. + private Map automationCompositionResultMap = new LinkedHashMap<>(); + + /** + * Constructor for instantiating ParticipantRegisterAck class with message name. + * + */ + public AutomationCompositionDeployAck(final ParticipantMessageType messageType) { + super(messageType); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public AutomationCompositionDeployAck(final AutomationCompositionDeployAck source) { + super(source); + this.automationCompositionId = source.automationCompositionId; + this.startPhase = source.startPhase; + this.automationCompositionResultMap = + PfUtils.mapMap(source.automationCompositionResultMap, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java deleted file mode 100644 index 6bc79f67e..000000000 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdate.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.messages.dmaap.participant; - -import java.util.ArrayList; -import java.util.List; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; -import org.onap.policy.models.base.PfUtils; - -/** - * Class to represent the AUTOMATION_COMPOSITION_UPDATE message that the automation composition runtime sends to a - * participant. When a participant receives this message, it creates the automation composition elements contained in - * the message and sets them to state PASSIVE. subsequent AUTOMATION_COMPOSITION_STATE_CHANGE messages are used to - * activate the automation compositions. - */ -@Getter -@Setter -@ToString(callSuper = true) -public class AutomationCompositionUpdate extends ParticipantMessage { - - // A list of ParticipantUpdates instances which carries details of an updated participant. - private List participantUpdatesList = new ArrayList<>(); - private Integer startPhase = 0; - - /** - * Constructor for instantiating class with message name. - * - */ - public AutomationCompositionUpdate() { - super(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); - } - - /** - * Constructs the object, making a deep copy. - * - * @param source source from which to copy - */ - public AutomationCompositionUpdate(AutomationCompositionUpdate source) { - super(source); - this.startPhase = source.startPhase; - this.participantUpdatesList = PfUtils.mapList(source.participantUpdatesList, ParticipantUpdates::new); - } -} diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java index 4f6bcdbf3..502896188 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java @@ -37,10 +37,10 @@ public enum ParticipantMessageType { PARTICIPANT_STATE_CHANGE, /** - * Used by acm runtime to update the automation compositions running on participants, triggers a - * PARTICIPANT_STATUS message with the result of the AUTOMATION_COMPOSITION_UPDATE operation. + * Used by acm runtime to deploy the automation compositions running on participants, triggers a + * PARTICIPANT_STATUS message with the result of the AUTOMATION_COMPOSITION_DEPLOY operation. */ - AUTOMATION_COMPOSITION_UPDATE, + AUTOMATION_COMPOSITION_DEPLOY, /** * Used by acm runtime to change the state of automation compositions in participants, triggers a @@ -86,10 +86,10 @@ public enum ParticipantMessageType { PARTICIPANT_UPDATE_ACK, /** - * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_UPDATE message + * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_DEPLOY message * from automation composition runtime. */ - AUTOMATION_COMPOSITION_UPDATE_ACK, + AUTOMATION_COMPOSITION_DEPLOY_ACK, /** * Used by participant to acknowledge the receipt of AUTOMATION_COMPOSITION_STATE_CHANGE message diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java index 9f73cb144..7d1e80f54 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java @@ -41,7 +41,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; import org.onap.policy.clamp.models.acm.concepts.NodeTemplateState; import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; -import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ObjectValidationResult; import org.onap.policy.common.parameters.ValidationResult; @@ -71,14 +71,14 @@ public final class AcmUtils { * @param participantUpdates list of participantUpdates */ public static void prepareParticipantUpdate(AutomationCompositionElement acElement, - List participantUpdates) { + List participantUpdates) { if (participantUpdates.isEmpty()) { participantUpdates.add(getAutomationCompositionElementList(acElement)); return; } var participantExists = false; - for (ParticipantUpdates participantUpdate : participantUpdates) { + for (ParticipantDeploy participantUpdate : participantUpdates) { if (participantUpdate.getParticipantId().equals(acElement.getParticipantId())) { participantUpdate.getAutomationCompositionElementList().add(acElement); participantExists = true; @@ -89,8 +89,8 @@ public final class AcmUtils { } } - private static ParticipantUpdates getAutomationCompositionElementList(AutomationCompositionElement acElement) { - var participantUpdate = new ParticipantUpdates(); + private static ParticipantDeploy getAutomationCompositionElementList(AutomationCompositionElement acElement) { + var participantUpdate = new ParticipantDeploy(); participantUpdate.setParticipantId(acElement.getParticipantId()); participantUpdate.getAutomationCompositionElementList().add(acElement); return participantUpdate; diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java deleted file mode 100644 index 8c5528cc6..000000000 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck; -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; - -class AutomationCompositionAckTest { - - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new AutomationCompositionAck((AutomationCompositionAck) null)) - .isInstanceOf(NullPointerException.class); - - final var orig = new AutomationCompositionAck(ParticipantMessageType.AUTOMATION_COMPOSITION_UPDATE); - - // verify with null values - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new AutomationCompositionAck(orig).toString())); - - // verify with all values - orig.setAutomationCompositionId(UUID.randomUUID()); - orig.setParticipantId(CommonTestData.getParticipantId()); - var acElementResult = new AutomationCompositionElementAck(AutomationCompositionState.UNINITIALISED, - true, "AutomationCompositionElement result"); - final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult); - orig.setAutomationCompositionResultMap(automationCompositionResultMap); - - orig.setResponseTo(UUID.randomUUID()); - orig.setResult(true); - orig.setMessage("Successfully processed AutomationCompositionUpdate message"); - - assertEquals(removeVariableFields(orig.toString()), - removeVariableFields(new AutomationCompositionAck(orig).toString())); - - assertSerializable(orig, AutomationCompositionAck.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java new file mode 100644 index 000000000..038c140ed --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployAckTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck; +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; + +class AutomationCompositionDeployAckTest { + + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionDeployAck((AutomationCompositionDeployAck) null)) + .isInstanceOf(NullPointerException.class); + + final var orig = new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_DEPLOY); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionDeployAck(orig).toString())); + + // verify with all values + orig.setAutomationCompositionId(UUID.randomUUID()); + orig.setParticipantId(CommonTestData.getParticipantId()); + var acElementResult = new AcElementDeployAck(AutomationCompositionState.UNINITIALISED, null, + true, "AutomationCompositionElement result"); + final var automationCompositionResultMap = Map.of(UUID.randomUUID(), acElementResult); + orig.setAutomationCompositionResultMap(automationCompositionResultMap); + + orig.setResponseTo(UUID.randomUUID()); + orig.setResult(true); + orig.setMessage("Successfully processed AutomationCompositionDeploy message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new AutomationCompositionDeployAck(orig).toString())); + + assertSerializable(orig, AutomationCompositionDeployAck.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java new file mode 100644 index 000000000..2912dee9b --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionDeployTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2023 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.models.acm.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; +import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; +import org.onap.policy.clamp.models.acm.utils.CommonTestData; +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; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; + +/** + * Test the copy constructor. + */ +class AutomationCompositionDeployTest { + @Test + void testCopyConstructor() throws CoderException { + assertThatThrownBy(() -> new AutomationCompositionDeploy(null)).isInstanceOf(NullPointerException.class); + + var orig = new AutomationCompositionDeploy(); + // verify with all values + orig.setAutomationCompositionId(UUID.randomUUID()); + orig.setParticipantId(null); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + var acElement = new AutomationCompositionElement(); + acElement.setId(UUID.randomUUID()); + var id = new ToscaConceptIdentifier("id", "1.2.3"); + acElement.setDefinition(id); + acElement.setDescription("Description"); + acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); + acElement.setState(AutomationCompositionState.PASSIVE); + + var participantId = CommonTestData.getParticipantId(); + acElement.setParticipantId(participantId); + + var property = new ToscaProperty(); + property.setName("test"); + property.setType("testType"); + var standardCoder = new StandardCoder(); + var json = standardCoder.encode(property); + var propertiesMap = Map.of("Prop1", (Object) json); + acElement.setProperties(propertiesMap); + + var participantDeploy = new ParticipantDeploy(); + participantDeploy.setParticipantId(participantId); + participantDeploy.setAutomationCompositionElementList(List.of(acElement)); + orig.setParticipantUpdatesList(List.of(participantDeploy)); + + var other = new AutomationCompositionDeploy(orig); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + assertSerializable(orig, AutomationCompositionDeploy.class); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java deleted file mode 100644 index c1be28958..000000000 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.models.acm.messages.dmaap.participant; - -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable; -import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; - -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.junit.jupiter.api.Test; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; -import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; -import org.onap.policy.clamp.models.acm.utils.CommonTestData; -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; -import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; - -/** - * Test the copy constructor. - */ -class AutomationCompositionUpdateTest { - @Test - void testCopyConstructor() throws CoderException { - assertThatThrownBy(() -> new AutomationCompositionUpdate(null)).isInstanceOf(NullPointerException.class); - - var orig = new AutomationCompositionUpdate(); - // verify with all values - orig.setAutomationCompositionId(UUID.randomUUID()); - orig.setParticipantId(null); - orig.setMessageId(UUID.randomUUID()); - orig.setTimestamp(Instant.ofEpochMilli(3000)); - - var acElement = new AutomationCompositionElement(); - acElement.setId(UUID.randomUUID()); - var id = new ToscaConceptIdentifier("id", "1.2.3"); - acElement.setDefinition(id); - acElement.setDescription("Description"); - acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE); - acElement.setState(AutomationCompositionState.PASSIVE); - - var participantId = CommonTestData.getParticipantId(); - acElement.setParticipantId(participantId); - - var property = new ToscaProperty(); - property.setName("test"); - property.setType("testType"); - var standardCoder = new StandardCoder(); - var json = standardCoder.encode(property); - var propertiesMap = Map.of("Prop1", (Object) json); - acElement.setProperties(propertiesMap); - - var participantUpdates = new ParticipantUpdates(); - participantUpdates.setParticipantId(participantId); - participantUpdates.setAutomationCompositionElementList(List.of(acElement)); - orig.setParticipantUpdatesList(List.of(participantUpdates)); - - var other = new AutomationCompositionUpdate(orig); - - assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - assertSerializable(orig, AutomationCompositionUpdate.class); - } -} diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java index ce23a821f..4a1a2d9de 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPojosTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,12 @@ package org.onap.policy.clamp.models.acm.messages.dmaap.participant; -import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.rule.impl.GetterMustExistRule; import com.openpojo.validation.rule.impl.SetterMustExistRule; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; -import java.util.List; import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.test.ToStringTester; @@ -39,18 +36,18 @@ class ParticipantPojosTest { @Test void testPojos() { - List pojoClasses = + var pojoClasses = PojoClassFactory.getPojoClasses(ParticipantPojosTest.class.getPackageName()); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAck.class)); - pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionAckTest.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionDeployAck.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(AutomationCompositionDeployAckTest.class)); // @formatter:off - final Validator validator = ValidatorBuilder + final var validator = ValidatorBuilder .create() .with(new ToStringTester()) .with(new SetterMustExistRule()) diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java index c23c38c5b..413139999 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java @@ -39,7 +39,7 @@ import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; -import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates; +import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -60,7 +60,7 @@ class AcmUtilsTest { @Test void testCommonUtilsParticipantUpdate() { var acElement = new AutomationCompositionElement(); - List participantUpdates = new ArrayList<>(); + List participantUpdates = new ArrayList<>(); assertThat(participantUpdates).isEmpty(); AcmUtils.prepareParticipantUpdate(acElement, participantUpdates); -- cgit 1.2.3-korg