From b741e69ad9a60a128d1994a6fcf65f0b6aeee7ee Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Fri, 10 Sep 2021 15:38:07 +0100 Subject: Add Priming flag per controlloop This commit adds a Priming flag per controlloop which indicates whether a controlLoop is primed or deprimed. There is a rest end-point added to depict in GUI Issue-ID: POLICY-3577 Signed-off-by: Sirisha_Manchikanti Change-Id: Ie81a41505ab1eafda9515733e0b895421803ea8a --- .../models/controlloop/concepts/ControlLoop.java | 4 +++ .../persistence/concepts/JpaControlLoop.java | 10 ++++++ .../rest/instantiation/ControlLoopPrimed.java | 32 +++++++++++++++++ .../instantiation/ControlLoopPrimedResponse.java | 41 ++++++++++++++++++++++ .../persistence/concepts/JpaControlLoopTest.java | 5 +++ 5 files changed, 92 insertions(+) create mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimed.java create mode 100644 models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java (limited to 'models') diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java index f2397602b..4d3d37236 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java @@ -52,6 +52,9 @@ public class ControlLoop extends ToscaEntity implements Comparable private Map elements; + @NonNull + private Boolean primed = false; + @Override public String getType() { return definition.getName(); @@ -73,6 +76,7 @@ public class ControlLoop extends ToscaEntity implements Comparable this.state = otherControlLoop.state; this.orderedState = otherControlLoop.orderedState; this.elements = PfUtils.mapMap(otherControlLoop.elements, ControlLoopElement::new); + this.primed = otherControlLoop.primed; } @Override diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java index 2a2cde2ae..756c4f1bf 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java @@ -91,6 +91,9 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative(0)); + this.primed = copyConcept.primed; } /** @@ -163,6 +167,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative(0))); + controlLoop.setPrimed(primed); return controlLoop; } @@ -177,6 +182,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative(controlLoop.getElements().size()); for (Entry elementEntry : controlLoop.getElements().entrySet()) { @@ -249,6 +255,10 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative primedControlLoopsList = new ArrayList<>(); +} diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java index ff6cc7619..d705c49b5 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoopTest.java @@ -240,6 +240,11 @@ class JpaControlLoopTest { testJpaControlLoop.setDescription(null); assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); + testJpaControlLoop.setPrimed(true); + assertNotEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); + testJpaControlLoop.setPrimed(false); + assertEquals(0, testJpaControlLoop.compareTo(otherJpaControlLoop)); + assertEquals(testJpaControlLoop, new JpaControlLoop(testJpaControlLoop)); } -- cgit 1.2.3-korg