aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-11-18 10:44:41 -0500
committerJim Hahn <jrh3@att.com>2020-11-20 11:49:01 -0500
commit1dd41890f83702d47c5a957493046433989ef36c (patch)
tree4271931cf6ca6e7c43141cc600bd8351015be294 /models-interactions/model-actors/actorServiceProvider/src
parentca468c57a4d09842f2608e32da74b30eba52d015 (diff)
Delete preprocessed flag from actors
Removed the "preprocessed" flag from the Actor parameter class, now that the actors no longer have a startPreprocess() method. Also removed targetEntity from Actor parameter class. Created a makeOutcome method within OperationPartial, which is used to create an initial outcome whose target field is pre-populated with the target-entity extracted from the properties. As the meaning of "target" may be specific to an operation, the makeOutcome method may be overridden by an operation subclass. Issue-ID: POLICY-2804 Change-Id: Ifb66de63301d644e69340009593513773ee5672d Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java26
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java16
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java18
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java34
4 files changed, 35 insertions, 59 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index e9f6b024c..c3d3f6663 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -226,7 +226,7 @@ public abstract class OperationPartial implements Operation {
logger.info("{}: start operation attempt {} for {}", getFullName(), attempt, params.getRequestId());
final Executor executor = params.getExecutor();
- final OperationOutcome outcome = params.makeOutcome(getTargetEntity());
+ final OperationOutcome outcome = makeOutcome();
final CallbackManager callbacks = new CallbackManager();
// this operation attempt gets its own controller
@@ -357,7 +357,7 @@ public abstract class OperationPartial implements Operation {
outcome = origOutcome;
} else {
logger.warn("{}: null outcome; treating as a failure for {}", getFullName(), params.getRequestId());
- outcome = this.setOutcome(params.makeOutcome(getTargetEntity()), OperationResult.FAILURE);
+ outcome = this.setOutcome(makeOutcome(), OperationResult.FAILURE);
}
// ensure correct actor/operation
@@ -456,7 +456,7 @@ public abstract class OperationPartial implements Operation {
private Function<Throwable, OperationOutcome> fromException(String type) {
return thrown -> {
- OperationOutcome outcome = params.makeOutcome(getTargetEntity());
+ OperationOutcome outcome = makeOutcome();
if (thrown instanceof CancellationException || thrown.getCause() instanceof CancellationException) {
// do not include exception in the message, as it just clutters the log
@@ -893,6 +893,16 @@ public abstract class OperationPartial implements Operation {
}
/**
+ * Makes an outcome, populating the "target" field with the contents of the target
+ * entity property.
+ *
+ * @return a new operation outcome
+ */
+ protected OperationOutcome makeOutcome() {
+ return params.makeOutcome(getProperty(OperationProperties.AAI_TARGET_ENTITY));
+ }
+
+ /**
* Determines if a throwable is due to a timeout.
*
* @param thrown throwable of interest
@@ -976,16 +986,6 @@ public abstract class OperationPartial implements Operation {
}
/**
- * Gets the target entity, first trying the properties and then the parameters.
- *
- * @return the target entity
- */
- protected String getTargetEntity() {
- String targetEntity = getProperty(OperationProperties.AAI_TARGET_ENTITY);
- return (targetEntity != null ? targetEntity : params.getTargetEntity());
- }
-
- /**
* Gets the operation timeout.
*
* @param timeoutSec timeout, in seconds, extracted from the parameters, or
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
index 67f68036b..2769697cf 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
@@ -97,13 +97,6 @@ public class ControlLoopOperationParams {
private Map<String, Object> payload;
/**
- * {@code True} if the preprocessing steps have already been executed, {@code false}
- * otherwise.
- */
- // TODO remove this once the rules no longer reference it
- private boolean preprocessed;
-
- /**
* Number of retries allowed, or {@code null} if no retries.
*/
private Integer retry;
@@ -121,12 +114,6 @@ public class ControlLoopOperationParams {
private Map<String, String> targetEntityIds;
/**
- * Target entity.
- */
- // TODO to be removed
- private String targetEntity;
-
- /**
* Timeout, in seconds, or {@code null} if no timeout. Zero and negative values also
* imply no timeout.
*/
@@ -197,9 +184,8 @@ public class ControlLoopOperationParams {
*
* @return a new operation outcome
*/
- // TODO to be removed
public OperationOutcome makeOutcome() {
- return makeOutcome(getTargetEntity());
+ return makeOutcome(null);
}
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
index b7a6a1d3b..72a7338d5 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
@@ -165,7 +165,7 @@ public class OperationPartialTest {
params = ControlLoopOperationParams.builder().completeCallback(this::completer).requestId(REQ_ID)
.executor(executor).actorService(service).actor(ACTOR).operation(OPERATION).timeoutSec(TIMEOUT)
- .startCallback(this::starter).targetEntity(MY_TARGET_ENTITY).build();
+ .startCallback(this::starter).build();
when(service.getActor(OperationPartial.GUARD_ACTOR_NAME)).thenReturn(guardActor);
when(guardActor.getOperator(OperationPartial.GUARD_OPERATION_NAME)).thenReturn(guardOperator);
@@ -924,6 +924,12 @@ public class OperationPartialTest {
}
@Test
+ public void testMakeOutcome() {
+ oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_TARGET_ENTITY);
+ assertEquals(MY_TARGET_ENTITY, oper.makeOutcome().getTarget());
+ }
+
+ @Test
public void testIsTimeout() {
final TimeoutException timex = new TimeoutException(EXPECTED_EXCEPTION);
@@ -1007,16 +1013,6 @@ public class OperationPartialTest {
}
@Test
- public void testGetTargetEntity() {
- // get it from the params
- assertEquals(MY_TARGET_ENTITY, oper.getTargetEntity());
-
- // now get it from the properties
- oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, "entityX");
- assertEquals("entityX", oper.getTargetEntity());
- }
-
- @Test
public void testGetTimeOutMs() {
assertEquals(TIMEOUT * 1000, oper.getTimeoutMs(params.getTimeoutSec()));
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java
index b6bd50c7e..fc36c12ba 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParamsTest.java
@@ -112,8 +112,8 @@ public class ControlLoopOperationParamsTest {
params = ControlLoopOperationParams.builder().actorService(actorService).completeCallback(completer)
.requestId(REQ_ID).executor(executor).actor(ACTOR).operation(OPERATION).payload(payload)
- .retry(RETRY).targetEntity(TARGET_ENTITY).timeoutSec(TIMEOUT)
- .startCallback(starter).preprocessed(true).build();
+ .retry(RETRY).timeoutSec(TIMEOUT)
+ .startCallback(starter).build();
outcome = params.makeOutcome(TARGET_ENTITY);
}
@@ -139,13 +139,20 @@ public class ControlLoopOperationParamsTest {
@Test
public void testMakeOutcome() {
- assertEquals(ACTOR, outcome.getActor());
- assertEquals(OPERATION, outcome.getOperation());
+ outcome = params.makeOutcome();
+ assertNull(outcome.getTarget());
+ checkRemainingFields("with actor");
+ }
+
+ @Test
+ public void testMakeOutcomeString() {
+ assertEquals(TARGET_ENTITY, outcome.getTarget());
checkRemainingFields("with actor");
}
protected void checkRemainingFields(String testName) {
- assertEquals(testName, TARGET_ENTITY, outcome.getTarget());
+ assertEquals(ACTOR, outcome.getActor());
+ assertEquals(OPERATION, outcome.getOperation());
assertNull(testName, outcome.getStart());
assertNull(testName, outcome.getEnd());
assertNull(testName, outcome.getSubRequestId());
@@ -212,7 +219,7 @@ public class ControlLoopOperationParamsTest {
testValidate("requestId", NULL_MSG, bldr -> bldr.requestId(null));
// has no target entity
- BeanValidationResult result = params.toBuilder().targetEntity(null).build().validate();
+ BeanValidationResult result = params.toBuilder().build().validate();
assertTrue(result.isValid());
// check edge cases
@@ -224,7 +231,7 @@ public class ControlLoopOperationParamsTest {
// test with minimal fields
assertTrue(ControlLoopOperationParams.builder().actorService(actorService).requestId(REQ_ID).actor(ACTOR)
- .operation(OPERATION).targetEntity(TARGET_ENTITY).build().validate().isValid());
+ .operation(OPERATION).build().validate().isValid());
}
private void testValidate(String fieldName, String expected,
@@ -277,14 +284,6 @@ public class ControlLoopOperationParamsTest {
}
@Test
- public void test() {
- assertTrue(params.isPreprocessed());
-
- // should be false when unspecified
- assertFalse(ControlLoopOperationParams.builder().build().isPreprocessed());
- }
-
- @Test
public void testGetRetry() {
assertSame(RETRY, params.getRetry());
@@ -312,9 +311,4 @@ public class ControlLoopOperationParamsTest {
public void testGetCompleteCallback() {
assertSame(completer, params.getCompleteCallback());
}
-
- @Test
- public void testGetTargetEntity() {
- assertEquals(TARGET_ENTITY, params.getTargetEntity());
- }
}