aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test/java/org
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-07-27 17:24:44 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-07-29 08:59:27 +0100
commit2d351b432d28c0d9bda0dbeaac994b030e3b6f82 (patch)
treeeeb9e82baae554ea395a0e62a19e54da1847fa13 /models/src/test/java/org
parentd5c645873589e0b56a6ad0edd5bd0d480896f765 (diff)
Updates to participant messages
Updated participant messages according to https://wiki.onap.org/display/DW/The+CLAMP+Control+Loop+Participant+Protocol Issue-ID: POLICY-3416 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: Idef19bee05116f11690c7aca0493e731dd128e06
Diffstat (limited to 'models/src/test/java/org')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopAckTest.java62
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopStateChangeTest.java6
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ControlLoopUpdateTest.java41
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantPojosTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantStatusReqTest.java52
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/messages/dmaap/participant/ParticipantUpdateTest.java11
6 files changed, 147 insertions, 27 deletions
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);