summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java45
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java60
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java5
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java66
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java64
-rw-r--r--models/src/test/resources/providers/TestAutomationCompositions.json2
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java18
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java2
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java2
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java50
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java4
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java6
15 files changed, 202 insertions, 132 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
index c3245d27c..b19f54c3b 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
@@ -38,6 +38,9 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
@EqualsAndHashCode(callSuper = true)
public class AutomationComposition extends ToscaEntity implements Comparable<AutomationComposition> {
@NonNull
+ private UUID instanceId;
+
+ @NonNull
private UUID compositionId;
@NonNull
@@ -58,6 +61,7 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
*/
public AutomationComposition(final AutomationComposition otherAutomationComposition) {
super(otherAutomationComposition);
+ this.instanceId = otherAutomationComposition.instanceId;
this.compositionId = otherAutomationComposition.compositionId;
this.state = otherAutomationComposition.state;
this.orderedState = otherAutomationComposition.orderedState;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java
index 4ecb8ce32..534c909aa 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/InstantiationResponse.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.models.acm.messages.rest.instantiation;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -33,5 +34,6 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@Setter
@ToString(callSuper = true)
public class InstantiationResponse extends SimpleResponse {
+ private UUID instanceId;
ToscaConceptIdentifier affectedAutomationComposition;
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
index 8268e9066..b87bad4e0 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.models.acm.persistence.concepts;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.UUID;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -40,7 +39,6 @@ import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
-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.common.parameters.annotations.NotNull;
@@ -66,11 +64,16 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey;
public class JpaAutomationComposition extends PfConcept implements PfAuthorative<AutomationComposition> {
private static final long serialVersionUID = -4725410933242154805L;
+ @Column
+ @NotNull
+ private String instanceId;
+
@EmbeddedId
@VerifyKey
@NotNull
private PfConceptKey key;
+ @Column
@NotNull
private String compositionId;
@@ -97,29 +100,23 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
* The Default Constructor creates a {@link JpaAutomationComposition} object with a null key.
*/
public JpaAutomationComposition() {
- this(new PfConceptKey());
- }
-
- /**
- * The Key Constructor creates a {@link JpaAutomationComposition} object with the given concept key.
- *
- * @param key the key
- */
- public JpaAutomationComposition(@NonNull final PfConceptKey key) {
- this(key, UUID.randomUUID().toString(), AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>());
+ this(UUID.randomUUID().toString(), new PfConceptKey(), UUID.randomUUID().toString(),
+ AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>());
}
/**
* The Key Constructor creates a {@link JpaAutomationComposition} object with all mandatory fields.
*
+ * @param instanceId The UUID of the automation composition instance
* @param key the key
* @param compositionId the TOSCA compositionId of the automation composition definition
* @param state the state of the automation composition
* @param elements the elements of the automation composition in participants
*/
- public JpaAutomationComposition(@NonNull final PfConceptKey key, @NonNull final String compositionId,
- @NonNull final AutomationCompositionState state,
+ public JpaAutomationComposition(@NonNull final String instanceId, @NonNull final PfConceptKey key,
+ @NonNull final String compositionId, @NonNull final AutomationCompositionState state,
@NonNull final Map<UUID, JpaAutomationCompositionElement> elements) {
+ this.instanceId = instanceId;
this.key = key;
this.compositionId = compositionId;
this.state = state;
@@ -133,6 +130,7 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
*/
public JpaAutomationComposition(@NonNull final JpaAutomationComposition copyConcept) {
super(copyConcept);
+ this.instanceId = copyConcept.instanceId;
this.key = new PfConceptKey(copyConcept.key);
this.compositionId = copyConcept.compositionId;
this.state = copyConcept.state;
@@ -156,6 +154,7 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
public AutomationComposition toAuthorative() {
var automationComposition = new AutomationComposition();
+ automationComposition.setInstanceId(UUID.fromString(instanceId));
automationComposition.setName(getKey().getName());
automationComposition.setVersion(getKey().getVersion());
automationComposition.setCompositionId(UUID.fromString(compositionId));
@@ -171,6 +170,7 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
@Override
public void fromAuthorative(@NonNull final AutomationComposition automationComposition) {
+ this.instanceId = automationComposition.getInstanceId().toString();
if (this.key == null || this.getKey().isNullKey()) {
this.setKey(new PfConceptKey(automationComposition.getName(), automationComposition.getVersion()));
}
@@ -182,7 +182,7 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
this.primed = automationComposition.getPrimed();
this.elements = new LinkedHashMap<>(automationComposition.getElements().size());
- for (Entry<UUID, AutomationCompositionElement> elementEntry : automationComposition.getElements().entrySet()) {
+ for (var elementEntry : automationComposition.getElements().entrySet()) {
var jpaAutomationCompositionElement = new JpaAutomationCompositionElement();
jpaAutomationCompositionElement
.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString()));
@@ -193,9 +193,9 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
@Override
public List<PfKey> getKeys() {
- List<PfKey> keyList = getKey().getKeys();
+ var keyList = getKey().getKeys();
- for (JpaAutomationCompositionElement element : elements.values()) {
+ for (var element : elements.values()) {
keyList.addAll(element.getKeys());
}
@@ -207,7 +207,7 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
key.clean();
description = (description == null ? null : description.trim());
- for (JpaAutomationCompositionElement element : elements.values()) {
+ for (var element : elements.values()) {
element.clean();
}
}
@@ -224,8 +224,13 @@ public class JpaAutomationComposition extends PfConcept implements PfAuthorative
return this.getClass().getName().compareTo(otherConcept.getClass().getName());
}
- final JpaAutomationComposition other = (JpaAutomationComposition) otherConcept;
- int result = key.compareTo(other.key);
+ final var other = (JpaAutomationComposition) otherConcept;
+ var result = ObjectUtils.compare(instanceId, other.instanceId);
+ if (result != 0) {
+ return result;
+ }
+
+ result = key.compareTo(other.key);
if (result != 0) {
return result;
}
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 5024785f8..3d2813eb2 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
@@ -52,29 +52,31 @@ public class AutomationCompositionProvider {
/**
* Get automation composition.
*
- * @param automationCompositionId the ID of the automation composition to get
+ * @param instanceId the ID of the automation composition to get
* @return the automation composition found
*/
@Transactional(readOnly = true)
- public AutomationComposition getAutomationComposition(final ToscaConceptIdentifier automationCompositionId) {
- try {
- return automationCompositionRepository.getById(automationCompositionId.asConceptKey()).toAuthorative();
- } catch (EntityNotFoundException e) {
- throw new PfModelRuntimeException(Status.NOT_FOUND, "AutomationComposition not found", e);
+ public AutomationComposition getAutomationComposition(final UUID instanceId) {
+ var result = automationCompositionRepository.findByInstanceId(instanceId.toString());
+ if (result.isEmpty()) {
+ throw new PfModelRuntimeException(Status.NOT_FOUND, "AutomationComposition not found");
}
+ return result.get().toAuthorative();
}
/**
- * Find automation composition by automationCompositionId.
+ * Get automation composition.
*
- * @param name the name of the automation composition to get, null to get all automation compositions
- * @param version the version of the automation composition to get, null to get all automation compositions
+ * @param automationCompositionId the ID of the automation composition to get
* @return the automation composition found
*/
@Transactional(readOnly = true)
- public Optional<AutomationComposition> findAutomationComposition(@NonNull final String name,
- @NonNull final String version) {
- return findAutomationComposition(new PfConceptKey(name, version));
+ public AutomationComposition getAutomationComposition(final ToscaConceptIdentifier automationCompositionId) {
+ try {
+ return automationCompositionRepository.getById(automationCompositionId.asConceptKey()).toAuthorative();
+ } catch (EntityNotFoundException e) {
+ throw new PfModelRuntimeException(Status.NOT_FOUND, "AutomationComposition not found", e);
+ }
}
/**
@@ -94,12 +96,27 @@ public class AutomationCompositionProvider {
}
/**
- * Save automation composition.
+ * Create automation composition.
+ *
+ * @param automationComposition the automation composition to create
+ * @return the create automation composition
+ */
+ public AutomationComposition createAutomationComposition(final AutomationComposition automationComposition) {
+ automationComposition.setInstanceId(UUID.randomUUID());
+ var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition,
+ JpaAutomationComposition::new, "automation composition"));
+
+ // Return the saved automation composition
+ return result.toAuthorative();
+ }
+
+ /**
+ * Update automation composition.
*
* @param automationComposition the automation composition to update
* @return the updated automation composition
*/
- public AutomationComposition saveAutomationComposition(final AutomationComposition automationComposition) {
+ public AutomationComposition updateAutomationComposition(final AutomationComposition automationComposition) {
var result = automationCompositionRepository.save(ProviderUtils.getJpaAndValidate(automationComposition,
JpaAutomationComposition::new, "automation composition"));
@@ -136,23 +153,18 @@ public class AutomationCompositionProvider {
/**
* Delete a automation composition.
*
- * @param name the name of the automation composition to delete
- * @param version the version of the automation composition to delete
+ * @param instanceId the ID of the automation composition to get
* @return the automation composition deleted
*/
- public AutomationComposition deleteAutomationComposition(@NonNull final String name,
- @NonNull final String version) {
-
- var automationCompositionKey = new PfConceptKey(name, version);
- var jpaDeleteAutomationComposition = automationCompositionRepository.findById(automationCompositionKey);
-
+ public AutomationComposition deleteAutomationComposition(@NonNull final UUID instanceId) {
+ var jpaDeleteAutomationComposition = automationCompositionRepository.findByInstanceId(instanceId.toString());
if (jpaDeleteAutomationComposition.isEmpty()) {
- String errorMessage = "delete of automation composition \"" + automationCompositionKey.getId()
+ var errorMessage = "delete of automation composition \"" + instanceId
+ "\" failed, automation composition does not exist";
throw new PfModelRuntimeException(Response.Status.NOT_FOUND, errorMessage);
}
- automationCompositionRepository.deleteById(automationCompositionKey);
+ automationCompositionRepository.deleteById(jpaDeleteAutomationComposition.get().getKey());
return jpaDeleteAutomationComposition.get().toAuthorative();
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java
index 273b99a63..aba752667 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionRepository.java
@@ -21,6 +21,7 @@
package org.onap.policy.clamp.models.acm.persistence.repository;
import java.util.List;
+import java.util.Optional;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationComposition;
import org.onap.policy.models.base.PfConceptKey;
import org.springframework.data.jpa.repository.JpaRepository;
@@ -28,7 +29,9 @@ import org.springframework.stereotype.Repository;
@Repository
public interface AutomationCompositionRepository
- extends JpaRepository<JpaAutomationComposition, PfConceptKey>, FilterRepository {
+ extends JpaRepository<JpaAutomationComposition, PfConceptKey>, FilterRepository {
+
+ Optional<JpaAutomationComposition> findByInstanceId(String instanceId);
List<JpaAutomationComposition> findByCompositionId(String compositionId);
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
index 733ba3807..f5a2149b4 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
@@ -46,7 +46,8 @@ import org.onap.policy.models.base.PfConceptKey;
*/
class JpaAutomationCompositionTest {
- private static final String NULL_KEY_ERROR = "key is marked .*ull but is null";
+ private static final String NULL_KEY_ERROR = "instanceId is marked .*ull but is null";
+ private static final UUID INSTANCE_ID = UUID.fromString("709c62b3-8918-41b9-a747-d21eb79c6c20");
private static final String COMPOSITION_ID = "709c62b3-8918-41b9-a747-e21eb79c6c41";
@Test
@@ -56,74 +57,70 @@ class JpaAutomationCompositionTest {
}).hasMessageMatching("copyConcept is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition((PfConceptKey) null);
+ new JpaAutomationComposition(null, null, null, null, null);
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, null, null, null);
+ new JpaAutomationComposition(null, null, null, null, new LinkedHashMap<>());
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, null, null, new LinkedHashMap<>());
+ new JpaAutomationComposition(null, null, null, AutomationCompositionState.UNINITIALISED, null);
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, null, AutomationCompositionState.UNINITIALISED, null);
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, null, AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>());
- }).hasMessageMatching(NULL_KEY_ERROR);
-
- assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, "key", null, null);
+ new JpaAutomationComposition(null, null, null, AutomationCompositionState.UNINITIALISED,
+ new LinkedHashMap<>());
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, "key", null, new LinkedHashMap<>());
+ new JpaAutomationComposition(null, null, "key", null, new LinkedHashMap<>());
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, "key", AutomationCompositionState.UNINITIALISED, null);
+ new JpaAutomationComposition(null, null, "key", AutomationCompositionState.UNINITIALISED, null);
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(null, "key", AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>());
+ new JpaAutomationComposition(null, null, "key", AutomationCompositionState.UNINITIALISED,
+ new LinkedHashMap<>());
}).hasMessageMatching(NULL_KEY_ERROR);
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), null, null, null);
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), null, null, null);
}).hasMessageMatching("compositionId is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), null, null, new LinkedHashMap<>());
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), null, null, new LinkedHashMap<>());
}).hasMessageMatching("compositionId is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), null, AutomationCompositionState.UNINITIALISED, null);
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), null,
+ AutomationCompositionState.UNINITIALISED, null);
}).hasMessageMatching("compositionId is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), null, AutomationCompositionState.UNINITIALISED,
- new LinkedHashMap<>());
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), null,
+ AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>());
}).hasMessageMatching("compositionId is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), "key", null, null);
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), "key", null, null);
}).hasMessageMatching("state is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), "key", null, new LinkedHashMap<>());
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), "key", null,
+ new LinkedHashMap<>());
}).hasMessageMatching("state is marked .*ull but is null");
assertThatThrownBy(() -> {
- new JpaAutomationComposition(new PfConceptKey(), "key", AutomationCompositionState.UNINITIALISED, null);
+ new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), "key",
+ AutomationCompositionState.UNINITIALISED, null);
}).hasMessageMatching("elements is marked .*ull but is null");
assertNotNull(new JpaAutomationComposition());
- assertNotNull(new JpaAutomationComposition((new PfConceptKey())));
- assertNotNull(new JpaAutomationComposition(new PfConceptKey(), "key", AutomationCompositionState.UNINITIALISED,
- new LinkedHashMap<>()));
+ assertNotNull(new JpaAutomationComposition(INSTANCE_ID.toString(), new PfConceptKey(), "key",
+ AutomationCompositionState.UNINITIALISED, new LinkedHashMap<>()));
}
@Test
@@ -182,23 +179,24 @@ class JpaAutomationCompositionTest {
new StandardCoder().decode(new File("src/test/resources/json/AutomationCompositionNoOrderedState.json"),
AutomationComposition.class);
+ noOrderedStateAc.setInstanceId(INSTANCE_ID);
var noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc);
assertNull(noOrderedStateJpaAc.getOrderedState());
noOrderedStateAc.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
noOrderedStateJpaAc = new JpaAutomationComposition(noOrderedStateAc);
assertEquals(testJpaAutomationComposition, noOrderedStateJpaAc);
- var automationCompositionsWithElements = new StandardCoder().decode(
- new File("src/test/resources/providers/TestAutomationCompositions.json"), AutomationCompositions.class);
+ var acWithElements =
+ new StandardCoder().decode(new File("src/test/resources/providers/TestAutomationCompositions.json"),
+ AutomationCompositions.class).getAutomationCompositionList().get(0);
- var jpaAutomationCompositionWithElements =
- new JpaAutomationComposition(automationCompositionsWithElements.getAutomationCompositionList().get(0));
+ acWithElements.setInstanceId(INSTANCE_ID);
+ var jpaAutomationCompositionWithElements = new JpaAutomationComposition(acWithElements);
assertEquals(4, jpaAutomationCompositionWithElements.getElements().size());
assertEquals(17, jpaAutomationCompositionWithElements.getKeys().size());
assertThatCode(jpaAutomationCompositionWithElements::clean).doesNotThrowAnyException();
- assertEquals(automationCompositionsWithElements.getAutomationCompositionList().get(0),
- jpaAutomationCompositionWithElements.toAuthorative());
+ assertEquals(acWithElements, jpaAutomationCompositionWithElements.toAuthorative());
}
@Test
@@ -282,6 +280,7 @@ class JpaAutomationCompositionTest {
var ac2 = new JpaAutomationComposition();
ac2.setCompositionId(COMPOSITION_ID);
+ ac2.setInstanceId(ac0.getInstanceId());
assertEquals(ac2, ac0);
}
@@ -299,6 +298,7 @@ class JpaAutomationCompositionTest {
private AutomationComposition createAutomationCompositionInstance() {
var testAutomationComposition = new AutomationComposition();
testAutomationComposition.setName("automation-composition");
+ testAutomationComposition.setInstanceId(INSTANCE_ID);
testAutomationComposition.setVersion("0.0.1");
testAutomationComposition.setCompositionId(UUID.fromString(COMPOSITION_ID));
testAutomationComposition.setElements(new LinkedHashMap<>());
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
index 5b12eee17..d7d96e9bd 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
import java.util.List;
import java.util.Optional;
+import java.util.UUID;
import javax.persistence.EntityNotFoundException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -40,7 +41,6 @@ import org.onap.policy.clamp.models.acm.persistence.repository.AutomationComposi
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
class AutomationCompositionProviderTest {
@@ -68,18 +68,32 @@ class AutomationCompositionProviderTest {
}
@Test
- void testAutomationCompositionSave() {
+ void testAutomationCompositionCreate() {
var automationCompositionRepository = mock(AutomationCompositionRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository);
- assertThatThrownBy(() -> automationCompositionProvider.saveAutomationComposition(null))
+ when(automationCompositionRepository.save(any(JpaAutomationComposition.class)))
+ .thenReturn(inputAutomationCompositionsJpa.get(0));
+ var inputAc = inputAutomationCompositions.getAutomationCompositionList().get(0);
+
+ var createdAutomationComposition = automationCompositionProvider.createAutomationComposition(inputAc);
+ inputAc.setInstanceId(createdAutomationComposition.getInstanceId());
+ assertEquals(inputAc, createdAutomationComposition);
+ }
+
+ @Test
+ void testAutomationCompositionUpdate() {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository);
+
+ assertThatThrownBy(() -> automationCompositionProvider.updateAutomationComposition(null))
.hasMessageMatching(OBJECT_IS_NULL);
when(automationCompositionRepository.save(inputAutomationCompositionsJpa.get(0)))
.thenReturn(inputAutomationCompositionsJpa.get(0));
var createdAutomationComposition = automationCompositionProvider
- .saveAutomationComposition(inputAutomationCompositions.getAutomationCompositionList().get(0));
+ .updateAutomationComposition(inputAutomationCompositions.getAutomationCompositionList().get(0));
assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(0), createdAutomationComposition);
}
@@ -121,31 +135,49 @@ class AutomationCompositionProviderTest {
.getAutomationComposition(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION)))
.hasMessageMatching("AutomationComposition not found");
- ac = automationCompositionProvider.findAutomationComposition(ID_NAME, ID_VERSION)
- .orElse(new AutomationComposition());
- assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(1), ac);
-
assertThat(automationCompositionProvider
.findAutomationComposition(new ToscaConceptIdentifier(ID_NAME_NOT_EXTST, ID_VERSION))).isEmpty();
}
@Test
- void testDeleteAutomationComposition() {
+ void testGetAutomationComposition() {
var automationCompositionRepository = mock(AutomationCompositionRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository);
- assertThatThrownBy(
- () -> automationCompositionProvider.deleteAutomationComposition(ID_NAME_NOT_EXTST, ID_VERSION))
- .hasMessageMatching(".*.failed, automation composition does not exist");
+ var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0);
+ when(automationCompositionRepository.findByInstanceId(automationComposition.getInstanceId().toString()))
+ .thenReturn(Optional.of(inputAutomationCompositionsJpa.get(0)));
+ var ac = automationCompositionProvider.getAutomationComposition(automationComposition.getInstanceId());
+ assertEquals(inputAutomationCompositions.getAutomationCompositionList().get(0), ac);
+ }
+
+ @Test
+ void testGetAcInstancesByCompositionId() {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository);
var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0);
- var name = automationComposition.getName();
- var version = automationComposition.getVersion();
+ when(automationCompositionRepository.findByCompositionId(automationComposition.getCompositionId().toString()))
+ .thenReturn(inputAutomationCompositionsJpa);
+ var acList =
+ automationCompositionProvider.getAcInstancesByCompositionId(automationComposition.getCompositionId());
+ assertEquals(inputAutomationCompositions.getAutomationCompositionList(), acList);
+ }
- when(automationCompositionRepository.findById(new PfConceptKey(name, version)))
+ @Test
+ void testDeleteAutomationComposition() {
+ var automationCompositionRepository = mock(AutomationCompositionRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(automationCompositionRepository);
+
+ assertThatThrownBy(() -> automationCompositionProvider.deleteAutomationComposition(UUID.randomUUID()))
+ .hasMessageMatching(".*.failed, automation composition does not exist");
+
+ var automationComposition = inputAutomationCompositions.getAutomationCompositionList().get(0);
+ when(automationCompositionRepository.findByInstanceId(automationComposition.getInstanceId().toString()))
.thenReturn(Optional.of(inputAutomationCompositionsJpa.get(0)));
- AutomationComposition deletedAc = automationCompositionProvider.deleteAutomationComposition(name, version);
+ var deletedAc =
+ automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId());
assertEquals(automationComposition, deletedAc);
}
}
diff --git a/models/src/test/resources/providers/TestAutomationCompositions.json b/models/src/test/resources/providers/TestAutomationCompositions.json
index 171ce07f6..286759988 100644
--- a/models/src/test/resources/providers/TestAutomationCompositions.json
+++ b/models/src/test/resources/providers/TestAutomationCompositions.json
@@ -2,6 +2,7 @@
"automationCompositionList": [
{
"compositionId": "709c62b3-8918-41b9-a747-e21eb79c6c40",
+ "instanceId": "809c62b3-8918-41b9-a748-e21eb79c6c89",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"elements": {
@@ -68,6 +69,7 @@
},
{
"compositionId": "709c62b3-8918-41b9-a747-e21eb79c6c40",
+ "instanceId": "809c62b3-8918-41b9-a748-e21eb79c6c90",
"state": "UNINITIALISED",
"orderedState": "UNINITIALISED",
"elements": {
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index 29b337edd..03a2f4e25 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -43,6 +43,7 @@ import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -80,9 +81,10 @@ public class AutomationCompositionInstantiationProvider {
if (!validationResult.isValid()) {
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- automationComposition = automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationComposition = automationCompositionProvider.createAutomationComposition(automationComposition);
var response = new InstantiationResponse();
+ response.setInstanceId(automationComposition.getInstanceId());
response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
@@ -99,9 +101,10 @@ public class AutomationCompositionInstantiationProvider {
if (!validationResult.isValid()) {
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, validationResult.getResult());
}
- automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
var response = new InstantiationResponse();
+ response.setInstanceId(automationComposition.getInstanceId());
response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
@@ -134,7 +137,8 @@ public class AutomationCompositionInstantiationProvider {
* @return the result of the deletion
*/
public InstantiationResponse deleteAutomationComposition(String name, String version) {
- var automationCompositionOpt = automationCompositionProvider.findAutomationComposition(name, version);
+ var automationCompositionOpt =
+ automationCompositionProvider.findAutomationComposition(new ToscaConceptIdentifier(name, version));
if (automationCompositionOpt.isEmpty()) {
throw new PfModelRuntimeException(Response.Status.NOT_FOUND, "Automation composition not found");
}
@@ -144,8 +148,10 @@ public class AutomationCompositionInstantiationProvider {
"Automation composition state is still " + automationComposition.getState());
}
var response = new InstantiationResponse();
- response.setAffectedAutomationComposition(
- automationCompositionProvider.deleteAutomationComposition(name, version).getKey().asIdentifier());
+ automationComposition =
+ automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId());
+ response.setInstanceId(automationComposition.getInstanceId());
+ response.setAffectedAutomationComposition(automationComposition.getKey().asIdentifier());
return response;
}
@@ -199,7 +205,7 @@ public class AutomationCompositionInstantiationProvider {
automationComposition.setCascadedOrderedState(command.getOrderedState());
supervisionHandler.triggerAutomationCompositionSupervision(automationComposition);
- automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
var response = new InstantiationResponse();
response.setAffectedAutomationComposition(command.getAutomationCompositionIdentifier());
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index b5d7645da..de67360f8 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -235,7 +235,7 @@ public class SupervisionHandler {
automationCompositionAckMessage.getAutomationCompositionResultMap().entrySet());
updated |= setPrimed(automationComposition.get());
if (updated) {
- automationCompositionProvider.saveAutomationComposition(automationComposition.get());
+ automationCompositionProvider.updateAutomationComposition(automationComposition.get());
}
} else {
LOGGER.warn("AutomationComposition not found in database {}",
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index e2f8b6777..129569b6b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -242,7 +242,7 @@ public class SupervisionScanner {
automationComposition.getState(), automationComposition.getOrderedState());
automationComposition.setState(automationComposition.getOrderedState().asState());
- automationCompositionProvider.saveAutomationComposition(automationComposition);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
// Clear missed report counter on automation composition
clearFaultAndCounter(automationComposition);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
index 864179844..115adcb50 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
@@ -45,6 +45,7 @@ import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvide
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ParticipantProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.ProviderUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
@@ -66,14 +67,13 @@ class AutomationCompositionInstantiationProviderTest {
private static final String ORDERED_STATE_INVALID = "ordered state invalid or not specified on command";
private static final String AC_ELEMENT_NAME_NOT_FOUND =
"\"AutomationComposition\" INVALID, item has status INVALID\n"
- + " \"entry PMSHInstance0AcElementNotFound\" INVALID, item has status INVALID\n"
- + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n"
- + " \"entry org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement\""
- + " INVALID, Not found\n";
- private static final String AC_DEFINITION_NOT_FOUND =
- "\"AutomationComposition\" INVALID, item has status INVALID\n"
- + " item \"ServiceTemplate\" value \"\" INVALID,"
- + " Commissioned automation composition definition not found\n";
+ + " \"entry PMSHInstance0AcElementNotFound\" INVALID, item has status INVALID\n"
+ + " \"entry org.onap.domain.pmsh.DCAEMicroservice\" INVALID, Not found\n"
+ + " \"entry org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement\""
+ + " INVALID, Not found\n";
+ private static final String AC_DEFINITION_NOT_FOUND = "\"AutomationComposition\" INVALID, item has status INVALID\n"
+ + " item \"ServiceTemplate\" value \"\" INVALID,"
+ + " Commissioned automation composition definition not found\n";
private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
@@ -101,12 +101,13 @@ class AutomationCompositionInstantiationProviderTest {
var automationCompositionCreate =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Crud");
automationCompositionCreate.setCompositionId(compositionId);
- when(acProvider.saveAutomationComposition(automationCompositionCreate)).thenReturn(automationCompositionCreate);
+ when(acProvider.createAutomationComposition(automationCompositionCreate))
+ .thenReturn(automationCompositionCreate);
var instantiationResponse = instantiationProvider.createAutomationComposition(automationCompositionCreate);
InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionCreate);
- verify(acProvider).saveAutomationComposition(automationCompositionCreate);
+ verify(acProvider).createAutomationComposition(automationCompositionCreate);
when(acProvider.getAutomationCompositions(automationCompositionCreate.getName(),
automationCompositionCreate.getVersion())).thenReturn(List.of(automationCompositionCreate));
@@ -123,14 +124,12 @@ class AutomationCompositionInstantiationProviderTest {
instantiationResponse = instantiationProvider.updateAutomationComposition(automationCompositionUpdate);
InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionUpdate);
- verify(acProvider).saveAutomationComposition(automationCompositionUpdate);
+ verify(acProvider).updateAutomationComposition(automationCompositionUpdate);
when(acProvider.findAutomationComposition(automationCompositionUpdate.getKey().asIdentifier()))
.thenReturn(Optional.of(automationCompositionUpdate));
- when(acProvider.findAutomationComposition(automationCompositionUpdate.getName(),
- automationCompositionUpdate.getVersion())).thenReturn(Optional.of(automationCompositionUpdate));
- when(acProvider.deleteAutomationComposition(automationCompositionUpdate.getName(),
- automationCompositionUpdate.getVersion())).thenReturn(automationCompositionUpdate);
+ when(acProvider.deleteAutomationComposition(automationCompositionUpdate.getInstanceId()))
+ .thenReturn(automationCompositionUpdate);
var instantiationCommand =
InstantiationUtils.getInstantiationCommandFromResource(AC_INSTANTIATION_CHANGE_STATE_JSON, "Crud");
@@ -146,8 +145,7 @@ class AutomationCompositionInstantiationProviderTest {
instantiationProvider.deleteAutomationComposition(automationCompositionCreate.getName(),
automationCompositionCreate.getVersion());
- verify(acProvider).deleteAutomationComposition(automationCompositionCreate.getName(),
- automationCompositionCreate.getVersion());
+ verify(acProvider).deleteAutomationComposition(automationCompositionCreate.getInstanceId());
}
@Test
@@ -172,11 +170,13 @@ class AutomationCompositionInstantiationProviderTest {
}
}
automationComposition.setState(AutomationCompositionState.UNINITIALISED);
+ automationComposition.setInstanceId(UUID.randomUUID());
- when(acProvider.findAutomationComposition(automationComposition.getName(), automationComposition.getVersion()))
- .thenReturn(Optional.of(automationComposition));
- when(acProvider.deleteAutomationComposition(automationComposition.getName(),
- automationComposition.getVersion())).thenReturn(automationComposition);
+ when(acProvider.findAutomationComposition(
+ new ToscaConceptIdentifier(automationComposition.getName(), automationComposition.getVersion())))
+ .thenReturn(Optional.of(automationComposition));
+ when(acProvider.deleteAutomationComposition(automationComposition.getInstanceId()))
+ .thenReturn(automationComposition);
instantiationProvider.deleteAutomationComposition(automationComposition.getName(),
automationComposition.getVersion());
@@ -193,8 +193,8 @@ class AutomationCompositionInstantiationProviderTest {
var instantiationProvider = new AutomationCompositionInstantiationProvider(acProvider, supervisionHandler,
participantProvider, acDefinitionProvider);
- when(acProvider.findAutomationComposition(automationComposition.getName(), automationComposition.getVersion()))
- .thenReturn(Optional.of(automationComposition));
+ var key = new ToscaConceptIdentifier(automationComposition.getName(), automationComposition.getVersion());
+ when(acProvider.findAutomationComposition(key)).thenReturn(Optional.of(automationComposition));
assertThatThrownBy(() -> instantiationProvider.deleteAutomationComposition(automationComposition.getName(),
automationComposition.getVersion())).hasMessageMatching(String.format(DELETE_BAD_REQUEST, state));
@@ -209,9 +209,11 @@ class AutomationCompositionInstantiationProviderTest {
var automationCompositionCreate =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "NoDuplicates");
automationCompositionCreate.setCompositionId(compositionId);
+ automationCompositionCreate.setInstanceId(UUID.randomUUID());
var acProvider = mock(AutomationCompositionProvider.class);
- when(acProvider.saveAutomationComposition(automationCompositionCreate)).thenReturn(automationCompositionCreate);
+ when(acProvider.createAutomationComposition(automationCompositionCreate))
+ .thenReturn(automationCompositionCreate);
var participantProvider = Mockito.mock(ParticipantProvider.class);
var supervisionHandler = mock(SupervisionHandler.class);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
index dd6e8f3fc..9c364b2db 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -166,6 +166,7 @@ class InstantiationControllerTest extends CommonRestController {
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
var instResponse = resp.readEntity(InstantiationResponse.class);
InstantiationUtils.assertInstantiationResponse(instResponse, automationCompositionFromRsc);
+ automationCompositionFromRsc.setInstanceId(instResponse.getInstanceId());
var automationCompositionsFromDb = instantiationProvider.getAutomationCompositions(
automationCompositionFromRsc.getKey().getName(), automationCompositionFromRsc.getKey().getVersion());
@@ -227,12 +228,13 @@ class InstantiationControllerTest extends CommonRestController {
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Update");
automationCompositionCreate.setCompositionId(compositionId);
- instantiationProvider.createAutomationComposition(automationCompositionCreate);
+ var response = instantiationProvider.createAutomationComposition(automationCompositionCreate);
var invocationBuilder = super.sendRequest(INSTANTIATION_ENDPOINT);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Update");
automationComposition.setCompositionId(compositionId);
+ automationComposition.setInstanceId(response.getInstanceId());
var resp = invocationBuilder.put(Entity.json(automationComposition));
assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
index cc915003d..3a707cd52 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandlerTest.java
@@ -235,7 +235,7 @@ class SupervisionHandlerTest {
handler.handleAutomationCompositionStateChangeAckMessage(automationCompositionAckMessage);
- verify(automationCompositionProvider).saveAutomationComposition(any(AutomationComposition.class));
+ verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class));
}
@Test
@@ -255,7 +255,7 @@ class SupervisionHandlerTest {
handler.handleAutomationCompositionUpdateAckMessage(automationCompositionAckMessage);
- verify(automationCompositionProvider).saveAutomationComposition(any(AutomationComposition.class));
+ verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class));
}
@Test
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index 03a0ec59e..1455e9246 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -96,7 +96,7 @@ class SupervisionScannerTest {
participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
supervisionScanner.run(false);
- verify(automationCompositionProvider, times(0)).saveAutomationComposition(any(AutomationComposition.class));
+ verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
}
@Test
@@ -120,7 +120,7 @@ class SupervisionScannerTest {
participantStatusReqPublisher, participantUpdatePublisher, acRuntimeParameterGroup);
supervisionScanner.run(false);
- verify(automationCompositionProvider, times(1)).saveAutomationComposition(any(AutomationComposition.class));
+ verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class));
}
@Test
@@ -148,7 +148,7 @@ class SupervisionScannerTest {
supervisionScanner.handleParticipantStatus(participant.getKey().asIdentifier());
supervisionScanner.run(true);
- verify(automationCompositionProvider, times(0)).saveAutomationComposition(any(AutomationComposition.class));
+ verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
verify(participantStatusReqPublisher, times(0)).send(any(ToscaConceptIdentifier.class));
}