diff options
author | Jim Hahn <jrh3@att.com> | 2021-07-12 18:34:13 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-07-12 18:34:13 +0000 |
commit | fa8bac11d88cca8bd86f6a5687034449a961e1ec (patch) | |
tree | fa712240cbeb27543304d72ed734f483ce341252 | |
parent | 3699a2d2b3a9869d9dbab2d7c0c49830fc0a7f4d (diff) | |
parent | f76591c7f98e5b96bdfa33533753ed17ea483f2a (diff) |
Merge "Add models for register,deregister and update"
22 files changed, 934 insertions, 13 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java new file mode 100644 index 000000000..7daf8974c --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElementDefinition.java @@ -0,0 +1,63 @@ +/*- + * ============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.controlloop.models.controlloop.concepts; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Class to represent a control loop element definition instance. + */ +@NoArgsConstructor +@Data +@ToString +public class ControlLoopElementDefinition { + + @NonNull + private UUID id = UUID.randomUUID(); + + // The definition of the Control Loop Element in TOSCA + private ToscaServiceTemplate controlLoopElementToscaServiceTemplate; + + // 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<String, String> commonPropertiesMap = new LinkedHashMap<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param clElementDefinition the controlloop element definition to copy from + */ + public ControlLoopElementDefinition(final ControlLoopElementDefinition clElementDefinition) { + this.id = clElementDefinition.id; + this.controlLoopElementToscaServiceTemplate = + new ToscaServiceTemplate(clElementDefinition.controlLoopElementToscaServiceTemplate); + this.commonPropertiesMap = PfUtils.mapMap(clElementDefinition.commonPropertiesMap, UnaryOperator.identity()); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java new file mode 100644 index 000000000..1e53921dd --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessage.java @@ -0,0 +1,67 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import java.util.UUID; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent participant Ack message. + */ +@Getter +@Setter +@ToString +public class ParticipantAckMessage { + + // The responseTo field should match the original request id in the request. + private UUID responseTo; + + // Result: Success/Fail. + private Boolean result; + + // Message indicating reason for failure + private String message; + + private ParticipantMessageType messageType; + + /** + * Constructor for instantiating a participant ack message class. + * + * @param messageType the message type + */ + public ParticipantAckMessage(final ParticipantMessageType messageType) { + this.messageType = messageType; + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantAckMessage(ParticipantAckMessage source) { + this.responseTo = source.responseTo; + this.result = source.result; + this.message = source.message; + this.messageType = source.messageType; + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java new file mode 100644 index 000000000..e8759b302 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregister.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_DEREGISTER message that all the participants send to control loop runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantDeregister extends ParticipantMessage { + + /** + * Constructor for instantiating ParticipantDeregister class with message name. + * + */ + public ParticipantDeregister() { + super(ParticipantMessageType.PARTICIPANT_DEREGISTER); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantDeregister(final ParticipantDeregister source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java new file mode 100644 index 000000000..69406beb7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAck.java @@ -0,0 +1,51 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent the PARTICIPANT_DEREGISTER_ACK message that control loop runtime sends to the participant. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantDeregisterAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantDeregisterAck class with message name. + * + */ + public ParticipantDeregisterAck() { + super(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantDeregisterAck(final ParticipantDeregisterAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java index 77a50bd36..94d484620 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantMessageType.java @@ -31,26 +31,57 @@ public enum ParticipantMessageType { PARTICIPANT_STATUS, /** - * Used by the control loop runtime to change the state of participants, triggers a PARTICIPANT_STATUS message with - * the result of the PARTICIPANT_STATE_CHANGE operation. + * Used by the controlloop runtime to change the state of participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_STATE_CHANGE operation. */ PARTICIPANT_STATE_CHANGE, /** - * Used by the control loop runtime to update the control loops running on participants, triggers a + * Used by controlloop runtime to update the controlloops running on participants, triggers a * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_UPDATE operation. */ PARTICIPANT_CONTROL_LOOP_UPDATE, /** - * Used by the control loop runtime to change the state of control loops in participants, triggers a - * PARTICIPANT_STATUS message with the result of the PARTICIPANT_CONTROL_LOOP_STATE_CHANGE operation. + * Used by controlloop runtime to change the state of controlloops in participants, triggers a + * PARTICIPANT_STATUS message with result of PARTICIPANT_CONTROL_LOOP_STATE_CHANGE operation. */ PARTICIPANT_CONTROL_LOOP_STATE_CHANGE, /** - * Used by the control loop runtime to order a health check on participants, triggers a PARTICIPANT_STATUS message - * with the result of the PARTICIPANT_HEALTH_CHECK operation. + * Used by the control loop runtime to order a health check on participants, triggers a + * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation. */ - PARTICIPANT_HEALTH_CHECK + PARTICIPANT_HEALTH_CHECK, + + /** + * Used by participant to register itself with control loop runtime. + */ + PARTICIPANT_REGISTER, + + /** + * Used by control loop runtime to respond to participant registration. + */ + PARTICIPANT_REGISTER_ACK, + + /** + * Used by participant to deregister itself with control loop runtime. + */ + PARTICIPANT_DEREGISTER, + + /** + * Used by control loop runtime to respond to participant deregistration. + */ + PARTICIPANT_DEREGISTER_ACK, + + /** + * Used by control loop runtime to send ToscaServiceTemplate to participant. + */ + PARTICIPANT_UPDATE, + + /** + * Used by participant to acknowledge the receipt of Participant_Update message + * from control loop runtime. + */ + PARTICIPANT_UPDATE_ACK } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java new file mode 100644 index 000000000..7319d99db --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegister.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_REGISTER message that all the participants send to control loop runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantRegister extends ParticipantMessage { + + /** + * Constructor for instantiating ParticipantRegister class with message name. + * + */ + public ParticipantRegister() { + super(ParticipantMessageType.PARTICIPANT_REGISTER); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantRegister(final ParticipantRegister source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java new file mode 100644 index 000000000..3d55c3690 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAck.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_REGISTER_ACK message that control loop runtime sends to registered participant. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantRegisterAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantRegisterAck class with message name. + * + */ + public ParticipantRegisterAck() { + super(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantRegisterAck(final ParticipantRegisterAck source) { + super(source); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java new file mode 100644 index 000000000..5fd00e278 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdate.java @@ -0,0 +1,68 @@ +/*- + * ============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.controlloop.models.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.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; +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 the PARTICIPANT_UPDATE message that the control loop runtime sends to a participant. + * CLAMP Runtime sends Control Loop Element Definitions and Common Parameter Values to Participants. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantUpdate extends ParticipantMessage { + + // A map with Participant ID as its key, and a map of ControlLoopElements as value. + private Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>> + participantDefinitionUpdateMap = new LinkedHashMap<>(); + + /** + * Constructor for instantiating ParticipantUpdate class with message name. + * + */ + public ParticipantUpdate() { + super(ParticipantMessageType.PARTICIPANT_UPDATE); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantUpdate(ParticipantUpdate source) { + super(source); + + this.participantDefinitionUpdateMap = PfUtils.mapMap(source.participantDefinitionUpdateMap, + clElementDefinitionMap -> PfUtils.mapMap(clElementDefinitionMap, + ControlLoopElementDefinition::new)); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java new file mode 100644 index 000000000..0f065e9e6 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAck.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics; + +/** + * Class to represent the PARTICIPANT_UPDATE_ACK message that registered participant sends to controlloop runtime. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantUpdateAck extends ParticipantAckMessage { + + /** + * Constructor for instantiating ParticipantUpdateAck class with message name. + * + */ + public ParticipantUpdateAck() { + super(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantUpdateAck(final ParticipantUpdateAck source) { + super(source); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java index b90ccba5b..94b0b13c7 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaClElementStatisticsChild.java @@ -23,6 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept /** * Test class for {@link JpaClElementStatistics} comparisons. */ -public class DummyJpaClElementStatisticsChild extends JpaClElementStatistics { +class DummyJpaClElementStatisticsChild extends JpaClElementStatistics { private static final long serialVersionUID = -5101743610779424064L; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java index c4eb364d3..10150cf59 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopChild.java @@ -23,6 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept /** * Test class for {@link JpaControlLoop} comparisons. */ -public class DummyJpaControlLoopChild extends JpaControlLoop { +class DummyJpaControlLoopChild extends JpaControlLoop { private static final long serialVersionUID = -5101743610779424064L; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java index 2082ff41c..4bacb9255 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaControlLoopElementChild.java @@ -23,6 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept /** * Test class for {@link JpaControlLoopElement} comparisons. */ -public class DummyJpaControlLoopElementChild extends JpaControlLoopElement { +class DummyJpaControlLoopElementChild extends JpaControlLoopElement { private static final long serialVersionUID = -5101743610779424064L; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java index e6bc92efb..68dcc319b 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantChild.java @@ -23,6 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept /** * Test class for {@link JpaParticipant} comparisons. */ -public class DummyJpaParticipantChild extends JpaParticipant { +class DummyJpaParticipantChild extends JpaParticipant { private static final long serialVersionUID = -5101743610779424064L; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java index 74dd40034..2c1f04ea1 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/DummyJpaParticipantStatisticsChild.java @@ -23,6 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept /** * Test class for {@link JpaParticipantStatistics} comparisons. */ -public class DummyJpaParticipantStatisticsChild extends JpaParticipantStatistics { +class DummyJpaParticipantStatisticsChild extends JpaParticipantStatistics { private static final long serialVersionUID = -5101743610779424064L; } diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java new file mode 100644 index 000000000..82ba5d186 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantAckMessageTest.java @@ -0,0 +1,59 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; + +import java.util.UUID; +import org.junit.jupiter.api.Test; + +class ParticipantAckMessageTest { + private ParticipantAckMessage message; + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantAckMessage((ParticipantAckMessage) null)) + .isInstanceOf(NullPointerException.class); + + // verify with null values + message = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE); + ParticipantAckMessage newmsg = new ParticipantAckMessage(message); + newmsg.setResponseTo(message.getResponseTo()); + assertEquals(message.toString(), newmsg.toString()); + + // verify with all values + message = makeMessage(); + newmsg = new ParticipantAckMessage(message); + newmsg.setResponseTo(message.getResponseTo()); + assertEquals(message.toString(), newmsg.toString()); + } + + private ParticipantAckMessage makeMessage() { + ParticipantAckMessage msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + + msg.setMessage("Successfull Ack"); + msg.setResult(true); + msg.setResponseTo(UUID.randomUUID()); + + return msg; + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java new file mode 100644 index 000000000..cfb891e2a --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterAckTest.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantDeregisterAckTest { + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantDeregisterAck(null)).isInstanceOf(NullPointerException.class); + + final ParticipantDeregisterAck orig = new ParticipantDeregisterAck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregisterAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setResponseTo(UUID.randomUUID()); + orig.setMessageType(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK); + orig.setResult(true); + orig.setMessage("Successfully processed message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregisterAck(orig).toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java new file mode 100644 index 000000000..2daefb6cc --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantDeregisterTest.java @@ -0,0 +1,57 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantDeregisterTest { + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantDeregister(null)).isInstanceOf(NullPointerException.class); + + final ParticipantDeregister orig = new ParticipantDeregister(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregister(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setControlLoopId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantDeregister(orig).toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java index af8eaa8eb..1a56a3979 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java @@ -44,6 +44,8 @@ class ParticipantPojosTest { pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessage.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class)); // @formatter:off final Validator validator = ValidatorBuilder diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java new file mode 100644 index 000000000..f0c721186 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterAckTest.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantRegisterAckTest { + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantRegisterAck(null)).isInstanceOf(NullPointerException.class); + + final ParticipantRegisterAck orig = new ParticipantRegisterAck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegisterAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setResponseTo(UUID.randomUUID()); + orig.setMessageType(ParticipantMessageType.PARTICIPANT_REGISTER_ACK); + orig.setResult(true); + orig.setMessage("Successfully processed message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegisterAck(orig).toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java new file mode 100644 index 000000000..d7ce5bf38 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantRegisterTest.java @@ -0,0 +1,57 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantRegisterTest { + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantRegister(null)).isInstanceOf(NullPointerException.class); + + final ParticipantRegister orig = new ParticipantRegister(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegister(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setControlLoopId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantRegister(orig).toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java new file mode 100644 index 000000000..868147637 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateAckTest.java @@ -0,0 +1,55 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ParticipantUpdateAckTest { + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantUpdateAck(null)).isInstanceOf(NullPointerException.class); + + final ParticipantUpdateAck orig = new ParticipantUpdateAck(); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantUpdateAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setResponseTo(UUID.randomUUID()); + orig.setMessageType(ParticipantMessageType.PARTICIPANT_UPDATE_ACK); + orig.setResult(true); + orig.setMessage("Successfully processed message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ParticipantUpdateAck(orig).toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java new file mode 100644 index 000000000..4f8b42b3a --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java @@ -0,0 +1,81 @@ +/*- + * ============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.controlloop.models.messages.dmaap.participant; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields; + +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; + +/** + * Test the copy constructor. + */ +class ParticipantUpdateTest { + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class); + + ParticipantUpdate orig = new ParticipantUpdate(); + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier(); + id.setName("id"); + id.setVersion("1.2.3"); + orig.setControlLoopId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate(); + toscaServiceTemplate.setName("serviceTemplate"); + toscaServiceTemplate.setDerivedFrom("parentServiceTemplate"); + toscaServiceTemplate.setDescription("Description of serviceTemplate"); + toscaServiceTemplate.setVersion("1.2.3"); + + ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); + clDefinition.setId(UUID.randomUUID()); + clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate); + Map<String, String> commonPropertiesMap = new LinkedHashMap<>(); + commonPropertiesMap.put("Prop1", "PropValue"); + clDefinition.setCommonPropertiesMap(commonPropertiesMap); + + Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap = new LinkedHashMap<>(); + controlLoopElementDefinitionMap.put(UUID.randomUUID(), clDefinition); + + Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>> + participantDefinitionUpdateMap = new LinkedHashMap<>(); + participantDefinitionUpdateMap.put(id, controlLoopElementDefinitionMap); + orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap); + + ParticipantUpdate other = new ParticipantUpdate(orig); + + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); + } +} |