aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java')
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java101
1 files changed, 101 insertions, 0 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
new file mode 100644
index 000000000..f8aaffe11
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+/**
+ * Test the copy constructor.
+ */
+class ParticipantUpdateTest {
+ @Test
+ void testCopyConstructor() throws CoderException {
+ assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class);
+
+ ParticipantUpdate orig = new ParticipantUpdate();
+ // verify with all values
+ ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
+ orig.setAutomationCompositionId(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");
+
+ ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
+ toscaNodeTemplate.setName("nodeTemplate");
+ toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
+ toscaNodeTemplate.setDescription("Description of nodeTemplate");
+ toscaNodeTemplate.setVersion("1.2.3");
+
+ ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition();
+ participantDefinitionUpdate.setParticipantType(id);
+ AutomationCompositionElementDefinition acDefinition = getAcElementDefinition(id);
+ participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
+ orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
+
+ ParticipantUpdate other = new ParticipantUpdate(orig);
+
+ assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
+
+ assertSerializable(orig, ParticipantUpdate.class);
+ }
+
+ private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
+ ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
+ toscaNodeTemplate.setName("nodeTemplate");
+ toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
+ toscaNodeTemplate.setDescription("Description of nodeTemplate");
+ toscaNodeTemplate.setVersion("1.2.3");
+
+ AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition();
+ acDefinition.setAcElementDefinitionId(id);
+ acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
+
+ ToscaProperty property = new ToscaProperty();
+ property.setName("test");
+ property.setType("testType");
+ Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
+ acDefinition.setCommonPropertiesMap(commonPropertiesMap);
+ return acDefinition;
+ }
+}