aboutsummaryrefslogtreecommitdiffstats
path: root/models/src
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2024-07-23 18:08:35 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2024-07-26 12:43:25 +0100
commitbcc65d6f4268ff437b162324de13ee53bde47ddd (patch)
tree3b4fbbb23639d6a006da828d7d9400b1d75d3e56 /models/src
parent37195c69c99b5987f037a018859b4421cbcbadf2 (diff)
Support add/remove elements in Migration
Issue-ID: POLICY-4917 Change-Id: I0014b4858dd7e6ac76bfa1184d0b90b52e8649f5 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech>
Diffstat (limited to 'models/src')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProvider.java9
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AutomationCompositionProviderTest.java13
2 files changed, 22 insertions, 0 deletions
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 9b736483d..e26a7748f 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
@@ -269,6 +269,15 @@ public class AutomationCompositionProvider {
}
/**
+ * Delete AutomationCompositionElement.
+ *
+ * @param elementId the AutomationCompositionElement Id
+ */
+ public void deleteAutomationCompositionElement(@NonNull final UUID elementId) {
+ acElementRepository.deleteById(elementId.toString());
+ }
+
+ /**
* Validate ElementIds.
*
* @param automationComposition the AutomationComposition
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 515dfaa83..c2368fe10 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
@@ -56,6 +56,7 @@ class AutomationCompositionProviderTest {
private static final String AC_IS_NULL = "automationComposition is marked non-null but is null";
private static final String ACELEMENT_IS_NULL = "element is marked non-null but is null";
+ private static final String ACELEMENT_ID_IS_NULL = "elementId is marked non-null but is null";
private static final Coder CODER = new StandardCoder();
private static final String AUTOMATION_COMPOSITION_JSON =
@@ -241,6 +242,18 @@ class AutomationCompositionProviderTest {
}
@Test
+ void testDeleteElementById() {
+ var acElementRepository = mock(AutomationCompositionElementRepository.class);
+ var automationCompositionProvider = new AutomationCompositionProvider(
+ mock(AutomationCompositionRepository.class), acElementRepository);
+ assertThatThrownBy(() -> automationCompositionProvider.deleteAutomationCompositionElement(null))
+ .hasMessageMatching(ACELEMENT_ID_IS_NULL);
+ var elementId = UUID.randomUUID();
+ automationCompositionProvider.deleteAutomationCompositionElement(elementId);
+ verify(acElementRepository).deleteById(elementId.toString());
+ }
+
+ @Test
void testValidateElementIds() {
var acElementRepository = mock(AutomationCompositionElementRepository.class);
var automationCompositionProvider = new AutomationCompositionProvider(