summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java12
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAckTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionStateChangeTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionUpdateTest.java4
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantDeregisterTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRegisterTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantStatusTest.java25
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantUpdateTest.java2
11 files changed, 38 insertions, 26 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java
index 14aee1dd8..c43e4db91 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionInfo.java
@@ -20,10 +20,10 @@
package org.onap.policy.clamp.models.acm.concepts;
+import java.util.UUID;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent a automation composition info instance.
@@ -33,7 +33,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@ToString
public class AutomationCompositionInfo {
- private ToscaConceptIdentifier automationCompositionId;
+ private UUID automationCompositionId;
private AutomationCompositionState state = AutomationCompositionState.UNINITIALISED;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java
index c0a21d61a..c1ec67c83 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/AutomationCompositionAck.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import lombok.Setter;
import lombok.ToString;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementAck;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent the AUTOMATION_COMPOSITION_ACK message that a participant sends
@@ -41,7 +40,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@ToString(callSuper = true)
public class AutomationCompositionAck extends ParticipantAckMessage {
- private ToscaConceptIdentifier automationCompositionId;
+ private UUID automationCompositionId;
private Integer startPhase;
// A map with AutomationCompositionElementID as its key, and a pair of result and message as value per
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java
index c358376b2..ae6dce515 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessage.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ public class ParticipantMessage {
/**
* Automation Composition ID, or {@code null} for messages to participants.
*/
- private ToscaConceptIdentifier automationCompositionId;
+ private UUID automationCompositionId;
/**
* Constructor for instantiating a participant message class.
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
index 3d2813eb2..8c39f6e2b 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java
@@ -80,6 +80,18 @@ public class AutomationCompositionProvider {
}
/**
+ * Find automation composition.
+ *
+ * @param instanceId the ID of the automation composition to get
+ * @return the automation composition found
+ */
+ @Transactional(readOnly = true)
+ public Optional<AutomationComposition> findAutomationComposition(final UUID instanceId) {
+ var result = automationCompositionRepository.findByInstanceId(instanceId.toString());
+ return result.stream().map(JpaAutomationComposition::toAuthorative).findFirst();
+ }
+
+ /**
* Find automation composition by automationCompositionId.
*
* @param automationCompositionId the ID of the automation composition to get
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 c750610d4..8702808cd 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
@@ -48,7 +48,7 @@ class AutomationCompositionAckTest {
// verify with all values
var id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setAutomationCompositionId(id);
+ orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(id);
orig.setParticipantType(id);
var acElementResult = new AutomationCompositionElementAck(AutomationCompositionState.UNINITIALISED,
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 6e8f41a4f..ff738a01a 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
@@ -50,7 +50,7 @@ class AutomationCompositionStateChangeTest {
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setAutomationCompositionId(id);
+ orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(id);
orig.setMessageId(UUID.randomUUID());
orig.setOrderedState(AutomationCompositionOrderedState.RUNNING);
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 a2417df6b..9f7417a0b 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
@@ -49,14 +49,14 @@ class AutomationCompositionUpdateTest {
var orig = new AutomationCompositionUpdate();
// verify with all values
- var id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setAutomationCompositionId(id);
+ orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(null);
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
var acElement = new AutomationCompositionElement();
acElement.setId(UUID.randomUUID());
+ var id = new ToscaConceptIdentifier("id", "1.2.3");
acElement.setDefinition(id);
acElement.setDescription("Description");
acElement.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
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 d8dd15dbd..02b79878c 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
@@ -47,7 +47,7 @@ class ParticipantDeregisterTest {
ToscaConceptIdentifier id = new ToscaConceptIdentifier();
id.setName("id");
id.setVersion("1.2.3");
- orig.setAutomationCompositionId(id);
+ orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(id);
orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());
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 215f4a9ec..b8be8b0d9 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
@@ -47,7 +47,7 @@ class ParticipantRegisterTest {
ToscaConceptIdentifier id = new ToscaConceptIdentifier();
id.setName("id");
id.setVersion("1.2.3");
- orig.setAutomationCompositionId(id);
+ orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(id);
orig.setParticipantType(id);
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 eeb8ba3dd..a8a2267ad 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
@@ -47,15 +47,16 @@ class ParticipantStatusTest {
void testCopyConstructor() throws CoderException {
assertThatThrownBy(() -> new ParticipantStatus(null)).isInstanceOf(NullPointerException.class);
- final ParticipantStatus orig = new ParticipantStatus();
+ final var orig = new ParticipantStatus();
// verify with null values
assertEquals(removeVariableFields(orig.toString()),
removeVariableFields(new ParticipantStatus(orig).toString()));
// verify with all values
- ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setAutomationCompositionId(id);
+ 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");
orig.setParticipantType(type);
@@ -64,13 +65,13 @@ class ParticipantStatusTest {
orig.setHealthStatus(ParticipantHealthStatus.HEALTHY);
orig.setTimestamp(Instant.ofEpochMilli(3000));
- AutomationCompositionInfo acInfo = getAutomationCompositionInfo(id);
+ var acInfo = getAutomationCompositionInfo(automationCompositionId);
orig.setAutomationCompositionInfoList(List.of(acInfo));
- ParticipantDefinition participantDefinitionUpdate = new ParticipantDefinition();
+ var participantDefinitionUpdate = new ParticipantDefinition();
participantDefinitionUpdate.setParticipantId(id);
participantDefinitionUpdate.setParticipantType(type);
- AutomationCompositionElementDefinition acDefinition = getAcElementDefinition(id);
+ var acDefinition = getAcElementDefinition(id);
participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
@@ -80,8 +81,8 @@ class ParticipantStatusTest {
assertSerializable(orig, ParticipantStatus.class);
}
- private AutomationCompositionInfo getAutomationCompositionInfo(ToscaConceptIdentifier id) {
- AutomationCompositionInfo acInfo = new AutomationCompositionInfo();
+ private AutomationCompositionInfo getAutomationCompositionInfo(UUID id) {
+ var acInfo = new AutomationCompositionInfo();
acInfo.setState(AutomationCompositionState.PASSIVE2RUNNING);
acInfo.setAutomationCompositionId(id);
@@ -89,20 +90,20 @@ class ParticipantStatusTest {
}
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);
- ToscaProperty property = new ToscaProperty();
+ var property = new ToscaProperty();
property.setName("test");
property.setType("testType");
- Map<String, ToscaProperty> commonPropertiesMap = Map.of("Prop1", property);
+ var commonPropertiesMap = Map.of("Prop1", property);
acDefinition.setCommonPropertiesMap(commonPropertiesMap);
return acDefinition;
}
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 dd49e1355..074f6f2e2 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
@@ -49,7 +49,7 @@ class ParticipantUpdateTest {
ParticipantUpdate orig = new ParticipantUpdate();
// verify with all values
ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.2.3");
- orig.setAutomationCompositionId(id);
+ orig.setAutomationCompositionId(UUID.randomUUID());
orig.setParticipantId(id);
orig.setParticipantType(id);
orig.setMessageId(UUID.randomUUID());