diff options
Diffstat (limited to 'models/src/test/java')
14 files changed, 130 insertions, 59 deletions
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java index 3fd102b31..9f235d6ac 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java @@ -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("); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java index 8702808cd..cfae1b1db 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java @@ -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"); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java index ff738a01a..76dcabf0e 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java @@ -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); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java index 9f7417a0b..8125c37d7 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java @@ -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)); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java index 276d36887..3594755b8 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantAckMessageTest.java @@ -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()); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java index 02b79878c..dec168232 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java @@ -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)); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java index 1d7e7b02f..42c3152c3 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageTest.java @@ -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)); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java index b8be8b0d9..af1b9e692 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java @@ -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)); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java index 11a26d007..5cbbc2c5d 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusReqTest.java @@ -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()); diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java index 51331b4bb..8675d24ff 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java @@ -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)); 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 index 177e22356..7d57afc3f 100644 --- 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 @@ -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; diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java index 3781c3a7d..460f3ab4b 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java @@ -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; diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java index bb33e4d5a..c659f5ae2 100644 --- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java @@ -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 index 000000000..0d47fa6e3 --- /dev/null +++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java @@ -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"); + } +} |