diff options
48 files changed, 589 insertions, 330 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java index 54801358c..612fba98d 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java @@ -37,10 +37,10 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; -import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -188,7 +188,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> { } @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse, + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, Response rawResponse, String response) { super.setOutcome(outcome, result, rawResponse, response); diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java index 8e8b8f150..5a5e170dd 100644 --- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java +++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java @@ -53,6 +53,7 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator; @@ -60,7 +61,6 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOp import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.PolicyResult; public class AaiCustomQueryOperationTest extends BasicAaiOperation { private static final StandardCoder coder = new StandardCoder(); @@ -120,7 +120,7 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation { oper.setProperty(OperationProperties.AAI_VSERVER_LINK, MY_LINK); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertNotNull(outcome.getResponse()); } @@ -171,7 +171,7 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation { CompletableFuture<OperationOutcome> future2 = oper.start(); - assertEquals(PolicyResult.SUCCESS, getResult(future2)); + assertEquals(OperationResult.SUCCESS, getResult(future2)); // tenant response should have been cached within the context assertNotNull(context.getProperty(AaiGetTenantOperation.getKey(MY_VSERVER))); @@ -198,7 +198,7 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation { CompletableFuture<OperationOutcome> future2 = oper.start(); - assertEquals(PolicyResult.SUCCESS, getResult(future2)); + assertEquals(OperationResult.SUCCESS, getResult(future2)); // should not have replaced tenant response assertSame(data, context.getProperty(AaiGetTenantOperation.getKey(MY_VSERVER))); @@ -259,10 +259,10 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation { @Test public void testSetOutcome() { - outcome = oper.setOutcome(params.makeOutcome(null), PolicyResult.SUCCESS, null, null); + outcome = oper.setOutcome(params.makeOutcome(null), OperationResult.SUCCESS, null, null); assertNull(outcome.getResponse()); - outcome = oper.setOutcome(params.makeOutcome(null), PolicyResult.SUCCESS, null, "{}"); + outcome = oper.setOutcome(params.makeOutcome(null), OperationResult.SUCCESS, null, "{}"); assertTrue(outcome.getResponse() instanceof AaiCqResponse); } @@ -289,7 +289,7 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation { context.setProperty(AaiGetTenantOperation.getKey(SIM_VSERVER), data); } - private PolicyResult getResult(CompletableFuture<OperationOutcome> future2) + private OperationResult getResult(CompletableFuture<OperationOutcome> future2) throws InterruptedException, ExecutionException, TimeoutException { executor.runAll(100); diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java index 13b5b5926..84f28210e 100644 --- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java +++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperationTest.java @@ -43,9 +43,9 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; -import org.onap.policy.controlloop.policy.PolicyResult; public class AaiGetPnfOperationTest extends BasicAaiOperation { private static final String INPUT_FIELD = "input"; @@ -100,7 +100,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation { oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, "OzVServer"); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof StandardCoderObject); } @@ -117,7 +117,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation { oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, "getFail"); outcome = oper.start().get(); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); } @Test @@ -139,7 +139,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation { executor.runAll(100); assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + assertEquals(OperationResult.SUCCESS, future2.get().getResult()); // data should have been cached within the context StandardCoderObject data = context.getProperty(AaiGetPnfOperation.getKey(TARGET_ENTITY)); @@ -167,7 +167,7 @@ public class AaiGetPnfOperationTest extends BasicAaiOperation { executor.runAll(100); assertTrue(future2.isDone()); - assertEquals(PolicyResult.FAILURE, future2.get().getResult()); + assertEquals(OperationResult.FAILURE, future2.get().getResult()); // data should NOT have been cached within the context assertNull(context.getProperty(AaiGetPnfOperation.getKey(TARGET_ENTITY))); diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java index 11604cdb9..cf9a7a6a1 100644 --- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java +++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperationTest.java @@ -43,9 +43,9 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; -import org.onap.policy.controlloop.policy.PolicyResult; public class AaiGetTenantOperationTest extends BasicAaiOperation { private static final String INPUT_FIELD = "input"; @@ -100,7 +100,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation { oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, "OzVServer"); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof StandardCoderObject); } @@ -117,7 +117,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation { oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, "failedVserver"); outcome = oper.start().get(); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); } @Test @@ -139,7 +139,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation { executor.runAll(100); assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + assertEquals(OperationResult.SUCCESS, future2.get().getResult()); // data should have been cached within the context StandardCoderObject data = context.getProperty(AaiGetTenantOperation.getKey(TARGET_ENTITY)); @@ -167,7 +167,7 @@ public class AaiGetTenantOperationTest extends BasicAaiOperation { executor.runAll(100); assertTrue(future2.isDone()); - assertEquals(PolicyResult.FAILURE, future2.get().getResult()); + assertEquals(OperationResult.FAILURE, future2.get().getResult()); // data should NOT have been cached within the context assertNull(context.getProperty(AaiGetTenantOperation.getKey(TARGET_ENTITY))); diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java index e07093ae6..70c70823c 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java @@ -33,11 +33,11 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderInstantAsMillis; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey; -import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -172,7 +172,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request, * Sets the message to the status description, if available. */ @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response response) { + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, Response response) { outcome.setResponse(response); if (response.getStatus() == null || response.getStatus().getDescription() == null) { diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java index 13ddaf4a9..1f5b9fd10 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java @@ -83,7 +83,8 @@ public class ModifyConfigOperation extends AppcOperation { throw new IllegalStateException("target vnf-id could not be determined"); } - GenericVnf genvnf = cq.getGenericVnfByModelInvariantId(params.getTarget().getResourceID()); + GenericVnf genvnf = cq.getGenericVnfByModelInvariantId(params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID)); if (genvnf == null) { logger.info("{}: target entity could not be found for {}", getFullName(), params.getRequestId()); throw new IllegalArgumentException("target vnf-id could not be found"); diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java index 4bbb057d7..db104b6bb 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java @@ -39,10 +39,10 @@ import org.onap.policy.appc.CommonHeader; import org.onap.policy.appc.Request; import org.onap.policy.appc.ResponseCode; import org.onap.policy.appc.ResponseStatus; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; -import org.onap.policy.controlloop.policy.PolicyResult; public class AppcOperationTest extends BasicAppcOperation { private AppcOperation oper; @@ -220,21 +220,21 @@ public class AppcOperationTest extends BasicAppcOperation { // null status response.setStatus(null); - assertSame(outcome, oper.setOutcome(outcome, PolicyResult.SUCCESS, response)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertSame(outcome, oper.setOutcome(outcome, OperationResult.SUCCESS, response)); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertNotNull(outcome.getMessage()); assertSame(response, outcome.getResponse()); response.setStatus(status); // null description status.setDescription(null); - assertSame(outcome, oper.setOutcome(outcome, PolicyResult.FAILURE, response)); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertSame(outcome, oper.setOutcome(outcome, OperationResult.FAILURE, response)); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertNotNull(outcome.getMessage()); assertSame(response, outcome.getResponse()); status.setDescription(MY_DESCRIPTION); - for (PolicyResult result : PolicyResult.values()) { + for (OperationResult result : OperationResult.values()) { assertSame(outcome, oper.setOutcome(outcome, result, response)); assertEquals(result, outcome.getResult()); assertEquals(MY_DESCRIPTION, outcome.getMessage()); diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java index 1a8c60350..9d434cebf 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java @@ -42,11 +42,11 @@ import org.onap.policy.common.utils.coder.StandardCoderInstantAsMillis; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.Target; +import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.simulators.AppcLegacyTopicServer; import org.onap.policy.simulators.TopicServer; import org.powermock.reflect.Whitebox; @@ -103,6 +103,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio super.tearDownBasic(); } + @Override protected TopicServer<Request> makeServer(TopicSink sink, TopicSource source) { return new AppcLegacyTopicServer(sink, source); } @@ -126,7 +127,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio assertTrue(future2.isDone()); outcome = future2.get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(MY_DESCRIPTION, outcome.getMessage()); } @@ -153,10 +154,9 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio protected void makeContext() { super.makeContext(); - Target target = new Target(); - target.setResourceID(RESOURCE_ID); + Map<String, String> entities = Map.of(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, RESOURCE_ID); - params = params.toBuilder().target(target).build(); + params = params.toBuilder().targetEntityIds(entities).build(); } /** diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java index 2177dfa41..749b6c86c 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java @@ -51,10 +51,10 @@ import org.onap.policy.appc.Response; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; -import org.onap.policy.controlloop.policy.PolicyResult; public class ModifyConfigOperationTest extends BasicAppcOperation { @@ -120,7 +120,7 @@ public class ModifyConfigOperationTest extends BasicAppcOperation { oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof Response); } @@ -162,7 +162,7 @@ public class ModifyConfigOperationTest extends BasicAppcOperation { future2.complete(params.makeOutcome(null)); assertTrue(executor.runAll(100)); assertTrue(future3.isDone()); - assertEquals(PolicyResult.SUCCESS, future3.get().getResult()); + assertEquals(OperationResult.SUCCESS, future3.get().getResult()); } /** diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java index dc74825f7..1d687cded 100644 --- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java +++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperation.java @@ -33,11 +33,11 @@ import org.onap.policy.appclcm.AppcLcmResponseStatus; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey; -import org.onap.policy.controlloop.policy.PolicyResult; public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWrapper, AppcLcmDmaapWrapper> { @@ -177,7 +177,7 @@ public class AppcLcmOperation extends BidirectionalTopicOperation<AppcLcmDmaapWr * Sets the message to the status description, if available. */ @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, AppcLcmDmaapWrapper response) { + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, AppcLcmDmaapWrapper response) { outcome.setResponse(response); AppcLcmResponseStatus status = getStatus(response); diff --git a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java index f3b3cc2f3..e707ea942 100644 --- a/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java +++ b/models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java @@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -57,12 +58,12 @@ import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.Target; +import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.simulators.AppcLcmTopicServer; import org.onap.policy.simulators.TopicServer; @@ -106,6 +107,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL super.tearDownBasic(); } + @Override protected TopicServer<AppcLcmDmaapWrapper> makeServer(TopicSink sink, TopicSource source) { return new AppcLcmTopicServer(sink, source); } @@ -129,7 +131,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL }; outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof AppcLcmDmaapWrapper); } @@ -168,7 +170,7 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL assertTrue(executor.runAll(100)); assertTrue(future2.isDone()); outcome = future2.get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); } @Test @@ -260,26 +262,26 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL @Test public void testSetOutcome() { - oper.setOutcome(outcome, PolicyResult.SUCCESS, response); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + oper.setOutcome(outcome, OperationResult.SUCCESS, response); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(MY_MESSAGE, outcome.getMessage()); assertSame(response, outcome.getResponse()); // failure - oper.setOutcome(outcome, PolicyResult.FAILURE, response); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + oper.setOutcome(outcome, OperationResult.FAILURE, response); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertEquals(MY_MESSAGE, outcome.getMessage()); assertSame(response, outcome.getResponse()); // null message response.getBody().getOutput().getStatus().setMessage(null); - oper.setOutcome(outcome, PolicyResult.SUCCESS, response); + oper.setOutcome(outcome, OperationResult.SUCCESS, response); assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); assertSame(response, outcome.getResponse()); // null status response.getBody().getOutput().setStatus(null); - oper.setOutcome(outcome, PolicyResult.SUCCESS, response); + oper.setOutcome(outcome, OperationResult.SUCCESS, response); assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); assertSame(response, outcome.getResponse()); } @@ -348,10 +350,10 @@ public class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcL protected void makeContext() { super.makeContext(); - Target target = new Target(); - target.setResourceID(RESOURCE_ID); + Map<String, String> targetEntities = new HashMap<>(); + targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, RESOURCE_ID); - params = params.toBuilder().target(target).build(); + params = params.toBuilder().targetEntityIds(targetEntities).build(); } @Override diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java index d0f5bd2b4..4da23f1a8 100644 --- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java +++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/CdsActorServiceManager.java @@ -23,7 +23,7 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.onap.policy.cds.api.CdsProcessorListener; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,12 +61,12 @@ public class CdsActorServiceManager implements CdsProcessorListener { LOGGER.info("CDS is processing the message: {}", message); break; case EVENT_COMPONENT_EXECUTED: - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); outcome.setResponse(message); future.complete(outcome); break; default: - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); outcome.setResponse(message); future.complete(outcome); break; diff --git a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java index d3842441d..c04453b7c 100644 --- a/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java +++ b/models-interactions/model-actors/actor.cds/src/main/java/org/onap/policy/controlloop/actor/cds/GrpcOperation.java @@ -50,11 +50,11 @@ import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; import org.onap.policy.controlloop.actor.cds.request.CdsActionRequest; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.TargetType; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture; -import org.onap.policy.controlloop.policy.TargetType; /** * Operation that uses gRPC to send request to CDS. @@ -111,7 +111,7 @@ public class GrpcOperation extends OperationPartial { super(params, config, Collections.emptyList()); this.config = config; - if (TargetType.PNF.equals(params.getTarget().getType())) { + if (TargetType.PNF.equals(params.getTargetType())) { aaiRequestor = this::getPnf; aaiConverter = this::convertPnfToAaiProperties; } else { @@ -122,7 +122,7 @@ public class GrpcOperation extends OperationPartial { @Override public List<String> getPropertyNames() { - return (TargetType.PNF.equals(params.getTarget().getType()) ? PNF_PROPERTY_NAMES : VNF_PROPERTY_NAMES); + return (TargetType.PNF.equals(params.getTargetType()) ? PNF_PROPERTY_NAMES : VNF_PROPERTY_NAMES); } /** @@ -259,7 +259,8 @@ public class GrpcOperation extends OperationPartial { AaiCqResponse aaicq = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY); - genericVnf = aaicq.getGenericVnfByModelInvariantId(params.getTarget().getResourceID()); + genericVnf = aaicq.getGenericVnfByModelInvariantId(params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID)); if (genericVnf == null) { throw new IllegalArgumentException("Target generic vnf could not be found"); } diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java index 908b05c08..07a05e6b8 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcActorServiceManagerTest.java @@ -36,7 +36,7 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; public class GrpcActorServiceManagerTest { @@ -61,7 +61,7 @@ public class GrpcActorServiceManagerTest { output = ExecutionServiceOutput.newBuilder().setStatus(status).build(); manager.onMessage(output); OperationOutcome outcome = future.get(2, TimeUnit.SECONDS); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertSame(output, outcome.getResponse()); } @@ -82,7 +82,7 @@ public class GrpcActorServiceManagerTest { output = ExecutionServiceOutput.newBuilder().setStatus(status).build(); manager.onMessage(output); OperationOutcome outcome = future.get(2, TimeUnit.SECONDS); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertSame(output, outcome.getResponse()); } diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java index 512349555..709e179e6 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java @@ -69,11 +69,10 @@ import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; +import org.onap.policy.controlloop.actorserviceprovider.TargetType; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.simulators.CdsSimulator; import org.onap.policy.simulators.Util; @@ -102,7 +101,8 @@ public class GrpcOperationTest { private CdsServerProperties cdsProps; private VirtualControlLoopEvent onset; private PseudoExecutor executor; - private Target target; + private TargetType targetType; + private Map<String, String> targetEntityIds; private ControlLoopOperationParams params; private GrpcConfig config; private CompletableFuture<OperationOutcome> cqFuture; @@ -143,17 +143,18 @@ public class GrpcOperationTest { // Setup executor executor = new PseudoExecutor(); - target = new Target(); - target.setType(TargetType.VM); - target.setResourceID(RESOURCE_ID); + targetType = TargetType.VM; + targetEntityIds = new HashMap<>(); + targetEntityIds.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, RESOURCE_ID); cqFuture = new CompletableFuture<>(); when(context.obtain(eq(AaiCqResponse.CONTEXT_KEY), any())).thenReturn(cqFuture); when(context.getEvent()).thenReturn(onset); - params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation(GrpcOperation.NAME) - .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target) - .build(); + params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR) + .operation(GrpcOperation.NAME).context(context).actorService(new ActorService()) + .targetEntity(TARGET_ENTITY).targetType(targetType).targetEntityIds(targetEntityIds) + .build(); } /** @@ -167,7 +168,8 @@ public class GrpcOperationTest { Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0"); params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe") - .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target) + .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY) + .targetType(targetType).targetEntityIds(targetEntityIds) .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload).build(); cdsProps.setHost("localhost"); @@ -185,7 +187,7 @@ public class GrpcOperationTest { }; OperationOutcome outcome = operation.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof ExecutionServiceOutput); } @@ -200,7 +202,8 @@ public class GrpcOperationTest { Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0"); params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe") - .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY).target(target) + .context(context).actorService(new ActorService()).targetEntity(TARGET_ENTITY) + .targetType(targetType).targetEntityIds(targetEntityIds) .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload).preprocessed(true).build(); cdsProps.setHost("localhost"); @@ -215,7 +218,7 @@ public class GrpcOperationTest { operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap()); OperationOutcome outcome = operation.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof ExecutionServiceOutput); } @@ -239,7 +242,7 @@ public class GrpcOperationTest { /* * check PNF case */ - target.setType(TargetType.PNF); + params = params.toBuilder().targetType(TargetType.PNF).build(); operation = new GrpcOperation(params, config); // @formatter:off @@ -334,7 +337,7 @@ public class GrpcOperationTest { cqFuture.complete(params.makeOutcome(null)); assertTrue(executor.runAll(100)); - assertEquals(PolicyResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult()); + assertEquals(OperationResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult()); assertTrue(future3.isDone()); } @@ -345,7 +348,7 @@ public class GrpcOperationTest { public void testStartPreprocessorAsyncPnf() throws InterruptedException, ExecutionException, TimeoutException { AtomicBoolean guardStarted = new AtomicBoolean(); - target.setType(TargetType.PNF); + params = params.toBuilder().targetType(TargetType.PNF).build(); operation = new GrpcOperation(params, config) { @Override @@ -362,7 +365,7 @@ public class GrpcOperationTest { cqFuture.complete(params.makeOutcome(null)); assertTrue(executor.runAll(100)); - assertEquals(PolicyResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult()); + assertEquals(OperationResult.SUCCESS, future3.get(2, TimeUnit.SECONDS).getResult()); assertTrue(future3.isDone()); } @@ -390,7 +393,7 @@ public class GrpcOperationTest { @Test public void testStartOperationAsyncPnf() throws Exception { - target.setType(TargetType.PNF); + targetType = TargetType.PNF; ControlLoopEventContext context = new ControlLoopEventContext(onset); loadPnfData(context); @@ -447,7 +450,8 @@ public class GrpcOperationTest { ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR) .operation(GrpcOperation.NAME).context(context).actorService(new ActorService()) - .targetEntity(TARGET_ENTITY).target(target).payload(payloadMap).build(); + .targetEntity(TARGET_ENTITY).targetType(targetType).targetEntityIds(targetEntityIds) + .payload(payloadMap).build(); GrpcConfig config = new GrpcConfig(executor, cdsProps); operation = new GrpcOperation(params, config); diff --git a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java index cfb20ab6c..11121c0b3 100644 --- a/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java +++ b/models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperatorTest.java @@ -32,12 +32,11 @@ import org.onap.policy.cds.properties.CdsServerProperties; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; import org.onap.policy.controlloop.actorserviceprovider.Operation; +import org.onap.policy.controlloop.actorserviceprovider.TargetType; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; public class GrpcOperatorTest { @@ -88,10 +87,8 @@ public class GrpcOperatorTest { public void testBuildOperation() { VirtualControlLoopEvent event = new VirtualControlLoopEvent(); ControlLoopEventContext context = new ControlLoopEventContext(event); - Target target = new Target(); - target.setType(TargetType.VM); ControlLoopOperationParams params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR) - .operation(GrpcOperation.NAME).context(context).target(target).build(); + .operation(GrpcOperation.NAME).context(context).targetType(TargetType.VM).build(); // not configured yet assertThatIllegalStateException().isThrownBy(() -> operation.buildOperation(params)); diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperation.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperation.java index 032a0c179..d9ec3ab2c 100644 --- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperation.java +++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperation.java @@ -31,11 +31,11 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.controlloop.actorserviceprovider.CallbackManager; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.slf4j.Logger; @@ -150,15 +150,15 @@ public class DecisionOperation extends HttpOperation<DecisionResponse> { // determine the result String status = response.getStatus(); if (status == null) { - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); outcome.setMessage("response contains no status"); return CompletableFuture.completedFuture(outcome); } if (PERMIT.equalsIgnoreCase(status) || INDETERMINATE.equalsIgnoreCase(status)) { - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); } else { - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); } // set the message diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java index ac6d6c8e3..5502ec6aa 100644 --- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java +++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java @@ -49,8 +49,8 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInst import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actor.test.BasicHttpOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Util; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.simulators.GuardSimulatorJaxRs; @@ -121,7 +121,7 @@ public class DecisionOperationTest extends BasicHttpOperation { oper = new DecisionOperation(params, config); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof DecisionResponse); } @@ -138,7 +138,7 @@ public class DecisionOperationTest extends BasicHttpOperation { oper = new DecisionOperation(params, config); outcome = oper.start().get(); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertTrue(outcome.getResponse() instanceof DecisionResponse); } @@ -170,7 +170,7 @@ public class DecisionOperationTest extends BasicHttpOperation { assertTrue(future2.isDone()); outcome = future2.get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(resp, outcome.getResponse()); assertNotNull(oper.getSubRequestId()); @@ -194,7 +194,7 @@ public class DecisionOperationTest extends BasicHttpOperation { assertTrue(future2.isDone()); outcome = future2.get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertNull(outcome.getResponse()); // ensure callbacks were invoked @@ -237,26 +237,26 @@ public class DecisionOperationTest extends BasicHttpOperation { // null status response.setStatus(null); - verifyOutcome(response, PolicyResult.FAILURE, "response contains no status"); + verifyOutcome(response, OperationResult.FAILURE, "response contains no status"); // permit, mixed case response.setStatus("peRmit"); - verifyOutcome(response, PolicyResult.SUCCESS, "peRmit"); + verifyOutcome(response, OperationResult.SUCCESS, "peRmit"); // indeterminate, mixed case response.setStatus("inDETerminate"); - verifyOutcome(response, PolicyResult.SUCCESS, "inDETerminate"); + verifyOutcome(response, OperationResult.SUCCESS, "inDETerminate"); // deny, mixed case response.setStatus("deNY"); - verifyOutcome(response, PolicyResult.FAILURE, "deNY"); + verifyOutcome(response, OperationResult.FAILURE, "deNY"); // unknown status response.setStatus("unknown"); - verifyOutcome(response, PolicyResult.FAILURE, "unknown"); + verifyOutcome(response, OperationResult.FAILURE, "unknown"); } - private void verifyOutcome(DecisionResponse response, PolicyResult expectedResult, String expectedMessage) { + private void verifyOutcome(DecisionResponse response, OperationResult expectedResult, String expectedMessage) { oper.postProcessResponse(outcome, BASE_URI, rawResponse, response); assertEquals(expectedResult, outcome.getResult()); assertEquals(expectedMessage, outcome.getMessage()); diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java index f80299f93..5e71a6cd5 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java @@ -32,10 +32,10 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnc.SdncRequest; import org.onap.policy.sdnc.SdncResponse; @@ -64,6 +64,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { /** * Set up. */ + @Override @Before public void setUp() throws Exception { super.setUp(); @@ -107,7 +108,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { oper.setProperty(OperationProperties.ENRICHMENT_VNF_ID, MY_VNF); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SdncResponse); } diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java index 8c45bc303..a118ab124 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java @@ -40,9 +40,9 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.controlloop.actor.test.BasicHttpOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnc.SdncRequest; import org.onap.policy.sdnc.SdncResponse; import org.onap.policy.sdnc.SdncResponseOutput; @@ -128,7 +128,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation { assertTrue(future2.isDone()); outcome = future2.get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SdncResponse); assertNotNull(outcome.getSubRequestId()); @@ -157,5 +157,6 @@ public abstract class BasicSdncOperation extends BasicHttpOperation { .withMessageContaining("missing").withMessageContaining(expectedText); } + @Override protected abstract Map<String, String> makeEnrichment(); } diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java index b71e567bf..e41ef3fec 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java @@ -32,10 +32,10 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnc.SdncRequest; import org.onap.policy.sdnc.SdncResponse; @@ -62,6 +62,7 @@ public class RerouteOperationTest extends BasicSdncOperation { /** * Set up. */ + @Override @Before public void setUp() throws Exception { super.setUp(); @@ -84,7 +85,7 @@ public class RerouteOperationTest extends BasicSdncOperation { oper.setProperty(OperationProperties.ENRICHMENT_NETWORK_ID, MY_NETWORK); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SdncResponse); } diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java index 4511cc3c5..308ddd9bd 100644 --- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java +++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java @@ -24,11 +24,11 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnr.PciBody; import org.onap.policy.sdnr.PciCommonHeader; import org.onap.policy.sdnr.PciMessage; @@ -118,7 +118,7 @@ public class SdnrOperation extends BidirectionalTopicOperation<PciMessage, PciMe * Sets the message to the status description, if available. */ @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, PciMessage responseWrapper) { + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, PciMessage responseWrapper) { outcome.setResponse(responseWrapper); if (responseWrapper.getBody() == null || responseWrapper.getBody().getOutput() == null) { diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java index 385052fec..912d27316 100644 --- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java +++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java @@ -36,10 +36,10 @@ import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnr.PciBody; import org.onap.policy.sdnr.PciMessage; import org.onap.policy.sdnr.PciResponse; @@ -94,6 +94,7 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio super.tearDownBasic(); } + @Override protected TopicServer<PciMessage> makeServer(TopicSink sink, TopicSource source) { return new SdnrTopicServer(sink, source); } @@ -117,7 +118,7 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio assertTrue(future2.isDone()); outcome = future2.get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); } /** diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java index 7537fa267..90452a9af 100644 --- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java +++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java @@ -42,11 +42,11 @@ import org.junit.Test; import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation.Status; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnr.PciCommonHeader; import org.onap.policy.sdnr.PciMessage; import org.onap.policy.sdnr.PciRequest; @@ -142,7 +142,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { }; outcome = operation.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof PciMessage); } @@ -171,7 +171,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { future2.complete(params.makeOutcome(null)); assertTrue(executor.runAll(100)); assertTrue(future3.isDone()); - assertEquals(PolicyResult.SUCCESS, future3.get().getResult()); + assertEquals(OperationResult.SUCCESS, future3.get().getResult()); } @Test @@ -255,8 +255,8 @@ public class SdnrOperationTest extends BasicSdnrOperation { } protected void checkOutcome() { - assertSame(outcome, operation.setOutcome(outcome, PolicyResult.SUCCESS, response)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertSame(outcome, operation.setOutcome(outcome, OperationResult.SUCCESS, response)); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertNotNull(outcome.getMessage()); assertSame(response, outcome.getResponse()); } diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java index 8f0dda3d2..8a0cb703b 100644 --- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java +++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java @@ -46,11 +46,10 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.Target; import org.onap.policy.so.SoCloudConfiguration; import org.onap.policy.so.SoModelInfo; import org.onap.policy.so.SoRequest; @@ -80,6 +79,8 @@ public abstract class SoOperation extends HttpOperation<SoResponse> { private final String modelCustomizationId; private final String modelInvariantId; private final String modelVersionId; + private final String modelName; + private final String modelVersion; private final String vfCountKey; @@ -96,11 +97,20 @@ public abstract class SoOperation extends HttpOperation<SoResponse> { setUsePolling(); - verifyNotNull("Target information", params.getTarget()); + verifyNotNull("Target information", params.getTargetType()); - this.modelCustomizationId = params.getTarget().getModelCustomizationId(); - this.modelInvariantId = params.getTarget().getModelInvariantId(); - this.modelVersionId = params.getTarget().getModelVersionId(); + verifyNotNull("Target entity Ids information", params.getTargetEntityIds()); + + this.modelCustomizationId = params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID); + this.modelInvariantId = params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID); + this.modelVersionId = params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID); + this.modelVersion = params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION); + this.modelName = params.getTargetEntityIds() + .get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_NAME); vfCountKey = SoConstants.VF_COUNT_PREFIX + "[" + modelCustomizationId + "][" + modelInvariantId + "][" + modelVersionId + "]"; @@ -117,9 +127,9 @@ public abstract class SoOperation extends HttpOperation<SoResponse> { * the VF count from the custom query. */ protected void validateTarget() { - verifyNotNull("modelCustomizationId", modelCustomizationId); - verifyNotNull("modelInvariantId", modelInvariantId); - verifyNotNull("modelVersionId", modelVersionId); + verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID, modelCustomizationId); + verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID, modelInvariantId); + verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID, modelVersionId); } private void verifyNotNull(String type, Object value) { @@ -267,13 +277,13 @@ public abstract class SoOperation extends HttpOperation<SoResponse> { * Prepends the message with the http status code. */ @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse, + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, Response rawResponse, SoResponse response) { // set default result and message setOutcome(outcome, result); - int code = (result == PolicyResult.FAILURE_TIMEOUT ? SO_RESPONSE_CODE : rawResponse.getStatus()); + int code = (result == OperationResult.FAILURE_TIMEOUT ? SO_RESPONSE_CODE : rawResponse.getStatus()); outcome.setResponse(response); outcome.setMessage(code + " " + outcome.getMessage()); @@ -281,23 +291,12 @@ public abstract class SoOperation extends HttpOperation<SoResponse> { } protected SoModelInfo prepareSoModelInfo() { - Target target = params.getTarget(); - if (target == null) { - throw new IllegalArgumentException("missing Target"); - } - - if (target.getModelCustomizationId() == null || target.getModelInvariantId() == null - || target.getModelName() == null || target.getModelVersion() == null - || target.getModelVersionId() == null) { - throw new IllegalArgumentException("missing VF Module model"); - } - SoModelInfo soModelInfo = new SoModelInfo(); - soModelInfo.setModelCustomizationId(target.getModelCustomizationId()); - soModelInfo.setModelInvariantId(target.getModelInvariantId()); - soModelInfo.setModelName(target.getModelName()); - soModelInfo.setModelVersion(target.getModelVersion()); - soModelInfo.setModelVersionId(target.getModelVersionId()); + soModelInfo.setModelCustomizationId(modelCustomizationId); + soModelInfo.setModelInvariantId(modelInvariantId); + soModelInfo.setModelName(modelName); + soModelInfo.setModelVersion(modelVersion); + soModelInfo.setModelVersionId(modelVersionId); soModelInfo.setModelType("vfModule"); return soModelInfo; } diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java index 3541333c0..d2e2872d5 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java @@ -34,9 +34,10 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.controlloop.actor.test.BasicHttpOperation; +import org.onap.policy.controlloop.actorserviceprovider.TargetType; import org.onap.policy.controlloop.actorserviceprovider.Util; +import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; -import org.onap.policy.controlloop.policy.Target; import org.onap.policy.simulators.SoSimulatorJaxRs; import org.onap.policy.so.SoRequest; import org.onap.policy.so.SoRequestParameters; @@ -65,7 +66,8 @@ public abstract class BasicSoOperation extends BasicHttpOperation { @Mock protected HttpPollingConfig config; - protected Target target; + protected TargetType targetType; + protected Map<String, String> targetEntities = new HashMap<>(); protected SoResponse response; /** @@ -144,14 +146,16 @@ public abstract class BasicSoOperation extends BasicHttpOperation { protected void makeContext() { super.makeContext(); - target = new Target(); - target.setModelCustomizationId(MODEL_CUSTOM_ID); - target.setModelInvariantId(MODEL_INVAR_ID); - target.setModelName(MODEL_NAME); - target.setModelVersion(MODEL_VERSION); - target.setModelVersionId(MODEL_VERS_ID); + targetType = TargetType.VNF; - params = params.toBuilder().target(target).build(); + targetEntities = new HashMap<>(); + targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID, MODEL_CUSTOM_ID); + targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID, MODEL_INVAR_ID); + targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_NAME, MODEL_NAME); + targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION, MODEL_VERSION); + targetEntities.put(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID, MODEL_VERS_ID); + + params = params.toBuilder().targetType(targetType).targetEntityIds(targetEntities).build(); } @Override diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java index e364246e4..464e5d162 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java @@ -35,9 +35,9 @@ import java.time.LocalDateTime; import java.time.Month; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; -import java.util.function.Consumer; import java.util.function.Supplier; import org.junit.Before; import org.junit.Test; @@ -52,7 +52,8 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; +import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.so.SoModelInfo; import org.onap.policy.so.SoRequest; import org.onap.policy.so.SoRequestInfo; @@ -73,6 +74,7 @@ public class SoOperationTest extends BasicSoOperation { /** * Sets up. */ + @Override @Before public void setUp() throws Exception { super.setUp(); @@ -90,7 +92,7 @@ public class SoOperationTest extends BasicSoOperation { assertTrue(oper.isUsePolling()); // check when Target is null - params = params.toBuilder().target(null).build(); + params = params.toBuilder().targetType(null).build(); assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config, PROP_NAMES) {}) .withMessageContaining("Target information"); } @@ -98,23 +100,23 @@ public class SoOperationTest extends BasicSoOperation { @Test public void testValidateTarget() { // check when various fields are null - verifyNotNull("modelCustomizationId", target::getModelCustomizationId, target::setModelCustomizationId); - verifyNotNull("modelInvariantId", target::getModelInvariantId, target::setModelInvariantId); - verifyNotNull("modelVersionId", target::getModelVersionId, target::setModelVersionId); + verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID, targetEntities); + verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID, targetEntities); + verifyNotNull(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID, targetEntities); // verify it's still valid assertThatCode(() -> new VfModuleCreate(params, config)).doesNotThrowAnyException(); } - private void verifyNotNull(String expectedText, Supplier<String> getter, Consumer<String> setter) { - String originalValue = getter.get(); + private void verifyNotNull(String expectedText, Map<String, String> targetEntities) { + String originalValue = targetEntities.get(expectedText); // try with null - setter.accept(null); + targetEntities.put(expectedText, null); assertThatIllegalArgumentException().isThrownBy(() -> new VfModuleCreate(params, config)) .withMessageContaining(expectedText); - setter.accept(originalValue); + targetEntities.put(expectedText, originalValue); } @Test @@ -178,7 +180,7 @@ public class SoOperationTest extends BasicSoOperation { assertTrue(executor.runAll(100)); assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + assertEquals(OperationResult.SUCCESS, future2.get().getResult()); // verify that the count was stored Integer vfcount = context.getProperty(VF_COUNT_KEY); @@ -219,49 +221,33 @@ public class SoOperationTest extends BasicSoOperation { public void testSetOutcome() { // success case when(rawResponse.getStatus()).thenReturn(200); - assertSame(outcome, oper.setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response)); + assertSame(outcome, oper.setOutcome(outcome, OperationResult.SUCCESS, rawResponse, response)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals("200 " + ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); assertSame(response, outcome.getResponse()); // failure case when(rawResponse.getStatus()).thenReturn(500); - assertSame(outcome, oper.setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response)); + assertSame(outcome, oper.setOutcome(outcome, OperationResult.FAILURE, rawResponse, response)); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertEquals("500 " + ControlLoopOperation.FAILED_MSG, outcome.getMessage()); assertSame(response, outcome.getResponse()); } @Test public void testPrepareSoModelInfo() throws CoderException { - verifyMissingModelInfo(target::getModelCustomizationId, target::setModelCustomizationId); - verifyMissingModelInfo(target::getModelInvariantId, target::setModelInvariantId); - verifyMissingModelInfo(target::getModelName, target::setModelName); - verifyMissingModelInfo(target::getModelVersion, target::setModelVersion); - verifyMissingModelInfo(target::getModelVersionId, target::setModelVersionId); - // valid data SoModelInfo info = oper.prepareSoModelInfo(); verifyRequest("model.json", info); // try with null target - params = params.toBuilder().target(null).build(); + params = params.toBuilder().targetType(null).build(); assertThatIllegalArgumentException().isThrownBy(() -> new SoOperation(params, config, PROP_NAMES) {}) .withMessageContaining("missing Target"); } - private void verifyMissingModelInfo(Supplier<String> getter, Consumer<String> setter) { - String original = getter.get(); - - setter.accept(null); - assertThatIllegalArgumentException().isThrownBy(() -> oper.prepareSoModelInfo()) - .withMessage("missing VF Module model"); - - setter.accept(original); - } - @Test public void testConstructRequestInfo() throws CoderException { SoRequestInfo info = oper.constructRequestInfo(); diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java index 9d80343e6..f1741d677 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java @@ -54,10 +54,10 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.so.SoRequest; import org.onap.policy.so.SoResponse; @@ -83,6 +83,7 @@ public class VfModuleCreateTest extends BasicSoOperation { destroyAfterClass(); } + @Override @Before public void setUp() throws Exception { super.setUp(); @@ -104,7 +105,7 @@ public class VfModuleCreateTest extends BasicSoOperation { oper = new VfModuleCreate(params, config); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SoResponse); } @@ -146,7 +147,7 @@ public class VfModuleCreateTest extends BasicSoOperation { // run the operation outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SoResponse); int count = oper.getProperty(OperationProperties.DATA_VF_COUNT); @@ -159,7 +160,7 @@ public class VfModuleCreateTest extends BasicSoOperation { assertEquals(VfModuleCreate.NAME, oper.getName()); // verify that target validation is done - params = params.toBuilder().target(null).build(); + params = params.toBuilder().targetType(null).build(); assertThatIllegalArgumentException().isThrownBy(() -> new VfModuleCreate(params, config)) .withMessageContaining("Target information"); } @@ -220,7 +221,7 @@ public class VfModuleCreateTest extends BasicSoOperation { provideCqResponse(makeCqResponse()); assertTrue(executor.runAll(100)); assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + assertEquals(OperationResult.SUCCESS, future2.get().getResult()); } @Test @@ -264,7 +265,7 @@ public class VfModuleCreateTest extends BasicSoOperation { CompletableFuture<OperationOutcome> future2 = oper.start(); outcome = future2.get(5, TimeUnit.SECONDS); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); SoResponse resp = outcome.getResponse(); assertNotNull(resp); @@ -296,7 +297,7 @@ public class VfModuleCreateTest extends BasicSoOperation { CompletableFuture<OperationOutcome> future2 = oper.start(); outcome = future2.get(5, TimeUnit.SECONDS); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); } @Test diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java index 9335f0141..2ab1dbe83 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java @@ -67,10 +67,10 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.so.SoRequest; import org.onap.policy.so.SoResponse; @@ -108,6 +108,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { /** * Sets up. */ + @Override @Before public void setUp() throws Exception { super.setUp(); @@ -133,7 +134,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { oper = new VfModuleDelete(params, config); outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SoResponse); } @@ -167,7 +168,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { // run the operation outcome = oper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof SoResponse); int count = oper.getProperty(OperationProperties.DATA_VF_COUNT); @@ -180,7 +181,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { assertEquals(VfModuleDelete.NAME, oper.getName()); // verify that target validation is done - params = params.toBuilder().target(null).build(); + params = params.toBuilder().targetType(null).build(); assertThatIllegalArgumentException().isThrownBy(() -> new MyOperation(params, config)) .withMessageContaining("Target information"); } @@ -239,7 +240,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { provideCqResponse(makeCqResponse()); assertTrue(executor.runAll(100)); assertTrue(future2.isDone()); - assertEquals(PolicyResult.SUCCESS, future2.get().getResult()); + assertEquals(OperationResult.SUCCESS, future2.get().getResult()); } @Test @@ -281,7 +282,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { CompletableFuture<OperationOutcome> future2 = oper.start(); outcome = future2.get(5, TimeUnit.SECONDS); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); SoResponse resp = outcome.getResponse(); assertNotNull(resp); @@ -315,7 +316,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { CompletableFuture<OperationOutcome> future2 = oper.start(); outcome = future2.get(5, TimeUnit.SECONDS); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); } @Test diff --git a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java index a0bb58e09..cdedbf401 100644 --- a/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java +++ b/models-interactions/model-actors/actor.test/src/main/java/org/onap/policy/controlloop/actor/test/BasicOperation.java @@ -43,12 +43,12 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Operator; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.PolicyResult; /** * Superclass for various Operation tests. @@ -137,7 +137,7 @@ public class BasicOperation { when(guardOperator.buildOperation(any())).thenReturn(guardOperation); outcome = params.makeOutcome(TARGET_ENTITY); - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); when(guardOperation.start()).thenReturn(CompletableFuture.completedFuture(outcome)); when(service.getActor(AaiConstants.ACTOR_NAME)).thenReturn(cqActor); @@ -227,7 +227,7 @@ public class BasicOperation { protected void provideCqResponse(AaiCqResponse cq) { context.setProperty(AaiCqResponse.CONTEXT_KEY, cq); OperationOutcome outcome2 = params.makeOutcome(TARGET_ENTITY); - outcome2.setResult(PolicyResult.SUCCESS); + outcome2.setResult(OperationResult.SUCCESS); cqFuture.complete(outcome2); } } diff --git a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java index 047378baf..60d3ddd31 100644 --- a/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java +++ b/models-interactions/model-actors/actor.test/src/test/java/org/onap/policy/controlloop/actor/test/BasicOperationTest.java @@ -34,9 +34,9 @@ import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial; -import org.onap.policy.controlloop.policy.PolicyResult; public class BasicOperationTest { private static final String ACTOR = "my-actor"; @@ -75,7 +75,7 @@ public class BasicOperationTest { CompletableFuture<OperationOutcome> future = oper.service.getActor(OperationPartial.GUARD_ACTOR_NAME) .getOperator(OperationPartial.GUARD_OPERATION_NAME).buildOperation(null).start(); assertTrue(future.isDone()); - assertEquals(PolicyResult.SUCCESS, future.get().getResult()); + assertEquals(OperationResult.SUCCESS, future.get().getResult()); } @Test @@ -116,6 +116,6 @@ public class BasicOperationTest { assertSame(cq, oper.context.getProperty(AaiCqResponse.CONTEXT_KEY)); assertTrue(oper.cqFuture.isDone()); - assertEquals(PolicyResult.SUCCESS, oper.cqFuture.get().getResult()); + assertEquals(OperationResult.SUCCESS, oper.cqFuture.get().getResult()); } } diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java index bb23fdcc5..0a1136d2f 100644 --- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java +++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java @@ -26,10 +26,10 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.vfc.VfcHealActionVmInfo; import org.onap.policy.vfc.VfcHealAdditionalParams; import org.onap.policy.vfc.VfcHealRequest; @@ -151,13 +151,13 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> { * Prepends the message with the http status code. */ @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse, + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, Response rawResponse, VfcResponse response) { // set default result and message setOutcome(outcome, result); - int code = (result == PolicyResult.FAILURE_TIMEOUT ? VFC_RESPONSE_CODE : rawResponse.getStatus()); + int code = (result == OperationResult.FAILURE_TIMEOUT ? VFC_RESPONSE_CODE : rawResponse.getStatus()); outcome.setResponse(response); outcome.setMessage(code + " " + outcome.getMessage()); diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java index 068ffdaab..9a4677d79 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java @@ -36,9 +36,9 @@ import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.vfc.VfcRequest; import org.onap.policy.vfc.VfcResponse; @@ -87,7 +87,7 @@ public class RestartTest extends BasicVfcOperation { restartOper = new Restart(params, config); outcome = restartOper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof VfcResponse); } @@ -113,7 +113,7 @@ public class RestartTest extends BasicVfcOperation { // run the operation outcome = restartOper.start().get(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof VfcResponse); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java new file mode 100644 index 000000000..67d25f2a9 --- /dev/null +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationFinalResult.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * models + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +public enum OperationFinalResult { + /** + * The Control Loop Policy successfully completed its Operations. + */ + FINAL_SUCCESS("Final_Success"), + /** + * The Control Loop Policy was an Open Loop and is finished. + */ + FINAL_OPENLOOP("Final_OpenLoop"), + /** + * The Control Loop Policy failed in its last Operation Policy. NOTE: Previous Operation Policies may have been + * successful. + */ + FINAL_FAILURE("Final_Failure"), + /** + * The Control Loop Policy failed because the overall timeout was met. + */ + FINAL_FAILURE_TIMEOUT("Final_Failure_Timeout"), + /** + * The Control Loop Policy failed because an Operation Policy met its retry limit. + */ + FINAL_FAILURE_RETRIES("Final_Failure_Retries"), + /** + * The Control Loop Policy failed due to an exception. + */ + FINAL_FAILURE_EXCEPTION("Final_Failure_Exception"), + /** + * The Control Loop Policy failed due to guard denied. + */ + FINAL_FAILURE_GUARD("Final_Failure_Guard"); + + String result; + + private OperationFinalResult(String result) { + this.result = result; + } + + /** + * Converts to a result object. + * + * @param result input string + * @return result object + */ + public static OperationFinalResult toResult(String result) { + if (result.equalsIgnoreCase(FINAL_SUCCESS.toString())) { + return FINAL_SUCCESS; + } + if (result.equalsIgnoreCase(FINAL_OPENLOOP.toString())) { + return FINAL_OPENLOOP; + } + if (result.equalsIgnoreCase(FINAL_FAILURE.toString())) { + return FINAL_FAILURE; + } + if (result.equalsIgnoreCase(FINAL_FAILURE_TIMEOUT.toString())) { + return FINAL_FAILURE_TIMEOUT; + } + if (result.equalsIgnoreCase(FINAL_FAILURE_RETRIES.toString())) { + return FINAL_FAILURE_RETRIES; + } + if (result.equalsIgnoreCase(FINAL_FAILURE_EXCEPTION.toString())) { + return FINAL_FAILURE_EXCEPTION; + } + if (result.equalsIgnoreCase(FINAL_FAILURE_GUARD.toString())) { + return FINAL_FAILURE_GUARD; + } + return null; + } + + /** + * Check if the result really is a result. + * + * @param result string + * @param finalResult result object + * @return true if a result + */ + public static boolean isResult(String result, OperationFinalResult finalResult) { + OperationFinalResult toResult = OperationFinalResult.toResult(result); + if (toResult == null) { + return false; + } + return toResult.equals(finalResult); + } + +} diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java index 0c4350c63..2d6a61249 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcome.java @@ -25,7 +25,6 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.policy.PolicyResult; /** * Outcome from an operation. Objects of this type are passed from one stage to the next. @@ -39,7 +38,7 @@ public class OperationOutcome { private Instant start; private Instant end; private String subRequestId; - private PolicyResult result = PolicyResult.SUCCESS; + private OperationResult result = OperationResult.SUCCESS; private String message; private boolean finalOutcome; private Object response; @@ -119,7 +118,7 @@ public class OperationOutcome { * * @param result new result */ - public void setResult(@NonNull PolicyResult result) { + public void setResult(@NonNull OperationResult result) { this.result = result; } } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationResult.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationResult.java new file mode 100644 index 000000000..4577617a2 --- /dev/null +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationResult.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +public enum OperationResult { + /** + * Operation was successful. + */ + SUCCESS("Success"), + /** + * Operation failed. + */ + FAILURE("Failure"), + /** + * Operation failed due to maximum retries being met. + */ + FAILURE_RETRIES("Failure_Retries"), + /** + * Operation failed due to timeout occurring. + */ + FAILURE_TIMEOUT("Failure_Timeout"), + /** + * Operation failed due to an exception. + */ + FAILURE_EXCEPTION("Failure_Exception"), + /** + * Operation failed since Guard did not permit. + */ + FAILURE_GUARD("Failure_Guard") + ; + + + private String result; + private OperationResult(String result) { + this.result = result; + } + + @Override + public String toString() { + return this.result; + } + + /** + * Convert to a result. + * + * @param result result string + * @return Result object + */ + public static OperationResult toResult(String result) { + if (result.equalsIgnoreCase(SUCCESS.toString())) { + return SUCCESS; + } + if (result.equalsIgnoreCase(FAILURE.toString())) { + return FAILURE; + } + if (result.equalsIgnoreCase(FAILURE_RETRIES.toString())) { + return FAILURE_RETRIES; + } + if (result.equalsIgnoreCase(FAILURE_TIMEOUT.toString())) { + return FAILURE_TIMEOUT; + } + if (result.equalsIgnoreCase(FAILURE_EXCEPTION.toString())) { + return FAILURE_EXCEPTION; + } + if (result.equalsIgnoreCase(FAILURE_GUARD.toString())) { + return FAILURE_GUARD; + } + return null; + } +} diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/TargetType.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/TargetType.java new file mode 100644 index 000000000..605445c57 --- /dev/null +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/TargetType.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +public enum TargetType { + VM("VM"), PNF("PNF"), VFC("VFC"), VNF("VNF"), VFMODULE("VFMODULE"); + + private String target; + + private TargetType(String targetType) { + this.target = targetType; + } + + @Override + public String toString() { + return this.target; + } + + /** + * Converts a string to TargetType object if it matches. + * + * @param targetType String + * @return TargetType object + */ + public static TargetType toTargetType(String targetType) { + if (targetType == null) { + return null; + } + if (targetType.equalsIgnoreCase(VM.toString())) { + return VM; + } + if (targetType.equalsIgnoreCase(PNF.toString())) { + return PNF; + } + if (targetType.equalsIgnoreCase(VFC.toString())) { + return VFC; + } + if (targetType.equalsIgnoreCase(VNF.toString())) { + return VNF; + } + if (targetType.equalsIgnoreCase(VFMODULE.toString())) { + return VFMODULE; + } + + return null; + } +} diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java index a3f3a6905..e02e59239 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java @@ -29,12 +29,12 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture; import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler; import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder; -import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -215,14 +215,14 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial case SUCCESS: logger.info("{}.{} request succeeded for {}", params.getActor(), params.getOperation(), params.getRequestId()); - setOutcome(outcome, PolicyResult.SUCCESS, response); + setOutcome(outcome, OperationResult.SUCCESS, response); postProcessResponse(outcome, rawResponse, response); return outcome; case FAILURE: logger.info("{}.{} request failed for {}", params.getActor(), params.getOperation(), params.getRequestId()); - return setOutcome(outcome, PolicyResult.FAILURE, response); + return setOutcome(outcome, OperationResult.FAILURE, response); case STILL_WAITING: default: @@ -240,7 +240,7 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial * @param response response used to populate the outcome * @return the updated operation */ - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, S response) { + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, S response) { outcome.setResponse(response); return setOutcome(outcome, result); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java index 09c876d41..c75ca1d4f 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java @@ -37,12 +37,12 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil; import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture; -import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -243,11 +243,12 @@ public abstract class HttpOperation<T> extends OperationPartial { if (!isSuccess(rawResponse, response)) { logger.info("{}.{} request failed with http error code {} for {}", params.getActor(), params.getOperation(), rawResponse.getStatus(), params.getRequestId()); - return CompletableFuture.completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response)); + return CompletableFuture.completedFuture( + setOutcome(outcome, OperationResult.FAILURE, rawResponse, response)); } logger.info("{}.{} request succeeded for {}", params.getActor(), params.getOperation(), params.getRequestId()); - setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response); + setOutcome(outcome, OperationResult.SUCCESS, rawResponse, response); return postProcessResponse(outcome, url, rawResponse, response); } @@ -260,7 +261,7 @@ public abstract class HttpOperation<T> extends OperationPartial { * @param response decoded response * @return the updated operation */ - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse, + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, Response rawResponse, T response) { outcome.setResponse(response); @@ -292,13 +293,13 @@ public abstract class HttpOperation<T> extends OperationPartial { logger.info("{}.{} request succeeded for {}", params.getActor(), params.getOperation(), params.getRequestId()); return CompletableFuture - .completedFuture(setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response)); + .completedFuture(setOutcome(outcome, OperationResult.SUCCESS, rawResponse, response)); case FAILURE: logger.info("{}.{} request failed for {}", params.getActor(), params.getOperation(), params.getRequestId()); return CompletableFuture - .completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response)); + .completedFuture(setOutcome(outcome, OperationResult.FAILURE, rawResponse, response)); case STILL_WAITING: default: @@ -313,7 +314,7 @@ public abstract class HttpOperation<T> extends OperationPartial { if (pollCount++ >= cfg.getMaxPolls()) { logger.warn("{}: execeeded 'poll' limit {} for {}", getFullName(), cfg.getMaxPolls(), params.getRequestId()); - setOutcome(outcome, PolicyResult.FAILURE_TIMEOUT); + setOutcome(outcome, OperationResult.FAILURE_TIMEOUT); return CompletableFuture.completedFuture(outcome); } 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 b5cc15e19..c81575f62 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 @@ -54,10 +54,10 @@ import org.onap.policy.controlloop.actorserviceprovider.CallbackManager; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.OperatorConfig; import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture; -import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -132,10 +132,12 @@ public abstract class OperationPartial implements Operation { return config.getBlockingExecutor(); } + @Override public String getActorName() { return params.getActor(); } + @Override public String getName() { return params.getOperation(); } @@ -221,7 +223,7 @@ public abstract class OperationPartial implements Operation { // TODO need a FAILURE_MISSING_DATA (e.g., A&AI) outcome2.setFinalOutcome(true); - outcome2.setResult(PolicyResult.FAILURE_GUARD); + outcome2.setResult(OperationResult.FAILURE_GUARD); outcome2.setMessage(outcome != null ? outcome.getMessage() : null); // @formatter:off @@ -392,7 +394,7 @@ public abstract class OperationPartial implements Operation { * @return {@code true} if the outcome was successful */ protected boolean isSuccess(OperationOutcome outcome) { - return (outcome != null && outcome.getResult() == PolicyResult.SUCCESS); + return (outcome != null && outcome.getResult() == OperationResult.SUCCESS); } /** @@ -403,7 +405,7 @@ public abstract class OperationPartial implements Operation { * <i>and</i> was associated with this operator, {@code false} otherwise */ protected boolean isActorFailed(OperationOutcome outcome) { - return (isSameOperation(outcome) && outcome.getResult() == PolicyResult.FAILURE); + return (isSameOperation(outcome) && outcome.getResult() == OperationResult.FAILURE); } /** @@ -475,7 +477,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()), PolicyResult.FAILURE); + outcome = this.setOutcome(params.makeOutcome(getTargetEntity()), OperationResult.FAILURE); } // ensure correct actor/operation @@ -483,7 +485,7 @@ public abstract class OperationPartial implements Operation { outcome.setOperation(getName()); // determine if we should retry, based on the result - if (outcome.getResult() != PolicyResult.FAILURE) { + if (outcome.getResult() != OperationResult.FAILURE) { // do not retry success or other failure types (e.g., exception) outcome.setFinalOutcome(true); return outcome; @@ -504,7 +506,7 @@ public abstract class OperationPartial implements Operation { * FAILURE_RETRIES */ logger.info("operation {} retries exhausted for {}", getFullName(), params.getRequestId()); - outcome.setResult(PolicyResult.FAILURE_RETRIES); + outcome.setResult(OperationResult.FAILURE_RETRIES); outcome.setFinalOutcome(true); } @@ -989,7 +991,8 @@ public abstract class OperationPartial implements Operation { * @return the updated operation */ public OperationOutcome setOutcome(OperationOutcome operation, Throwable thrown) { - PolicyResult result = (isTimeout(thrown) ? PolicyResult.FAILURE_TIMEOUT : PolicyResult.FAILURE_EXCEPTION); + OperationResult result = (isTimeout(thrown) ? OperationResult.FAILURE_TIMEOUT + : OperationResult.FAILURE_EXCEPTION); return setOutcome(operation, result); } @@ -1000,10 +1003,10 @@ public abstract class OperationPartial implements Operation { * @param result result of the operation * @return the updated operation */ - public OperationOutcome setOutcome(OperationOutcome operation, PolicyResult result) { + public OperationOutcome setOutcome(OperationOutcome operation, OperationResult result) { logger.trace("{}: set outcome {} for {}", getFullName(), result, params.getRequestId()); operation.setResult(result); - operation.setMessage(result == PolicyResult.SUCCESS ? ControlLoopOperation.SUCCESS_MSG + operation.setMessage(result == OperationResult.SUCCESS ? ControlLoopOperation.SUCCESS_MSG : ControlLoopOperation.FAILED_MSG); return operation; 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 66573f38a..0e4f09b66 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 @@ -37,9 +37,9 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.TargetType; import org.onap.policy.controlloop.actorserviceprovider.Util; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; -import org.onap.policy.controlloop.policy.Target; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,6 +54,13 @@ import org.slf4j.LoggerFactory; public class ControlLoopOperationParams { private static final Logger logger = LoggerFactory.getLogger(ControlLoopOperationParams.class); + public static final String PARAMS_ENTITY_RESOURCEID = "resourceID"; + public static final String PARAMS_ENTITY_MODEL_INVARIANT_ID = "modelInvariantId"; + public static final String PARAMS_ENTITY_MODEL_VERSION_ID = "modelVersionId"; + public static final String PARAMS_ENTITY_MODEL_NAME = "modelName"; + public static final String PARAMS_ENTITY_MODEL_VERSION = "modelVersion"; + public static final String PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID = "modelCustomizationId"; + /** * Actor name. */ @@ -107,10 +114,16 @@ public class ControlLoopOperationParams { private Integer retry; /** - * The Target information, extracted from the Policy. May be {@code null}, depending + * The Target Type information, extracted from the Policy. May be {@code null}, depending * on the requirement of the operation to be invoked. */ - private Target target; + private TargetType targetType; + + /** + * Target entitiy ids, extracted from the Policy. May be (@code null}, depending on + * the requirement of the operation to be invoked. + */ + private Map<String, String> targetEntityIds; /** * Target entity. diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java index 5820becc5..605a7330c 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/OperationOutcomeTest.java @@ -30,7 +30,6 @@ import java.time.Instant; import org.junit.Before; import org.junit.Test; import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.policy.PolicyResult; public class OperationOutcomeTest { private static final String ACTOR = "my-actor"; @@ -39,7 +38,7 @@ public class OperationOutcomeTest { private static final Instant START = Instant.ofEpochMilli(10); private static final Instant END = Instant.ofEpochMilli(20); private static final String SUB_REQ_ID = "my-sub-request-id"; - private static final PolicyResult RESULT = PolicyResult.FAILURE_GUARD; + private static final OperationResult RESULT = OperationResult.FAILURE_GUARD; private static final String MESSAGE = "my-message"; private static final String RESPONSE = "my-response"; @@ -124,8 +123,8 @@ public class OperationOutcomeTest { @Test public void testSetResult() { - outcome.setResult(PolicyResult.FAILURE_EXCEPTION); - assertEquals(PolicyResult.FAILURE_EXCEPTION, outcome.getResult()); + outcome.setResult(OperationResult.FAILURE_EXCEPTION); + assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult()); assertThatThrownBy(() -> outcome.setResult(null)); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java index f63e07e57..14b1daf49 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java @@ -55,11 +55,11 @@ import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.common.utils.time.PseudoExecutor; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler; import org.onap.policy.controlloop.actorserviceprovider.topic.Forwarder; -import org.onap.policy.controlloop.policy.PolicyResult; public class BidirectionalTopicOperationTest { private static final CommInfrastructure SINK_INFRA = CommInfrastructure.NOOP; @@ -163,7 +163,7 @@ public class BidirectionalTopicOperationTest { assertTrue(future.isDone()); assertSame(outcome, future.get()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(response, outcome.getResponse()); verify(forwarder).unregister(eq(Arrays.asList(REQ_ID)), eq(listenerCaptor.getValue())); @@ -263,7 +263,7 @@ public class BidirectionalTopicOperationTest { MyStringOperation oper2 = new MyStringOperation(); assertSame(outcome, oper2.processResponse(outcome, TEXT, null)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(TEXT, outcome.getResponse()); } @@ -276,7 +276,7 @@ public class BidirectionalTopicOperationTest { MyScoOperation oper2 = new MyScoOperation(); assertSame(outcome, oper2.processResponse(outcome, responseText, stdResponse)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(stdResponse, outcome.getResponse()); } @@ -293,7 +293,7 @@ public class BidirectionalTopicOperationTest { stdResponse = coder.decode(responseText, StandardCoderObject.class); assertSame(outcome, oper.processResponse(outcome, responseText, stdResponse)); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertEquals(resp, outcome.getResponse()); } @@ -303,7 +303,7 @@ public class BidirectionalTopicOperationTest { @Test public void testProcessResponseDecodeOk() throws CoderException { assertSame(outcome, oper.processResponse(outcome, responseText, stdResponse)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(response, outcome.getResponse()); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java index daabaa237..453592d2b 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java @@ -79,11 +79,11 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; -import org.onap.policy.controlloop.policy.PolicyResult; public class HttpOperationTest { @@ -257,7 +257,7 @@ public class HttpOperationTest { assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); assertSame(TEXT, outcome.getResponse()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); } /** @@ -289,7 +289,7 @@ public class HttpOperationTest { CompletableFuture<OperationOutcome> result = oper.processResponse(outcome, PATH, response); assertTrue(result.isDone()); assertSame(outcome, result.get()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertSame(TEXT, outcome.getResponse()); } @@ -302,7 +302,7 @@ public class HttpOperationTest { CompletableFuture<OperationOutcome> result = oper.processResponse(outcome, PATH, response); assertTrue(result.isDone()); assertSame(outcome, result.get()); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertSame(TEXT, outcome.getResponse()); } @@ -318,7 +318,7 @@ public class HttpOperationTest { CompletableFuture<OperationOutcome> result = oper2.processResponse(outcome, PATH, response); assertTrue(result.isDone()); assertSame(outcome, result.get()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(Integer.valueOf(10), outcome.getResponse()); } @@ -359,7 +359,7 @@ public class HttpOperationTest { OperationOutcome outcome = runOperation(oper2); assertNotNull(outcome); assertEquals(1, nget); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof MyResponse); } @@ -376,7 +376,7 @@ public class HttpOperationTest { OperationOutcome outcome = runOperation(oper2); assertNotNull(outcome); assertEquals(1, ndelete); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof String); } @@ -392,7 +392,7 @@ public class HttpOperationTest { OperationOutcome outcome = runOperation(oper2); assertNotNull(outcome); assertEquals(1, npost); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof MyResponse); } @@ -409,7 +409,7 @@ public class HttpOperationTest { OperationOutcome outcome = runOperation(oper2); assertNotNull(outcome); assertEquals(1, nput); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.getResponse() instanceof MyResponse); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java index ede2b7966..845758a48 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java @@ -44,10 +44,10 @@ import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; -import org.onap.policy.controlloop.policy.PolicyResult; /** * Tests HttpOperation when polling is enabled. @@ -134,7 +134,7 @@ public class HttpPollingOperationTest { oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertTrue(future2.isDone()); assertSame(outcome, future2.get()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertNotNull(oper.getSubRequestId()); assertSame(response, outcome.getResponse()); @@ -144,7 +144,7 @@ public class HttpPollingOperationTest { future2 = oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertTrue(future2.isDone()); assertSame(outcome, future2.get()); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertNotNull(oper.getSubRequestId()); assertSame(response, outcome.getResponse()); } @@ -175,7 +175,7 @@ public class HttpPollingOperationTest { oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(2, oper.getPollCount()); /* @@ -186,7 +186,7 @@ public class HttpPollingOperationTest { future2 = oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response); assertSame(outcome, future2.get(5, TimeUnit.SECONDS)); - assertEquals(PolicyResult.FAILURE_TIMEOUT, outcome.getResult()); + assertEquals(OperationResult.FAILURE_TIMEOUT, outcome.getResult()); assertEquals(MAX_POLLS + 1, oper.getPollCount()); oper.resetPollCount(); 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 6db824f98..455393c93 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 @@ -76,12 +76,12 @@ import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.Operator; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.OperatorConfig; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.LoggerFactory; public class OperationPartialTest { @@ -99,8 +99,8 @@ public class OperationPartialTest { private static final int TIMEOUT = 1000; private static final UUID REQ_ID = UUID.randomUUID(); - private static final List<PolicyResult> FAILURE_RESULTS = Arrays.asList(PolicyResult.values()).stream() - .filter(result -> result != PolicyResult.SUCCESS).collect(Collectors.toList()); + private static final List<OperationResult> FAILURE_RESULTS = Arrays.asList(OperationResult.values()).stream() + .filter(result -> result != OperationResult.SUCCESS).collect(Collectors.toList()); /** * Used to attach an appender to the class' logger. @@ -238,7 +238,7 @@ public class OperationPartialTest { @Test public void testStart() { - verifyRun("testStart", 1, 1, PolicyResult.SUCCESS); + verifyRun("testStart", 1, 1, OperationResult.SUCCESS); } /** @@ -254,7 +254,7 @@ public class OperationPartialTest { assertNotNull(opstart); assertNotNull(opend); - assertEquals(PolicyResult.SUCCESS, opend.getResult()); + assertEquals(OperationResult.SUCCESS, opend.getResult()); assertEquals(MAX_PARALLEL, numStart); assertEquals(MAX_PARALLEL, oper.getCount()); @@ -268,7 +268,7 @@ public class OperationPartialTest { public void testStartPreprocessorFailure() { oper.setPreProc(CompletableFuture.completedFuture(makeFailure())); - verifyRun("testStartPreprocessorFailure", 1, 0, PolicyResult.FAILURE_GUARD); + verifyRun("testStartPreprocessorFailure", 1, 0, OperationResult.FAILURE_GUARD); } /** @@ -279,7 +279,7 @@ public class OperationPartialTest { // arrange for the preprocessor to throw an exception oper.setPreProc(CompletableFuture.failedFuture(new IllegalStateException(EXPECTED_EXCEPTION))); - verifyRun("testStartPreprocessorException", 1, 0, PolicyResult.FAILURE_GUARD); + verifyRun("testStartPreprocessorException", 1, 0, OperationResult.FAILURE_GUARD); } /** @@ -328,7 +328,7 @@ public class OperationPartialTest { public void testStartGuardAsync() throws Exception { CompletableFuture<OperationOutcome> future = oper.startGuardAsync(); assertTrue(future.isDone()); - assertEquals(PolicyResult.SUCCESS, future.get().getResult()); + assertEquals(OperationResult.SUCCESS, future.get().getResult()); // verify the parameters that were passed ArgumentCaptor<ControlLoopOperationParams> paramsCaptor = @@ -387,10 +387,10 @@ public class OperationPartialTest { OperationOutcome outcome = new OperationOutcome(); - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); assertTrue(oper.isSuccess(outcome)); - for (PolicyResult failure : FAILURE_RESULTS) { + for (OperationResult failure : FAILURE_RESULTS) { outcome.setResult(failure); assertFalse("testIsSuccess-" + failure, oper.isSuccess(outcome)); } @@ -403,14 +403,14 @@ public class OperationPartialTest { OperationOutcome outcome = params.makeOutcome(null); // incorrect outcome - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); assertFalse(oper.isActorFailed(outcome)); - outcome.setResult(PolicyResult.FAILURE_RETRIES); + outcome.setResult(OperationResult.FAILURE_RETRIES); assertFalse(oper.isActorFailed(outcome)); // correct outcome - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); // incorrect actor outcome.setActor(MY_SINK); @@ -441,7 +441,7 @@ public class OperationPartialTest { assertTrue(executor.runAll(MAX_REQUESTS)); assertNotNull(opend); - assertEquals(PolicyResult.FAILURE_EXCEPTION, opend.getResult()); + assertEquals(OperationResult.FAILURE_EXCEPTION, opend.getResult()); } @Test @@ -461,7 +461,7 @@ public class OperationPartialTest { protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) { OperationOutcome outcome2 = params.makeOutcome(null); - outcome2.setResult(PolicyResult.SUCCESS); + outcome2.setResult(OperationResult.SUCCESS); /* * Create an incomplete future that will timeout after the operation's @@ -476,7 +476,7 @@ public class OperationPartialTest { } }; - assertEquals(PolicyResult.FAILURE_TIMEOUT, oper.start().get().getResult()); + assertEquals(OperationResult.FAILURE_TIMEOUT, oper.start().get().getResult()); } /** @@ -491,7 +491,7 @@ public class OperationPartialTest { oper.setMaxFailures(10); - verifyRun("testSetRetryFlag_testRetryOnFailure_ZeroRetries", 1, 1, PolicyResult.FAILURE); + verifyRun("testSetRetryFlag_testRetryOnFailure_ZeroRetries", 1, 1, OperationResult.FAILURE); } /** @@ -506,7 +506,7 @@ public class OperationPartialTest { oper.setMaxFailures(10); - verifyRun("testSetRetryFlag_testRetryOnFailure_NullRetries", 1, 1, PolicyResult.FAILURE); + verifyRun("testSetRetryFlag_testRetryOnFailure_NullRetries", 1, 1, OperationResult.FAILURE); } /** @@ -523,7 +523,7 @@ public class OperationPartialTest { oper.setMaxFailures(10); verifyRun("testSetRetryFlag_testRetryOnFailure_RetriesExhausted", maxRetries + 1, maxRetries + 1, - PolicyResult.FAILURE_RETRIES); + OperationResult.FAILURE_RETRIES); } /** @@ -540,7 +540,7 @@ public class OperationPartialTest { oper.setMaxFailures(maxFailures); verifyRun("testSetRetryFlag_testRetryOnFailure_SuccessAfterRetries", maxFailures + 1, maxFailures + 1, - PolicyResult.SUCCESS); + OperationResult.SUCCESS); } /** @@ -560,7 +560,7 @@ public class OperationPartialTest { } }; - verifyRun("testSetRetryFlag_testRetryOnFailure_NullOutcome", 1, 1, PolicyResult.FAILURE, noop()); + verifyRun("testSetRetryFlag_testRetryOnFailure_NullOutcome", 1, 1, OperationResult.FAILURE, noop()); } @Test @@ -622,7 +622,7 @@ public class OperationPartialTest { @Test public void testHandlePreprocessorFailureSuccess() { oper.setPreProc(CompletableFuture.completedFuture(makeSuccess())); - verifyRun("testHandlePreprocessorFailureTrue", 1, 1, PolicyResult.SUCCESS); + verifyRun("testHandlePreprocessorFailureTrue", 1, 1, OperationResult.SUCCESS); } /** @@ -631,7 +631,7 @@ public class OperationPartialTest { @Test public void testHandlePreprocessorFailureFailed() throws Exception { oper.setPreProc(CompletableFuture.completedFuture(makeFailure())); - verifyRun("testHandlePreprocessorFailureFalse", 1, 0, PolicyResult.FAILURE_GUARD); + verifyRun("testHandlePreprocessorFailureFalse", 1, 0, OperationResult.FAILURE_GUARD); } /** @@ -641,7 +641,7 @@ public class OperationPartialTest { public void testHandlePreprocessorFailureNull() throws Exception { // arrange to return a null outcome from the preprocessor oper.setPreProc(CompletableFuture.completedFuture(null)); - verifyRun("testHandlePreprocessorFailureNull", 1, 0, PolicyResult.FAILURE_GUARD); + verifyRun("testHandlePreprocessorFailureNull", 1, 0, OperationResult.FAILURE_GUARD); } @Test @@ -649,7 +649,7 @@ public class OperationPartialTest { // arrange to generate an exception when operation runs oper.setGenException(true); - verifyRun("testFromException", 1, 1, PolicyResult.FAILURE_EXCEPTION); + verifyRun("testFromException", 1, 1, OperationResult.FAILURE_EXCEPTION); } /** @@ -657,7 +657,7 @@ public class OperationPartialTest { */ @Test public void testFromExceptionNoExcept() { - verifyRun("testFromExceptionNoExcept", 1, 1, PolicyResult.SUCCESS); + verifyRun("testFromExceptionNoExcept", 1, 1, OperationResult.SUCCESS); } /** @@ -843,13 +843,13 @@ public class OperationPartialTest { @Test public void testCombineOutcomes() throws Exception { // only one outcome - verifyOutcomes(0, PolicyResult.SUCCESS); - verifyOutcomes(0, PolicyResult.FAILURE_EXCEPTION); + verifyOutcomes(0, OperationResult.SUCCESS); + verifyOutcomes(0, OperationResult.FAILURE_EXCEPTION); // maximum is in different positions - verifyOutcomes(0, PolicyResult.FAILURE, PolicyResult.SUCCESS, PolicyResult.FAILURE_GUARD); - verifyOutcomes(1, PolicyResult.SUCCESS, PolicyResult.FAILURE, PolicyResult.FAILURE_GUARD); - verifyOutcomes(2, PolicyResult.SUCCESS, PolicyResult.FAILURE_GUARD, PolicyResult.FAILURE); + verifyOutcomes(0, OperationResult.FAILURE, OperationResult.SUCCESS, OperationResult.FAILURE_GUARD); + verifyOutcomes(1, OperationResult.SUCCESS, OperationResult.FAILURE, OperationResult.FAILURE_GUARD); + verifyOutcomes(2, OperationResult.SUCCESS, OperationResult.FAILURE_GUARD, OperationResult.FAILURE); // null outcome - takes precedence over a success List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>(); @@ -904,7 +904,7 @@ public class OperationPartialTest { // second task fails, third should not run OperationOutcome failure = params.makeOutcome(null); - failure.setResult(PolicyResult.FAILURE); + failure.setResult(OperationResult.FAILURE); tasks.clear(); tasks.add(() -> CompletableFuture.completedFuture(outcome)); tasks.add(() -> CompletableFuture.completedFuture(failure)); @@ -936,7 +936,7 @@ public class OperationPartialTest { assertSame(future1, oper.sequence(() -> future1)); } - private void verifyOutcomes(int expected, PolicyResult... results) throws Exception { + private void verifyOutcomes(int expected, OperationResult... results) throws Exception { List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>(); OperationOutcome expectedOutcome = null; @@ -964,11 +964,11 @@ public class OperationPartialTest { OperationOutcome outcome = params.makeOutcome(null); - Map<PolicyResult, Integer> map = Map.of(PolicyResult.SUCCESS, 0, PolicyResult.FAILURE_GUARD, 2, - PolicyResult.FAILURE_RETRIES, 3, PolicyResult.FAILURE, 4, PolicyResult.FAILURE_TIMEOUT, 5, - PolicyResult.FAILURE_EXCEPTION, 6); + Map<OperationResult, Integer> map = Map.of(OperationResult.SUCCESS, 0, OperationResult.FAILURE_GUARD, 2, + OperationResult.FAILURE_RETRIES, 3, OperationResult.FAILURE, 4, OperationResult.FAILURE_TIMEOUT, 5, + OperationResult.FAILURE_EXCEPTION, 6); - for (Entry<PolicyResult, Integer> ent : map.entrySet()) { + for (Entry<OperationResult, Integer> ent : map.entrySet()) { outcome.setResult(ent.getKey()); assertEquals(ent.getKey().toString(), ent.getValue().intValue(), oper.detmPriority(outcome)); } @@ -1039,12 +1039,12 @@ public class OperationPartialTest { outcome = new OperationOutcome(); oper.setOutcome(outcome, timex); assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage()); - assertEquals(PolicyResult.FAILURE_TIMEOUT, outcome.getResult()); + assertEquals(OperationResult.FAILURE_TIMEOUT, outcome.getResult()); outcome = new OperationOutcome(); oper.setOutcome(outcome, new IllegalStateException(EXPECTED_EXCEPTION)); assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage()); - assertEquals(PolicyResult.FAILURE_EXCEPTION, outcome.getResult()); + assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult()); } @Test @@ -1052,15 +1052,15 @@ public class OperationPartialTest { OperationOutcome outcome; outcome = new OperationOutcome(); - oper.setOutcome(outcome, PolicyResult.SUCCESS); + oper.setOutcome(outcome, OperationResult.SUCCESS); assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); - oper.setOutcome(outcome, PolicyResult.SUCCESS); + oper.setOutcome(outcome, OperationResult.SUCCESS); assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); - for (PolicyResult result : FAILURE_RESULTS) { + for (OperationResult result : FAILURE_RESULTS) { outcome = new OperationOutcome(); oper.setOutcome(outcome, result); assertEquals(result.toString(), ControlLoopOperation.FAILED_MSG, outcome.getMessage()); @@ -1199,14 +1199,14 @@ public class OperationPartialTest { private OperationOutcome makeSuccess() { OperationOutcome outcome = params.makeOutcome(null); - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); return outcome; } private OperationOutcome makeFailure() { OperationOutcome outcome = params.makeOutcome(null); - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); return outcome; } @@ -1220,7 +1220,7 @@ public class OperationPartialTest { * @param expectedResult expected outcome */ private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, - PolicyResult expectedResult) { + OperationResult expectedResult) { verifyRun(testName, expectedCallbacks, expectedOperations, expectedResult, noop()); } @@ -1236,8 +1236,8 @@ public class OperationPartialTest { * {@link OperationPartial#start(ControlLoopOperationParams)} before the tasks * in the executor are run */ - private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, PolicyResult expectedResult, - Consumer<CompletableFuture<OperationOutcome>> manipulator) { + private void verifyRun(String testName, int expectedCallbacks, int expectedOperations, + OperationResult expectedResult, Consumer<CompletableFuture<OperationOutcome>> manipulator) { tstart = null; opstart = null; @@ -1342,9 +1342,9 @@ public class OperationPartialTest { operation.setSubRequestId(String.valueOf(attempt)); if (count > maxFailures) { - operation.setResult(PolicyResult.SUCCESS); + operation.setResult(OperationResult.SUCCESS); } else { - operation.setResult(PolicyResult.FAILURE); + operation.setResult(OperationResult.FAILURE); } return operation; 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 5e79247ed..caa840891 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 @@ -57,7 +57,6 @@ import org.onap.policy.controlloop.actorserviceprovider.Operator; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams.ControlLoopOperationParamsBuilder; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Target; public class ControlLoopOperationParamsTest { private static final String NULL_MSG = "null"; @@ -65,7 +64,6 @@ public class ControlLoopOperationParamsTest { private static final String EXPECTED_EXCEPTION = "expected exception"; private static final String ACTOR = "my-actor"; private static final String OPERATION = "my-operation"; - private static final Target TARGET = new Target(); private static final String TARGET_ENTITY = "my-target"; private static final Integer RETRY = 3; private static final Integer TIMEOUT = 100; @@ -128,7 +126,7 @@ public class ControlLoopOperationParamsTest { params = ControlLoopOperationParams.builder().actorService(actorService).completeCallback(completer) .context(context).executor(executor).actor(ACTOR).operation(OPERATION).payload(payload) - .retry(RETRY).target(TARGET).targetEntity(TARGET_ENTITY).timeoutSec(TIMEOUT) + .retry(RETRY).targetEntity(TARGET_ENTITY).timeoutSec(TIMEOUT) .startCallback(starter).preprocessed(true).build(); outcome = params.makeOutcome(TARGET_ENTITY); @@ -257,7 +255,7 @@ public class ControlLoopOperationParamsTest { assertTrue(params.toBuilder().build().validate().isValid()); // these can be null - assertTrue(params.toBuilder().payload(null).retry(null).target(null).timeoutSec(null).startCallback(null) + assertTrue(params.toBuilder().payload(null).retry(null).timeoutSec(null).startCallback(null) .completeCallback(null).build().validate().isValid()); // test with minimal fields @@ -356,14 +354,6 @@ public class ControlLoopOperationParamsTest { } @Test - public void testTarget() { - assertSame(TARGET, params.getTarget()); - - // should be null when unspecified - assertNull(ControlLoopOperationParams.builder().build().getTarget()); - } - - @Test public void testGetTimeoutSec() { assertSame(TIMEOUT, params.getTimeoutSec()); diff --git a/models-interactions/model-actors/pom.xml b/models-interactions/model-actors/pom.xml index ec8f4e0f5..1b6398ce2 100644 --- a/models-interactions/model-actors/pom.xml +++ b/models-interactions/model-actors/pom.xml @@ -52,10 +52,5 @@ <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> - <dependency> - <groupId>org.onap.policy.models.policy-models-interactions</groupId> - <artifactId>model-yaml</artifactId> - <version>${project.version}</version> - </dependency> </dependencies> </project> |