diff options
author | Jim Hahn <jrh3@att.com> | 2021-07-30 13:28:11 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-07-30 13:28:11 +0000 |
commit | f14caccfdfccee9d1e28d36293cca8d874a92d6b (patch) | |
tree | 9b97a9a17ae4759072125975e8ca5ae3f4cfb173 /models | |
parent | 4a17f8c489946a8a0b596d66dd968fd576605114 (diff) | |
parent | 2d351b432d28c0d9bda0dbeaac994b030e3b6f82 (diff) |
Merge "Updates to participant messages"
Diffstat (limited to 'models')
12 files changed, 326 insertions, 33 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java index 83f062c74..b99759eb3 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopElement.java @@ -20,12 +20,16 @@ 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.PfConceptKey; +import org.onap.policy.models.base.PfUtils; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** @@ -57,6 +61,10 @@ public class ControlLoopElement { private ClElementStatistics clElementStatistics; + // 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. * @@ -71,5 +79,6 @@ public class ControlLoopElement { this.orderedState = otherElement.orderedState; this.description = otherElement.description; this.clElementStatistics = otherElement.clElementStatistics; + this.commonPropertiesMap = PfUtils.mapMap(otherElement.commonPropertiesMap, UnaryOperator.identity()); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java new file mode 100644 index 000000000..6a72ec1f2 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAck.java @@ -0,0 +1,85 @@ +/*- + * ============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.apache.commons.lang3.tuple.Pair; +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; + +/** + * Class to represent the CONTROLLOOP_ACK message that a participant sends + * to control loop runtime as an acknowledgement to either ControlLoopUpdate + * or ControlLoopStateChange message. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ControlLoopAck extends ParticipantAckMessage { + + /** + * Participant ID, or {@code null} for messages from participants. + */ + private ToscaConceptIdentifier participantId; + + /** + * Participant Type, or {@code null} for messages from participants. + */ + private ToscaConceptIdentifier participantType; + + /** + * Control loop ID, or {@code null} for messages to participants. + */ + private ToscaConceptIdentifier controlLoopId; + + // A map with ControlLoopElementID as its key, and a pair of result and message as value per + // ControlLoopElement. + private Map<UUID, Map<UUID, Boolean>> controlLoopResultMap = new LinkedHashMap<>(); + + /** + * Constructor for instantiating ParticipantRegisterAck class with message name. + * + */ + public ControlLoopAck(final ParticipantMessageType messageType) { + super(messageType); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ControlLoopAck(final ControlLoopAck source) { + super(source); + this.participantId = source.participantId; + this.participantType = source.participantType; + this.controlLoopId = source.controlLoopId; + this.controlLoopResultMap = PfUtils.mapMap(source.controlLoopResultMap, + clElementResultMap -> PfUtils.mapMap(clElementResultMap, UnaryOperator.identity())); + } +} diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java index 180d99439..e6955b90b 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChange.java @@ -24,6 +24,7 @@ import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; /** * Class to represent the CONTROL_LOOP_STATE_CHANGE message that the control loop runtime will send to @@ -34,6 +35,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop @ToString(callSuper = true) public class ControlLoopStateChange extends ParticipantMessage { private ControlLoopOrderedState orderedState; + private ControlLoopState currentState; /** * Constructor for instantiating ControlLoopStateChange class with message name. @@ -52,5 +54,6 @@ public class ControlLoopStateChange extends ParticipantMessage { super(source); this.orderedState = source.orderedState; + this.currentState = source.currentState; } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java index 876c370b4..865264f6d 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdate.java @@ -20,11 +20,16 @@ package org.onap.policy.clamp.controlloop.models.messages.dmaap.participant; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; +import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** * Class to represent the CONTROL_LOOP_UPDATE message that the control loop runtime sends to a participant. @@ -35,11 +40,13 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @Setter @ToString(callSuper = true) public class ControlLoopUpdate extends ParticipantMessage { + // The control loop private ControlLoop controlLoop; - // A service template containing a complete definition of the control loop - private ToscaServiceTemplate controlLoopDefinition; + // A map with Participant ID as its key, and a map of ControlLoopElements as value. + private Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElement>> + participantUpdateMap = new LinkedHashMap<>(); /** * Constructor for instantiating ControlLoopUpdate class with message name. @@ -57,7 +64,8 @@ public class ControlLoopUpdate extends ParticipantMessage { public ControlLoopUpdate(ControlLoopUpdate source) { super(source); - this.controlLoop = new ControlLoop(source.controlLoop); - this.controlLoopDefinition = new ToscaServiceTemplate(source.controlLoopDefinition); + this.controlLoop = source.controlLoop; + this.participantUpdateMap = PfUtils.mapMap(source.participantUpdateMap, + clElementMap -> PfUtils.mapMap(clElementMap, ControlLoopElement::new)); } } 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 0c39392e0..62b8d20b0 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 @@ -83,5 +83,22 @@ public enum ParticipantMessageType { * Used by participant to acknowledge the receipt of Participant_Update message * from control loop runtime. */ - PARTICIPANT_UPDATE_ACK + PARTICIPANT_UPDATE_ACK, + + /** + * Used by participant to acknowledge the receipt of ControlLoop_Update message + * from control loop runtime. + */ + CONTROLLOOP_UPDATE_ACK, + + /** + * Used by participant to acknowledge the receipt of ControlLoop_StateChange message + * from control loop runtime. + */ + CONTROLLOOP_STATECHANGE_ACK, + + /** + * Used by control loop runtime to request for ParticipantStatus message immediately. + */ + PARTICIPANT_STATUS_REQ } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.java new file mode 100644 index 000000000..9242cea02 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReq.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_STATUS_REQ message that controlloop runtime + * sends to participants for an immediate ParticipantStatus from participants. + */ +@Getter +@Setter +@ToString(callSuper = true) +public class ParticipantStatusReq extends ParticipantMessage { + + /** + * Constructor for instantiating a participant status request class. + */ + public ParticipantStatusReq() { + super(ParticipantMessageType.PARTICIPANT_STATUS_REQ); + } + + /** + * Constructs the object, making a deep copy. + * + * @param source source from which to copy + */ + public ParticipantStatusReq(final ParticipantStatusReq source) { + super(source); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java new file mode 100644 index 000000000..8734a435c --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java @@ -0,0 +1,62 @@ +/*- + * ============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.Map; +import java.util.UUID; +import org.junit.jupiter.api.Test; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; + +class ControlLoopAckTest { + + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ControlLoopAck((ControlLoopAck) null)) + .isInstanceOf(NullPointerException.class); + + final ControlLoopAck orig = new ControlLoopAck(ParticipantMessageType.CONTROL_LOOP_UPDATE); + + // verify with null values + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ControlLoopAck(orig).toString())); + + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setControlLoopId(id); + orig.setParticipantId(id); + orig.setParticipantType(id); + + Map<UUID, Boolean> clElementResult = Map.of(UUID.randomUUID(), true); + final Map<UUID, Map<UUID, Boolean>> controlLoopResultMap = Map.of(UUID.randomUUID(), clElementResult); + orig.setControlLoopResultMap(controlLoopResultMap); + + orig.setResponseTo(UUID.randomUUID()); + orig.setResult(true); + orig.setMessage("Successfully processed ControlLoopUpdate message"); + + assertEquals(removeVariableFields(orig.toString()), + removeVariableFields(new ControlLoopAck(orig).toString())); + } +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java index 5b7fda0c4..dd6a814a7 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java @@ -28,6 +28,7 @@ import java.time.Instant; import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; /** @@ -46,13 +47,12 @@ class ControlLoopStateChangeTest { removeVariableFields(new ControlLoopStateChange(orig).toString())); // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); orig.setControlLoopId(id); orig.setParticipantId(id); orig.setMessageId(UUID.randomUUID()); orig.setOrderedState(ControlLoopOrderedState.RUNNING); + orig.setCurrentState(ControlLoopState.PASSIVE); orig.setTimestamp(Instant.ofEpochMilli(3000)); assertEquals(removeVariableFields(orig.toString()), diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java index ac164e32b..0ac4f5331 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java @@ -22,15 +22,17 @@ 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.Map; import java.util.UUID; import org.junit.jupiter.api.Test; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; /** * Test the copy constructor. @@ -42,30 +44,37 @@ class ControlLoopUpdateTest { ControlLoopUpdate orig = new ControlLoopUpdate(); // verify with all values - ToscaConceptIdentifier id = new ToscaConceptIdentifier(); - id.setName("id"); - id.setVersion("1.2.3"); + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); orig.setControlLoopId(id); - orig.setParticipantId(id); + orig.setParticipantId(null); orig.setMessageId(UUID.randomUUID()); orig.setTimestamp(Instant.ofEpochMilli(3000)); + ControlLoopElement clElement = new ControlLoopElement(); + clElement.setId(UUID.randomUUID()); + clElement.setDefinition(id); + clElement.setDescription("Description"); + clElement.setOrderedState(ControlLoopOrderedState.PASSIVE); + clElement.setState(ControlLoopState.PASSIVE); + clElement.setParticipantId(id); + clElement.setParticipantType(id); + ControlLoop controlLoop = new ControlLoop(); controlLoop.setName("controlLoop"); - ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate(); - toscaServiceTemplate.setName("serviceTemplate"); - toscaServiceTemplate.setDerivedFrom("parentServiceTemplate"); - toscaServiceTemplate.setDescription("Description of serviceTemplate"); - toscaServiceTemplate.setVersion("1.2.3"); - orig.setControlLoopDefinition(toscaServiceTemplate); + Map<UUID, ControlLoopElement> elements = Map.of(clElement.getId(), clElement); + controlLoop.setElements(elements); orig.setControlLoop(controlLoop); + Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue"); + clElement.setCommonPropertiesMap(commonPropertiesMap); + + Map<UUID, ControlLoopElement> controlLoopElementMap = Map.of(UUID.randomUUID(), clElement); + Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElement>> + participantUpdateMap = Map.of(id, controlLoopElementMap); + orig.setParticipantUpdateMap(participantUpdateMap); + ControlLoopUpdate other = new ControlLoopUpdate(orig); assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString())); - - // ensure list and items are not the same object - assertNotSame(other.getControlLoop(), controlLoop); - assertNotSame(other.getControlLoopDefinition(), toscaServiceTemplate); } } 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 1a56a3979..e67fbc143 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 @@ -46,6 +46,8 @@ class ParticipantPojosTest { pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantMessageTest.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessage.class)); pojoClasses.remove(PojoClassFactory.getPojoClass(ParticipantAckMessageTest.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAck.class)); + pojoClasses.remove(PojoClassFactory.getPojoClass(ControlLoopAckTest.class)); // @formatter:off final Validator validator = ValidatorBuilder diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java new file mode 100644 index 000000000..b391aa2cf --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java @@ -0,0 +1,52 @@ +/*- + * ============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; + +/** + * Test the copy constructor. + */ +class ParticipantStatusReqTest { + @Test + void testCopyConstructor() { + assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class); + + ParticipantStatusReq orig = new ParticipantStatusReq(); + // verify with all values + ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3"); + orig.setParticipantId(id); + orig.setControlLoopId(null); + orig.setParticipantType(null); + orig.setMessageId(UUID.randomUUID()); + orig.setTimestamp(Instant.ofEpochMilli(3000)); + + ParticipantStatusReq other = new ParticipantStatusReq(orig); + assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.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 index 4f8b42b3a..094431233 100644 --- 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 @@ -22,11 +22,9 @@ 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; @@ -62,16 +60,13 @@ class ParticipantUpdateTest { ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition(); clDefinition.setId(UUID.randomUUID()); clDefinition.setControlLoopElementToscaServiceTemplate(toscaServiceTemplate); - Map<String, String> commonPropertiesMap = new LinkedHashMap<>(); - commonPropertiesMap.put("Prop1", "PropValue"); + Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue"); clDefinition.setCommonPropertiesMap(commonPropertiesMap); - Map<UUID, ControlLoopElementDefinition> controlLoopElementDefinitionMap = new LinkedHashMap<>(); - controlLoopElementDefinitionMap.put(UUID.randomUUID(), clDefinition); + Map<UUID, ControlLoopElementDefinition> clElementDefinitionMap = Map.of(UUID.randomUUID(), clDefinition); Map<ToscaConceptIdentifier, Map<UUID, ControlLoopElementDefinition>> - participantDefinitionUpdateMap = new LinkedHashMap<>(); - participantDefinitionUpdateMap.put(id, controlLoopElementDefinitionMap); + participantDefinitionUpdateMap = Map.of(id, clElementDefinitionMap); orig.setParticipantDefinitionUpdateMap(participantDefinitionUpdateMap); ParticipantUpdate other = new ParticipantUpdate(orig); |