Remove reference type of participantId in Unit Tests in ACM-models 30/132930/1
authorFrancescoFioraEst <francesco.fiora@est.tech>
Tue, 17 Jan 2023 13:42:36 +0000 (13:42 +0000)
committerFrancesco Fiora <francesco.fiora@est.tech>
Tue, 17 Jan 2023 14:04:29 +0000 (14:04 +0000)
As part of the participantId refactoring, reduce the impact
of the changes by removing the reference type of participantId
in unit tests.

Issue-ID: POLICY-4523
Change-Id: I5d25dd3a02dffc8293bd9a4a2ce5dbcdbbf0bcb5
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
14 files changed:
models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java [new file with mode: 0644]

index 3fd102b..9f235d6 100644 (file)
@@ -29,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
 class AutomationCompositionElementTest {
@@ -43,7 +44,7 @@ class AutomationCompositionElementTest {
         ace1.setDescription("Description");
         ace1.setId(UUID.randomUUID());
         ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
-        ace1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
+        ace1.setParticipantId(CommonTestData.getParticipantId());
         ace1.setState(AutomationCompositionState.UNINITIALISED);
 
         var ace2 = new AutomationCompositionElement(ace1);
@@ -78,7 +79,7 @@ class AutomationCompositionElementTest {
         ace1.setDescription("Description");
         ace1.setId(UUID.randomUUID());
         ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
-        ace1.setParticipantId(new ToscaConceptIdentifier("id", "1.2.3"));
+        ace1.setParticipantId(CommonTestData.getParticipantId());
         ace1.setState(AutomationCompositionState.UNINITIALISED);
 
         assertThat(ace1.toString()).contains("AutomationCompositionElement(");
index 8702808..cfae1b1 100644 (file)
@@ -30,6 +30,7 @@ import java.util.UUID;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -47,9 +48,9 @@ class AutomationCompositionAckTest {
                 removeVariableFields(new AutomationCompositionAck(orig).toString()));
 
         // verify with all values
-        var id = new ToscaConceptIdentifier("id", "1.2.3");
         orig.setAutomationCompositionId(UUID.randomUUID());
-        orig.setParticipantId(id);
+        orig.setParticipantId(CommonTestData.getParticipantId());
+        var id = new ToscaConceptIdentifier("id", "1.2.3");
         orig.setParticipantType(id);
         var acElementResult = new AutomationCompositionElementAck(AutomationCompositionState.UNINITIALISED,
             true, "AutomationCompositionElement result");
index ff738a0..76dcabf 100644 (file)
@@ -30,8 +30,8 @@ import java.util.UUID;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
 /**
  * Test the copy constructor and other methods.
@@ -49,9 +49,8 @@ class AutomationCompositionStateChangeTest {
                 removeVariableFields(new AutomationCompositionStateChange(orig).toString()));
 
         // verify with all values
-        ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
         orig.setAutomationCompositionId(UUID.randomUUID());
-        orig.setParticipantId(id);
+        orig.setParticipantId(CommonTestData.getParticipantId());
         orig.setMessageId(UUID.randomUUID());
         orig.setOrderedState(AutomationCompositionOrderedState.RUNNING);
         orig.setCurrentState(AutomationCompositionState.PASSIVE);
index 9f7417a..8125c37 100644 (file)
@@ -34,6 +34,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantUpdates;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -61,7 +62,9 @@ class AutomationCompositionUpdateTest {
         acElement.setDescription("Description");
         acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
         acElement.setState(AutomationCompositionState.PASSIVE);
-        acElement.setParticipantId(id);
+
+        var participantId = CommonTestData.getParticipantId();
+        acElement.setParticipantId(participantId);
         acElement.setParticipantType(id);
 
         var property = new ToscaProperty();
@@ -73,7 +76,7 @@ class AutomationCompositionUpdateTest {
         acElement.setProperties(propertiesMap);
 
         var participantUpdates = new ParticipantUpdates();
-        participantUpdates.setParticipantId(id);
+        participantUpdates.setParticipantId(participantId);
         participantUpdates.setAutomationCompositionElementList(List.of(acElement));
         orig.setParticipantUpdatesList(List.of(participantUpdates));
 
index 276d368..3594755 100644 (file)
@@ -28,6 +28,7 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
 
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -36,8 +37,6 @@ class ParticipantAckMessageTest {
 
     private static final ToscaConceptIdentifier PTYPE_456 = new ToscaConceptIdentifier("PType", "4.5.6");
     private static final ToscaConceptIdentifier PTYPE_457 = new ToscaConceptIdentifier("PType", "4.5.7");
-    private static final ToscaConceptIdentifier ID_123 = new ToscaConceptIdentifier("id", "1.2.3");
-    private static final ToscaConceptIdentifier ID_124 = new ToscaConceptIdentifier("id", "1.2.4");
 
     @Test
     void testCopyConstructor() throws CoderException {
@@ -65,7 +64,8 @@ class ParticipantAckMessageTest {
 
         assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class);
         assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class);
-        assertThatThrownBy(() -> message.appliesTo(null, ID_123)).isInstanceOf(NullPointerException.class);
+        var participantId = CommonTestData.getParticipantId();
+        assertThatThrownBy(() -> message.appliesTo(null, participantId)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
@@ -73,9 +73,9 @@ class ParticipantAckMessageTest {
         message = makeMessage();
 
         // ParticipantId matches
-        assertTrue(message.appliesTo(PTYPE_456, ID_123));
-        assertFalse(message.appliesTo(PTYPE_456, ID_124));
-        assertFalse(message.appliesTo(PTYPE_457, ID_123));
+        assertTrue(message.appliesTo(PTYPE_456, CommonTestData.getParticipantId()));
+        assertFalse(message.appliesTo(PTYPE_456, CommonTestData.getRndParticipantId()));
+        assertFalse(message.appliesTo(PTYPE_457, CommonTestData.getParticipantId()));
     }
 
     @Test
@@ -86,16 +86,16 @@ class ParticipantAckMessageTest {
         ToscaConceptIdentifier id = new ToscaConceptIdentifier();
         id.setName("id1111");
         id.setVersion("3.2.1");
-        assertFalse(message.appliesTo(id, id));
+        assertFalse(message.appliesTo(id, CommonTestData.getRndParticipantId()));
         message.setParticipantType(null);
-        assertTrue(message.appliesTo(id, id));
+        assertTrue(message.appliesTo(id, CommonTestData.getRndParticipantId()));
     }
 
     private ParticipantAckMessage makeMessage() {
         ParticipantAckMessage msg = new ParticipantAckMessage(ParticipantMessageType.PARTICIPANT_DEREGISTER_ACK);
 
         msg.setParticipantType(PTYPE_456);
-        msg.setParticipantId(ID_123);
+        msg.setParticipantId(CommonTestData.getParticipantId());
         msg.setMessage("Successfull Ack");
         msg.setResult(true);
         msg.setResponseTo(UUID.randomUUID());
index 02b7987..dec1682 100644 (file)
@@ -28,6 +28,7 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
 import java.time.Instant;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -48,7 +49,7 @@ class ParticipantDeregisterTest {
         id.setName("id");
         id.setVersion("1.2.3");
         orig.setAutomationCompositionId(UUID.randomUUID());
-        orig.setParticipantId(id);
+        orig.setParticipantId(CommonTestData.getParticipantId());
         orig.setParticipantType(id);
         orig.setMessageId(UUID.randomUUID());
         orig.setTimestamp(Instant.ofEpochMilli(3000));
index 1d7e7b0..42c3152 100644 (file)
@@ -29,6 +29,7 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
 import java.time.Instant;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -37,8 +38,6 @@ class ParticipantMessageTest {
 
     private static final ToscaConceptIdentifier PTYPE_456 = new ToscaConceptIdentifier("PType", "4.5.6");
     private static final ToscaConceptIdentifier PTYPE_457 = new ToscaConceptIdentifier("PType", "4.5.7");
-    private static final ToscaConceptIdentifier ID_123 = new ToscaConceptIdentifier("id", "1.2.3");
-    private static final ToscaConceptIdentifier ID_124 = new ToscaConceptIdentifier("id", "1.2.4");
 
     @Test
     void testCopyConstructor() throws CoderException {
@@ -47,7 +46,7 @@ class ParticipantMessageTest {
 
         // verify with null values
         message = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
-        ParticipantMessage newmsg = new ParticipantMessage(message);
+        var newmsg = new ParticipantMessage(message);
         newmsg.setMessageId(message.getMessageId());
         newmsg.setTimestamp(message.getTimestamp());
         assertEquals(message.toString(), newmsg.toString());
@@ -68,7 +67,8 @@ class ParticipantMessageTest {
 
         assertThatThrownBy(() -> message.appliesTo(null, null)).isInstanceOf(NullPointerException.class);
         assertThatThrownBy(() -> message.appliesTo(PTYPE_456, null)).isInstanceOf(NullPointerException.class);
-        assertThatThrownBy(() -> message.appliesTo(null, ID_123)).isInstanceOf(NullPointerException.class);
+        var participantId = CommonTestData.getParticipantId();
+        assertThatThrownBy(() -> message.appliesTo(null, participantId)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
@@ -76,9 +76,9 @@ class ParticipantMessageTest {
         message = makeMessage();
 
         // ParticipantId matches
-        assertTrue(message.appliesTo(PTYPE_456, ID_123));
-        assertFalse(message.appliesTo(PTYPE_456, ID_124));
-        assertFalse(message.appliesTo(PTYPE_457, ID_123));
+        assertTrue(message.appliesTo(PTYPE_456, CommonTestData.getParticipantId()));
+        assertFalse(message.appliesTo(PTYPE_456, CommonTestData.getRndParticipantId()));
+        assertFalse(message.appliesTo(PTYPE_457, CommonTestData.getParticipantId()));
     }
 
     @Test
@@ -86,19 +86,19 @@ class ParticipantMessageTest {
         message = makeMessage();
 
         // ParticipantId does not match
-        ToscaConceptIdentifier id = new ToscaConceptIdentifier();
+        var id = new ToscaConceptIdentifier();
         id.setName("id1111");
         id.setVersion("3.2.1");
-        assertFalse(message.appliesTo(id, id));
+        assertFalse(message.appliesTo(id, CommonTestData.getRndParticipantId()));
         message.setParticipantType(null);
-        assertTrue(message.appliesTo(id, id));
+        assertTrue(message.appliesTo(id, CommonTestData.getRndParticipantId()));
     }
 
     private ParticipantMessage makeMessage() {
-        ParticipantMessage msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
+        var msg = new ParticipantMessage(ParticipantMessageType.PARTICIPANT_STATE_CHANGE);
 
         msg.setParticipantType(PTYPE_456);
-        msg.setParticipantId(ID_123);
+        msg.setParticipantId(CommonTestData.getParticipantId());
         msg.setMessageId(UUID.randomUUID());
         msg.setTimestamp(Instant.ofEpochMilli(3000));
 
index b8be8b0..af1b9e6 100644 (file)
@@ -28,6 +28,7 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
 import java.time.Instant;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
@@ -48,7 +49,7 @@ class ParticipantRegisterTest {
         id.setName("id");
         id.setVersion("1.2.3");
         orig.setAutomationCompositionId(UUID.randomUUID());
-        orig.setParticipantId(id);
+        orig.setParticipantId(CommonTestData.getParticipantId());
         orig.setParticipantType(id);
         orig.setMessageId(UUID.randomUUID());
         orig.setTimestamp(Instant.ofEpochMilli(3000));
index 11a26d0..5cbbc2c 100644 (file)
@@ -28,8 +28,8 @@ import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.Partic
 import java.time.Instant;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 
 /**
  * Test the copy constructor.
@@ -39,10 +39,9 @@ class ParticipantStatusReqTest {
     void testCopyConstructor() throws CoderException {
         assertThatThrownBy(() -> new ParticipantStatusReq(null)).isInstanceOf(NullPointerException.class);
 
-        ParticipantStatusReq orig = new ParticipantStatusReq();
+        var orig = new ParticipantStatusReq();
         // verify with all values
-        ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
-        orig.setParticipantId(id);
+        orig.setParticipantId(CommonTestData.getParticipantId());
         orig.setAutomationCompositionId(null);
         orig.setParticipantType(null);
         orig.setMessageId(UUID.randomUUID());
index 51331b4..8675d24 100644 (file)
@@ -34,6 +34,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
 import org.onap.policy.clamp.models.acm.concepts.ParticipantState;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 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;
@@ -53,9 +54,9 @@ class ParticipantStatusTest {
         // verify with all values
         var automationCompositionId = UUID.randomUUID();
         orig.setAutomationCompositionId(automationCompositionId);
-        var id = new ToscaConceptIdentifier("id", "1.2.3");
-        orig.setParticipantId(id);
-        ToscaConceptIdentifier type = new ToscaConceptIdentifier("type", "2.3.4");
+        var participantId = CommonTestData.getParticipantId();
+        orig.setParticipantId(participantId);
+        var type = new ToscaConceptIdentifier("type", "2.3.4");
         orig.setParticipantType(type);
         orig.setMessageId(UUID.randomUUID());
         orig.setState(ParticipantState.ON_LINE);
@@ -65,9 +66,9 @@ class ParticipantStatusTest {
         orig.setAutomationCompositionInfoList(List.of(acInfo));
 
         var participantDefinitionUpdate = new ParticipantDefinition();
-        participantDefinitionUpdate.setParticipantId(id);
+        participantDefinitionUpdate.setParticipantId(participantId);
         participantDefinitionUpdate.setParticipantType(type);
-        var acDefinition = getAcElementDefinition(id);
+        var acDefinition = getAcElementDefinition(new ToscaConceptIdentifier("id", "1.2.3"));
         participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
         orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
 
index 177e223..7d57afc 100644 (file)
@@ -31,6 +31,7 @@ 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.clamp.models.acm.utils.CommonTestData;
 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;
@@ -44,34 +45,34 @@ class ParticipantUpdateTest {
     void testCopyConstructor() throws CoderException {
         assertThatThrownBy(() -> new ParticipantUpdate(null)).isInstanceOf(NullPointerException.class);
 
-        ParticipantUpdate orig = new ParticipantUpdate();
+        var orig = new ParticipantUpdate();
         // verify with all values
-        ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
         orig.setAutomationCompositionId(UUID.randomUUID());
-        orig.setParticipantId(id);
-        orig.setParticipantType(id);
+        orig.setParticipantId(CommonTestData.getParticipantId());
+        var type = new ToscaConceptIdentifier("id", "1.2.3");
+        orig.setParticipantType(type);
         orig.setMessageId(UUID.randomUUID());
         orig.setTimestamp(Instant.ofEpochMilli(3000));
 
-        ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
+        var toscaServiceTemplate = new ToscaServiceTemplate();
         toscaServiceTemplate.setName("serviceTemplate");
         toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
         toscaServiceTemplate.setDescription("Description of serviceTemplate");
         toscaServiceTemplate.setVersion("1.2.3");
 
-        ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
+        var 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);
+        var participantDefinitionUpdate = new ParticipantDefinition();
+        participantDefinitionUpdate.setParticipantType(type);
+        var acDefinition = getAcElementDefinition(type);
         participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
         orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
 
-        ParticipantUpdate other = new ParticipantUpdate(orig);
+        var other = new ParticipantUpdate(orig);
 
         assertEquals(removeVariableFields(orig.toString()), removeVariableFields(other.toString()));
 
@@ -79,13 +80,13 @@ class ParticipantUpdateTest {
     }
 
     private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
-        ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
+        var toscaNodeTemplate = new ToscaNodeTemplate();
         toscaNodeTemplate.setName("nodeTemplate");
         toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
         toscaNodeTemplate.setDescription("Description of nodeTemplate");
         toscaNodeTemplate.setVersion("1.2.3");
 
-        AutomationCompositionElementDefinition acDefinition = new AutomationCompositionElementDefinition();
+        var acDefinition = new AutomationCompositionElementDefinition();
         acDefinition.setAcElementDefinitionId(id);
         acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
         return acDefinition;
index 3781c3a..460f3ab 100644 (file)
@@ -36,6 +36,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
 import org.onap.policy.clamp.models.acm.concepts.Participant;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.models.base.PfConceptKey;
@@ -141,6 +142,7 @@ class JpaAutomationCompositionElementTest {
         noOrderedStateJpaAce = new JpaAutomationCompositionElement(noOrderedStateAce);
         noOrderedStateJpaAce.setInstanceId(testJpaAutomationCompositionElement.getInstanceId());
         noOrderedStateJpaAce.setElementId(testJpaAutomationCompositionElement.getElementId());
+        noOrderedStateJpaAce.setParticipantId(testJpaAutomationCompositionElement.getParticipantId());
         assertEquals(testJpaAutomationCompositionElement, noOrderedStateJpaAce);
     }
 
@@ -221,7 +223,7 @@ class JpaAutomationCompositionElementTest {
         ace1.setDescription("Description");
         ace1.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
         ace1.setState(AutomationCompositionState.UNINITIALISED);
-        ace1.setParticipantId(new PfConceptKey("participant", "0.0.1"));
+        ace1.setParticipantId(CommonTestData.getJpaParticipantId());
 
         assertThat(ace1.toString()).contains("AutomationCompositionElement(");
         assertNotEquals(0, ace1.hashCode());
@@ -249,6 +251,7 @@ class JpaAutomationCompositionElementTest {
         automationCompositionElement.setId(UUID.fromString(ELEMENT_ID));
         automationCompositionElement.setDefinition(new ToscaConceptIdentifier("aceDef", "0.0.1"));
         automationCompositionElement.setParticipantType(new ToscaConceptIdentifier("participantType", "0.0.1"));
+        automationCompositionElement.setParticipantId(CommonTestData.getParticipantId());
         automationCompositionElement.setProperties(Map.of("key", "{}"));
 
         return automationCompositionElement;
index bb33e4d..c659f5a 100644 (file)
@@ -50,7 +50,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
 
 class AcmUtilsTest {
 
-    private final ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.0.0");
+    private static final ToscaConceptIdentifier TYPE = new ToscaConceptIdentifier("id", "1.0.0");
 
     @Test
     void testCommonUtilsParticipantUpdate() {
@@ -63,12 +63,13 @@ class AcmUtilsTest {
         assertEquals(acElement, participantUpdates.get(0).getAutomationCompositionElementList().get(0));
 
         AcmUtils.prepareParticipantUpdate(acElement, participantUpdates);
-        assertNotEquals(id, participantUpdates.get(0).getParticipantId());
+        var participantId = CommonTestData.getParticipantId();
+        assertNotEquals(participantId, participantUpdates.get(0).getParticipantId());
 
-        acElement.setParticipantId(id);
-        acElement.setParticipantType(id);
+        acElement.setParticipantId(participantId);
+        acElement.setParticipantType(TYPE);
         AcmUtils.prepareParticipantUpdate(acElement, participantUpdates);
-        assertEquals(id, participantUpdates.get(1).getParticipantId());
+        assertEquals(participantId, participantUpdates.get(1).getParticipantId());
     }
 
     @Test
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java
new file mode 100644 (file)
index 0000000..0d47fa6
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.utils;
+
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Class to hold/create all parameters for test cases.
+ *
+ */
+public class CommonTestData {
+
+    public static final ToscaConceptIdentifier PARTCICIPANT_ID = new ToscaConceptIdentifier("id", "1.2.3");
+
+    /**
+     * Returns participantId for test cases.
+     *
+     * @return participant Id
+     */
+    public static ToscaConceptIdentifier getParticipantId() {
+        return PARTCICIPANT_ID;
+    }
+
+    /**
+     * Returns participantId for test Jpa cases.
+     *
+     * @return participant Id
+     */
+    public static PfConceptKey getJpaParticipantId() {
+        return PARTCICIPANT_ID.asConceptKey();
+    }
+
+    /**
+     * Returns second participantId for test cases.
+     *
+     * @return participant Id
+     */
+    public static ToscaConceptIdentifier getRndParticipantId() {
+        return new ToscaConceptIdentifier("idDiff", "1.2.3");
+    }
+}