aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2020-08-24 15:06:10 +0000
committerGerrit Code Review <gerrit@onap.org>2020-08-24 15:06:10 +0000
commit3d2058a63eb8996d9af6f9f6142a9f882895d682 (patch)
tree6b572a6d0a8b0392b83344b7584976663b51cd92 /controlloop/common/eventmanager
parent0a5d9cf30c61956e62cc7db4faf84f999a7196cc (diff)
parent6a37af48d1db199a0f5a9e9c48f7c5f834a90d1b (diff)
Merge "Add "special" Operation classes for new usecases"
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java27
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java2
2 files changed, 21 insertions, 8 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java
index 01c64e5bc..ae51c737f 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/Step.java
@@ -55,12 +55,20 @@ public class Step {
private final AtomicReference<Instant> startTime;
/**
- * {@code True} if this step is for the policy's actual operation, {@code false} if it's a preprocessor step.
+ * {@code True} if this step is for the policy's actual operation, {@code false} if
+ * it's a preprocessor step.
*/
@Getter
private final boolean policyStep;
/**
+ * The parent step from which this was constructed, or {@code null} if is was not
+ * constructed from another step.
+ */
+ @Getter
+ private final Step parentStep;
+
+ /**
* The operation for this step.
*/
@Getter
@@ -73,7 +81,8 @@ public class Step {
/**
- * Constructs the object. This is used when constructing the step for the policy's actual operation.
+ * Constructs the object. This is used when constructing the step for the policy's
+ * actual operation.
*
* @param params operation parameters
* @param startTime start time of the first step for the current policy, initially
@@ -83,21 +92,23 @@ public class Step {
this.params = params;
this.startTime = startTime;
this.policyStep = true;
+ this.parentStep = null;
}
/**
- * Constructs the object using information from another step. This is used when constructing a preprocessing
- * step.
+ * Constructs the object using information from another step. This is used when
+ * constructing a preprocessing step.
*
- * @param otherStep step whose information should be used
+ * @param parentStep parent step whose information should be used
* @param actor actor name
* @param operation operation name
*/
- public Step(Step otherStep, String actor, String operation) {
- this.params = otherStep.params.toBuilder().actor(actor).operation(operation).retry(null).timeoutSec(null)
+ public Step(Step parentStep, String actor, String operation) {
+ this.params = parentStep.params.toBuilder().actor(actor).operation(operation).retry(null).timeoutSec(null)
.payload(new LinkedHashMap<>()).build();
- this.startTime = otherStep.startTime;
+ this.startTime = parentStep.startTime;
this.policyStep = false;
+ this.parentStep = parentStep;
}
public String getActorName() {
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java
index 1472adc18..c4121bb38 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java
@@ -147,6 +147,7 @@ public class StepTest {
public void testConstructor() {
assertTrue(step.isPolicyStep());
assertSame(params, step.getParams());
+ assertNull(step.getParentStep());
// check that it recorded the startTime by starting and checking it
step.init();
@@ -163,6 +164,7 @@ public class StepTest {
public void testConstructorWithOtherStep_testInitStartTime_testGetStartTimeRef() {
Step step2 = new Step(step, "actorB", "operB");
assertFalse(step2.isPolicyStep());
+ assertSame(step, step2.getParentStep());
ControlLoopOperationParams params2 = step2.getParams();
assertEquals("actorB", params2.getActor());