diff options
author | Jim Hahn <jrh3@att.com> | 2020-08-26 16:57:52 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2020-08-27 14:29:28 -0400 |
commit | 3052f10337897ea25983f35f4158c5626febbe7d (patch) | |
tree | 19da96c57189c04f1b6dd8cf17702b7ff36f367f /controlloop/common | |
parent | 14c9b3e48963d9283d77d140bcbe1ee4d4d24200 (diff) |
Use ToscaPolicy instead of legacy Policy
Removed usage of policy-yaml and old targetType definition.
Switched to using TOSCA operational policy classes and new
definitions for Target type enum.
Issue-ID: POLICY-2428
Change-Id: I25d1c5219764df27bdae7f2cbeb7ada7bcef4e1e
Signed-off-by: Jim Hahn <jrh3@att.com>
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'controlloop/common')
29 files changed, 444 insertions, 601 deletions
diff --git a/controlloop/common/controller-frankfurt/pom.xml b/controlloop/common/controller-frankfurt/pom.xml index 998c477d3..809d9d446 100644 --- a/controlloop/common/controller-frankfurt/pom.xml +++ b/controlloop/common/controller-frankfurt/pom.xml @@ -171,12 +171,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions</groupId> - <artifactId>model-yaml</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.onap.policy.drools-pdp</groupId> <artifactId>policy-management</artifactId> <version>${version.policy.drools-pdp}</version> diff --git a/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl b/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl index c42131318..9723cec43 100644 --- a/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl +++ b/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl @@ -25,7 +25,6 @@ import org.onap.policy.controlloop.CanonicalOnset; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2.NewEventStatus; import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager2; diff --git a/controlloop/common/controller-usecases/pom.xml b/controlloop/common/controller-usecases/pom.xml index e99077a47..fe1218e10 100644 --- a/controlloop/common/controller-usecases/pom.xml +++ b/controlloop/common/controller-usecases/pom.xml @@ -160,12 +160,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions</groupId> - <artifactId>model-yaml</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.onap.policy.drools-pdp</groupId> <artifactId>policy-management</artifactId> <version>${version.policy.drools-pdp}</version> diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java index e1259e48d..f9d90af4d 100644 --- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java +++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2.java @@ -33,10 +33,10 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.policy.controlloop.VirtualControlLoopEvent; 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.impl.OperationPartial; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.eventmanager.StepContext; -import org.onap.policy.controlloop.policy.Target; /** * An operation to get the target entity. This is a "pseudo" operation; it is not found @@ -65,7 +65,7 @@ public class GetTargetEntityOperation2 extends OperationPartial { @Override public List<String> getPropertyNames() { - String propName = detmTarget(params.getTarget()); + String propName = detmTarget(params.getTargetType()); return (propName == null ? Collections.emptyList() : List.of(propName)); } @@ -77,26 +77,22 @@ public class GetTargetEntityOperation2 extends OperationPartial { /** * Determines the target entity. * - * @param target policy target + * @param targetType policy target type * * @return the property containing the target entity, or {@code null} if the target * entity is already known */ - private String detmTarget(Target target) { + private String detmTarget(TargetType targetType) { if (stepContext.contains(OperationProperties.AAI_TARGET_ENTITY)) { // the target entity has already been determined return null; } - if (target == null) { - throw new IllegalArgumentException("The target is null"); - } - - if (target.getType() == null) { + if (targetType == null) { throw new IllegalArgumentException("The target type is null"); } - switch (target.getType()) { + switch (targetType) { case PNF: return detmPnfTarget(); case VM: diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java index cf8cc8ee3..d92fbcfad 100644 --- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java +++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java @@ -58,16 +58,16 @@ import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.ControlLoopResponse; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; +import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult; 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.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; import org.onap.policy.controlloop.eventmanager.ActorConstants; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager; import org.onap.policy.controlloop.eventmanager.StepContext; -import org.onap.policy.controlloop.policy.FinalResult; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.drools.apps.controller.usecases.step.AaiCqStep2; import org.onap.policy.drools.apps.controller.usecases.step.AaiGetPnfStep2; import org.onap.policy.drools.apps.controller.usecases.step.AaiGetTenantStep2; @@ -75,6 +75,9 @@ import org.onap.policy.drools.apps.controller.usecases.step.GetTargetEntityStep2 import org.onap.policy.drools.apps.controller.usecases.step.GuardStep2; import org.onap.policy.drools.apps.controller.usecases.step.LockStep2; import org.onap.policy.drools.apps.controller.usecases.step.Step2; +import org.onap.policy.drools.domain.models.operational.ActorOperation; +import org.onap.policy.drools.domain.models.operational.Operation; +import org.onap.policy.drools.domain.models.operational.OperationalTarget; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.drools.system.PolicyEngineConstants; import org.onap.policy.sdnr.PciMessage; @@ -172,7 +175,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste /** * Policy currently being processed. */ - private Policy policy; + private Operation policy; /** * Result of the last policy operation. This is just a place where the rules can store @@ -180,7 +183,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste */ @Getter @Setter - private PolicyResult result = PolicyResult.SUCCESS; + private OperationResult result = OperationResult.SUCCESS; @ToString.Include private int numOnsets = 1; @@ -205,7 +208,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste private final transient Deque<OperationOutcome2> partialHistory = new LinkedList<>(); @Getter - private FinalResult finalResult = null; + private OperationFinalResult finalResult = null; /** * Message to be placed into the final notification. Typically used when something @@ -284,7 +287,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste * @param finalResult final result * @param finalMessage final message */ - public void abort(@NonNull State finalState, FinalResult finalResult, String finalMessage) { + public void abort(@NonNull State finalState, OperationFinalResult finalResult, String finalMessage) { this.state = finalState; this.finalResult = finalResult; this.finalMessage = finalMessage; @@ -297,7 +300,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste * * @throws ControlLoopException if the processor cannot get a policy */ - public void loadNextPolicy(@NonNull PolicyResult lastResult) throws ControlLoopException { + public void loadNextPolicy(@NonNull OperationResult lastResult) throws ControlLoopException { getProcessor().nextPolicyForResult(lastResult); loadPolicy(); } @@ -317,23 +320,30 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste policy = getProcessor().getCurrentPolicy(); + ActorOperation actor = policy.getActorOperation(); + + OperationalTarget target = actor.getTarget(); + String targetType = (target != null ? target.getTargetType() : null); + Map<String, String> entityIds = (target != null ? target.getEntityIds() : null); + // convert policy payload from Map<String,String> to Map<String,Object> Map<String, Object> payload = new LinkedHashMap<>(); - if (policy.getPayload() != null) { - payload.putAll(policy.getPayload()); + if (actor.getPayload() != null) { + payload.putAll(actor.getPayload()); } // @formatter:off ControlLoopOperationParams params = ControlLoopOperationParams.builder() .actorService(getActorService()) - .actor(policy.getActor()) - .operation(policy.getRecipe()) + .actor(actor.getActor()) + .operation(actor.getOperation()) .requestId(event.getRequestId()) .preprocessed(true) .executor(getExecutor()) - .target(policy.getTarget()) - .retry(policy.getRetry()) + .retry(policy.getRetries()) .timeoutSec(policy.getTimeout()) + .targetType(TargetType.toTargetType(targetType)) + .targetEntityIds(entityIds) .payload(payload) .startCallback(this::onStart) .completeCallback(this::onComplete) @@ -450,7 +460,7 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste * @return {@code true} if the TOSCA should be aborted, {@code false} otherwise */ public boolean isAbort(OperationOutcome outcome) { - return (outcome.getResult() != PolicyResult.SUCCESS && ABORT_ACTORS.contains(outcome.getActor())); + return (outcome.getResult() != OperationResult.SUCCESS && ABORT_ACTORS.contains(outcome.getActor())); } /** @@ -741,7 +751,11 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste this.attempt = attempts; clOperation = outcome.toControlLoopOperation(); - clOperation.setTarget(policy.getTarget().toString()); + + // TODO encode()? + OperationalTarget target = policy.getActorOperation().getTarget(); + String targetStr = (target != null ? target.toString() : null); + clOperation.setTarget(targetStr); if (outcome.getEnd() == null) { clOperation.setOutcome("Started"); diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java index 9275f791d..5d80ea5f4 100644 --- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java +++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/step/Step2.java @@ -59,7 +59,11 @@ import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants; * steps. */ public class Step2 extends Step { - public static final String TARGET_INFO_MSG = "Target information"; + public static final String TARGET_MODEL_VERSION_ID = "modelVersionId"; + public static final String TARGET_MODEL_CUSTOMIZATION_ID = "modelCustomizationId"; + public static final String TARGET_MODEL_INVARIANT_ID = "modelInvariantId"; + public static final String TARGET_RESOURCE_ID = "resourceID"; + public static final String TARGET_INFO_MSG = "Target Entity IDs"; public static final String ENRICHMENT_PREFIX = "enrichment/"; public static final String VSERVER_VSERVER_NAME = "vserver.vserver-name"; public static final String RESOURCE_LINK = "resource-link"; @@ -293,9 +297,9 @@ public class Step2 extends Step { } protected GenericVnf getResourceVnf() { - verifyNotNull(TARGET_INFO_MSG, params.getTarget()); + verifyNotNull(TARGET_INFO_MSG, params.getTargetEntityIds()); - String resourceId = params.getTarget().getResourceID(); + String resourceId = params.getTargetEntityIds().get(TARGET_RESOURCE_ID); verifyNotNull("Target resource ID", resourceId); @@ -323,11 +327,11 @@ public class Step2 extends Step { } protected GenericVnf getVnf() { - verifyNotNull(TARGET_INFO_MSG, params.getTarget()); + verifyNotNull(TARGET_INFO_MSG, params.getTargetEntityIds()); - String modelInvariantId = params.getTarget().getModelInvariantId(); + String modelInvariantId = params.getTargetEntityIds().get(TARGET_MODEL_INVARIANT_ID); - verifyNotNull("modelInvariantId", modelInvariantId); + verifyNotNull(TARGET_MODEL_INVARIANT_ID, modelInvariantId); AaiCqResponse aaicq = getCustomQueryData(); return aaicq.getGenericVnfByVfModuleModelInvariantId(modelInvariantId); @@ -359,11 +363,11 @@ public class Step2 extends Step { return stepContext.getProperty(OperationProperties.DATA_VF_COUNT); } - verifyNotNull(TARGET_INFO_MSG, params.getTarget()); + verifyNotNull(TARGET_INFO_MSG, params.getTargetEntityIds()); - String modelCustomizationId = params.getTarget().getModelCustomizationId(); - String modelInvariantId = params.getTarget().getModelInvariantId(); - String modelVersionId = params.getTarget().getModelVersionId(); + String modelCustomizationId = params.getTargetEntityIds().get(TARGET_MODEL_CUSTOMIZATION_ID); + String modelInvariantId = params.getTargetEntityIds().get(TARGET_MODEL_INVARIANT_ID); + String modelVersionId = params.getTargetEntityIds().get(TARGET_MODEL_VERSION_ID); verifyNotNull("target modelCustomizationId", modelCustomizationId); verifyNotNull("target modelInvariantId", modelInvariantId); diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java index 238ac3d70..efa27a6ec 100644 --- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java +++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/GetTargetEntityOperation2Test.java @@ -39,10 +39,9 @@ import org.mockito.MockitoAnnotations; import org.onap.aai.domain.yang.GenericVnf; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.TargetType; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.eventmanager.StepContext; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; public class GetTargetEntityOperation2Test { private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id"; @@ -59,7 +58,6 @@ public class GetTargetEntityOperation2Test { private ControlLoopOperationParams params; private VirtualControlLoopEvent event; - private Target target; private GenericVnf vnf; private GetTargetEntityOperation2 oper; @@ -74,13 +72,10 @@ public class GetTargetEntityOperation2Test { event.setTarget("pnf.pnf-name"); event.setAai(Map.of("pnf.pnf-name", MY_PNF)); - target = new Target(); - target.setType(TargetType.PNF); - vnf = new GenericVnf(); vnf.setVnfId(MY_VNF); - when(params.getTarget()).thenReturn(target); + when(params.getTargetType()).thenReturn(TargetType.PNF); when(params.getActor()).thenReturn(MY_ACTOR); when(params.getOperation()).thenReturn(MY_OPERATION); @@ -124,24 +119,12 @@ public class GetTargetEntityOperation2Test { } /** - * Tests detmTarget() when the target is {@code null}. - */ - @Test - public void testDetmTargetNull() { - remakeWithoutData(); - when(params.getTarget()).thenReturn(null); - - assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()) - .withMessage("The target is null"); - } - - /** * Tests detmTarget() when the target type is {@code null}. */ @Test public void testDetmTargetNullType() { remakeWithoutData(); - target.setType(null); + when(params.getTargetType()).thenReturn(null); assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()) .withMessage("The target type is null"); @@ -152,7 +135,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmTargetVm() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); enrichTarget(VSERVER_NAME); assertThat(oper.getPropertyNames()).isEmpty(); verifyTarget(MY_VNF); @@ -163,7 +146,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmTargetVnf() { - target.setType(TargetType.VNF); + when(params.getTargetType()).thenReturn(TargetType.VNF); enrichTarget(VSERVER_NAME); assertThat(oper.getPropertyNames()).isEmpty(); verifyTarget(MY_VNF); @@ -175,7 +158,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmTargetVfModule() { - target.setType(TargetType.VFMODULE); + when(params.getTargetType()).thenReturn(TargetType.VFMODULE); enrichTarget(VSERVER_NAME); assertThat(oper.getPropertyNames()).isEmpty(); verifyTarget(MY_VNF); @@ -186,7 +169,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmTargetUnknownType() { - target.setType(TargetType.VFC); + when(params.getTargetType()).thenReturn(TargetType.VFC); enrichTarget(VSERVER_NAME); assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()) .withMessage("The target type is not supported"); @@ -223,7 +206,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVfModuleTargetNullTarget() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); event.setTarget(null); assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()).withMessage("Target is null"); } @@ -233,7 +216,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVfModuleTargetVserverName() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); enrichTarget(VSERVER_NAME); assertThat(oper.getPropertyNames()).isEmpty(); verifyTarget(MY_VNF); @@ -244,7 +227,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVfModuleTargetVnfId() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); enrichTarget(GENERIC_VNF_ID); assertThat(oper.getPropertyNames()).isEmpty(); verifyTarget(MY_VNF); @@ -256,7 +239,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVfModuleTargetVnfName() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); enrichTarget(GENERIC_VNF_ID); // set this AFTER setting enrichment data @@ -271,7 +254,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVfModuleTargetUnknown() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); enrichTarget(VSERVER_NAME); event.setTarget("unknown-vnf"); assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()) @@ -283,7 +266,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVfModuleTargetMissingEnrichment() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); event.setTarget(VSERVER_NAME); assertThatIllegalArgumentException().isThrownBy(() -> oper.getPropertyNames()) .withMessage("Enrichment data is missing " + VSERVER_NAME); @@ -294,7 +277,7 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVnfNameHaveData() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); event.setTarget(GENERIC_VNF_NAME); event.setAai(Map.of(GENERIC_VNF_ID, MY_VNF)); assertThat(oper.getPropertyNames()).isEmpty(); @@ -306,14 +289,14 @@ public class GetTargetEntityOperation2Test { */ @Test public void testDetmVnfNameNoData() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); event.setTarget(GENERIC_VNF_NAME); assertThat(oper.getPropertyNames()).isEqualTo(List.of(UsecasesConstants.AAI_DEFAULT_GENERIC_VNF)); } @Test public void testSetProperty() { - target.setType(TargetType.VM); + when(params.getTargetType()).thenReturn(TargetType.VM); event.setTarget(GENERIC_VNF_NAME); // not a property of interest - should be ignored @@ -336,7 +319,7 @@ public class GetTargetEntityOperation2Test { } private void remakeWithoutData() { - target.setType(TargetType.VNF); + when(params.getTargetType()).thenReturn(TargetType.VNF); event.setTarget(GENERIC_VNF_NAME); oper = new GetTargetEntityOperation2(stepContext, event, params); } diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java index dfbedc2c7..42fd9e4e4 100644 --- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java +++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/LockOperation2Test.java @@ -39,10 +39,9 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.policy.controlloop.VirtualControlLoopEvent; 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.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.eventmanager.StepContext; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; public class LockOperation2Test { private static final String MY_PNF = "my-pnf"; @@ -56,7 +55,6 @@ public class LockOperation2Test { private ControlLoopOperationParams params; private VirtualControlLoopEvent event; - private Target target; private CompletableFuture<OperationOutcome> future; private GenericVnf vnf; private LockOperation2 oper; @@ -72,9 +70,6 @@ public class LockOperation2Test { event.setTarget("pnf.pnf-name"); event.setAai(Map.of("pnf.pnf-name", MY_PNF)); - target = new Target(); - target.setType(TargetType.PNF); - future = new CompletableFuture<>(); vnf = new GenericVnf(); @@ -82,7 +77,7 @@ public class LockOperation2Test { when(stepContext.requestLock(anyString())).thenReturn(future); - when(params.getTarget()).thenReturn(target); + when(params.getTargetType()).thenReturn(TargetType.PNF); when(params.getActor()).thenReturn(MY_ACTOR); when(params.getOperation()).thenReturn(MY_OPERATION); diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java index 05bc03a60..6681c3ef3 100644 --- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java +++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java @@ -66,19 +66,18 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.Operation; +import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult; 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.TargetType; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; import org.onap.policy.controlloop.eventmanager.ActorConstants; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2; import org.onap.policy.controlloop.ophistory.OperationHistoryDataManager; -import org.onap.policy.controlloop.policy.FinalResult; -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.drools.apps.controller.usecases.UsecasesEventManager.NewEventStatus; import org.onap.policy.drools.apps.controller.usecases.step.AaiCqStep2; import org.onap.policy.drools.apps.controller.usecases.step.AaiGetPnfStep2; @@ -137,7 +136,6 @@ public class UsecasesEventManagerTest { private Step2 stepb; private List<LockImpl> locks; - private Target target; private ToscaPolicy tosca; private ControlLoopParams params; private VirtualControlLoopEvent event; @@ -163,10 +161,7 @@ public class UsecasesEventManagerTest { event.setAai(new TreeMap<>(Map.of(UsecasesConstants.VSERVER_VSERVER_NAME, MY_TARGET))); event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setClosedLoopControlName(CL_NAME); - event.setTargetType(TargetType.VNF.toString()); - - target = new Target(); - target.setType(TargetType.VNF); + event.setTargetType(ControlLoopTargetType.VNF); params = new ControlLoopParams(); params.setClosedLoopControlName(CL_NAME); @@ -299,14 +294,14 @@ public class UsecasesEventManagerTest { @Test public void testAbort() { - mgr.abort(UsecasesEventManager.State.DONE, FinalResult.FINAL_FAILURE_GUARD, "some message"); + mgr.abort(UsecasesEventManager.State.DONE, OperationFinalResult.FINAL_FAILURE_GUARD, "some message"); assertEquals(UsecasesEventManager.State.DONE, mgr.getState()); - assertEquals(FinalResult.FINAL_FAILURE_GUARD, mgr.getFinalResult()); + assertEquals(OperationFinalResult.FINAL_FAILURE_GUARD, mgr.getFinalResult()); assertEquals("some message", mgr.getFinalMessage()); // try null state - assertThatThrownBy(() -> mgr.abort(null, FinalResult.FINAL_FAILURE_GUARD, "")) + assertThatThrownBy(() -> mgr.abort(null, OperationFinalResult.FINAL_FAILURE_GUARD, "")) .isInstanceOf(NullPointerException.class).hasMessageContaining("finalState"); } @@ -325,7 +320,7 @@ public class UsecasesEventManagerTest { mgr.addToHistory(outcome); // indicate success and load next policy - mgr.loadNextPolicy(PolicyResult.SUCCESS); + mgr.loadNextPolicy(OperationResult.SUCCESS); assertEquals("OperationB", mgr.getSteps().poll().getOperationName()); assertNull(mgr.getFinalResult()); @@ -334,8 +329,8 @@ public class UsecasesEventManagerTest { assertThat(mgr.getFullHistory()).hasSize(1); // indicate failure - should go to final failure - mgr.loadNextPolicy(PolicyResult.FAILURE); - assertEquals(FinalResult.FINAL_FAILURE, mgr.getFinalResult()); + mgr.loadNextPolicy(OperationResult.FAILURE); + assertEquals(OperationFinalResult.FINAL_FAILURE, mgr.getFinalResult()); } @Test @@ -354,7 +349,8 @@ public class UsecasesEventManagerTest { assertSame(actors, params2.getActorService()); assertSame(REQ_ID, params2.getRequestId()); assertSame(ForkJoinPool.commonPool(), params2.getExecutor()); - assertNotNull(params2.getTarget()); + assertNotNull(params2.getTargetType()); + assertNotNull(params2.getTargetEntityIds()); assertEquals(Integer.valueOf(300), params2.getTimeoutSec()); assertEquals(Integer.valueOf(0), params2.getRetry()); assertThat(params2.getPayload()).isEmpty(); @@ -508,7 +504,10 @@ public class UsecasesEventManagerTest { */ @Test public void testLoadPreprocessorStepsNeedTargetEntity() { - stepa = new Step2(mgr, ControlLoopOperationParams.builder().target(target).build(), event) { + stepa = new Step2(mgr, + ControlLoopOperationParams.builder() + .targetType(TargetType.toTargetType(event.getTargetType())) + .targetEntityIds(Map.of()).build(), event) { @Override public List<String> getPropertyNames() { return List.of(OperationProperties.AAI_TARGET_ENTITY); @@ -586,7 +585,7 @@ public class UsecasesEventManagerTest { @Test public void testIsAbort() { OperationOutcome outcome = makeCompletedOutcome(); - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); // closed loop timeout outcome.setActor(ActorConstants.CL_TIMEOUT_ACTOR); @@ -597,7 +596,7 @@ public class UsecasesEventManagerTest { assertTrue(mgr.isAbort(outcome)); // no effect for success - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); assertFalse(mgr.isAbort(outcome)); } @@ -673,7 +672,7 @@ public class UsecasesEventManagerTest { assertThat(notif.getHistory()).hasSize(3); // indicate success and load the next policy - should clear the partial history - mgr.loadNextPolicy(PolicyResult.SUCCESS); + mgr.loadNextPolicy(OperationResult.SUCCESS); // check notification notif = mgr.makeNotification(); @@ -691,7 +690,7 @@ public class UsecasesEventManagerTest { assertThat(notif.getHistory()).hasSize(2); // indicate failure - should go to final state - mgr.loadNextPolicy(PolicyResult.FAILURE); + mgr.loadNextPolicy(OperationResult.FAILURE); // check notification notif = mgr.makeNotification(); @@ -1016,7 +1015,7 @@ public class UsecasesEventManagerTest { outcome.setActor(SIMPLE_ACTOR); outcome.setOperation(SIMPLE_OPERATION); outcome.setMessage(OUTCOME_MSG); - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); outcome.setStart(Instant.now()); outcome.setTarget(MY_TARGET); diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java index 75fe486ed..d01e2b5a0 100644 --- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java +++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/step/Step2Test.java @@ -35,6 +35,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -62,26 +63,21 @@ 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.Operator; +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.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager2; import org.onap.policy.controlloop.eventmanager.StepContext; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.drools.apps.controller.usecases.UsecasesConstants; public class Step2Test { private static final UUID REQ_ID = UUID.randomUUID(); - private static final String POLICY_ID = "my-policy"; private static final String POLICY_ACTOR = "my-actor"; private static final String POLICY_OPERATION = "my-operation"; private static final String MY_TARGET = "my-target"; private static final String PAYLOAD_KEY = "payload-key"; private static final String PAYLOAD_VALUE = "payload-value"; - private static final Integer POLICY_RETRY = 3; - private static final Integer POLICY_TIMEOUT = 20; private static final String NO_SLASH = "noslash"; private static final String ONE_SLASH = "/one"; @@ -99,9 +95,7 @@ public class Step2Test { private AaiCqResponse aaicq; private CompletableFuture<OperationOutcome> future; - private Target target; private Map<String, String> payload; - private Policy policy; private VirtualControlLoopEvent event; private ControlLoopEventContext context; private BlockingQueue<OperationOutcome> starts; @@ -128,20 +122,8 @@ public class Step2Test { when(stepContext.getProperty(AaiCqResponse.CONTEXT_KEY)).thenReturn(aaicq); - target = new Target(); - target.setType(TargetType.VM); - payload = Map.of(PAYLOAD_KEY, PAYLOAD_VALUE); - policy = new Policy(); - policy.setId(POLICY_ID); - policy.setActor(POLICY_ACTOR); - policy.setRecipe(POLICY_OPERATION); - policy.setTarget(target); - policy.setPayload(payload); - policy.setRetry(POLICY_RETRY); - policy.setTimeout(POLICY_TIMEOUT); - event = new VirtualControlLoopEvent(); event.setRequestId(REQ_ID); event.setTarget(ControlLoopOperationManager2.VSERVER_VSERVER_NAME); @@ -152,10 +134,13 @@ public class Step2Test { starts = new LinkedBlockingQueue<>(); completions = new LinkedBlockingQueue<>(); + Map<String, String> entityIds = new HashMap<>(); + params = ControlLoopOperationParams.builder().actor(POLICY_ACTOR).actorService(actors) .completeCallback(completions::add).context(context).executor(ForkJoinPool.commonPool()) .operation(POLICY_OPERATION).payload(new TreeMap<>(payload)).startCallback(starts::add) - .target(target).targetEntity(MY_TARGET).build(); + .targetType(TargetType.VM).targetEntityIds(entityIds).targetEntity(MY_TARGET) + .build(); step = new Step2(stepContext, params, event); step.init(); @@ -268,7 +253,7 @@ public class Step2Test { @Test public void testLoadResourceVnf_testGetResourceVnf() { - target.setResourceID("my-resource"); + params.getTargetEntityIds().put(Step2.TARGET_RESOURCE_ID, "my-resource"); GenericVnf data = new GenericVnf(); when(aaicq.getGenericVnfByModelInvariantId("my-resource")).thenReturn(data); when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_RESOURCE_VNF)); @@ -277,12 +262,12 @@ public class Step2Test { verify(policyOperation).setProperty(OperationProperties.AAI_RESOURCE_VNF, data); // missing resource ID - target.setResourceID(null); + params.getTargetEntityIds().put(Step2.TARGET_RESOURCE_ID, null); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) .withMessageContaining("missing Target resource ID"); - // missing target - params = params.toBuilder().target(null).build(); + // missing target entity IDs + params = params.toBuilder().targetEntityIds(null).build(); step = new Step2(stepContext, params, event); step.init(); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) @@ -315,7 +300,7 @@ public class Step2Test { @Test public void testLoadVnf_testGetVnf() { - target.setModelInvariantId("my-model-invariant"); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "my-model-invariant"); GenericVnf data = new GenericVnf(); when(aaicq.getGenericVnfByVfModuleModelInvariantId("my-model-invariant")).thenReturn(data); when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.AAI_VNF)); @@ -324,12 +309,12 @@ public class Step2Test { verify(policyOperation).setProperty(OperationProperties.AAI_VNF, data); // missing model invariant ID - target.setModelInvariantId(null); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, null); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) .withMessageContaining("missing modelInvariantId"); // missing target - params = params.toBuilder().target(null).build(); + params = params.toBuilder().targetEntityIds(null).build(); step = new Step2(stepContext, params, event); step.init(); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) @@ -338,7 +323,7 @@ public class Step2Test { @Test public void testLoadVnfModel_testGetVnfModel() { - target.setModelInvariantId("my-model-invariant"); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "my-model-invariant"); GenericVnf vnf = new GenericVnf(); when(aaicq.getGenericVnfByVfModuleModelInvariantId("my-model-invariant")).thenReturn(vnf); @@ -388,9 +373,9 @@ public class Step2Test { @Test public void testLoadVfCount_testGetVfCount() { - target.setModelCustomizationId("vf-count-customization"); - target.setModelInvariantId("vf-count-invariant"); - target.setModelVersionId("vf-count-version"); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_CUSTOMIZATION_ID, "vf-count-customization"); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, "vf-count-invariant"); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_VERSION_ID, "vf-count-version"); when(aaicq.getVfModuleCount("vf-count-customization", "vf-count-invariant", "vf-count-version")).thenReturn(11); when(policyOperation.getPropertyNames()).thenReturn(List.of(OperationProperties.DATA_VF_COUNT)); @@ -398,22 +383,22 @@ public class Step2Test { verify(policyOperation).setProperty(OperationProperties.DATA_VF_COUNT, 11); // missing model version id - target.setModelVersionId(null); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_VERSION_ID, null); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) .withMessageContaining("missing target modelVersionId"); // missing model invariant id - target.setModelInvariantId(null); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_INVARIANT_ID, null); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) .withMessageContaining("missing target modelInvariantId"); // missing model customization id - target.setModelCustomizationId(null); + params.getTargetEntityIds().put(Step2.TARGET_MODEL_CUSTOMIZATION_ID, null); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) .withMessageContaining("missing target modelCustomizationId"); // missing target - params = params.toBuilder().target(null).build(); + params = params.toBuilder().targetEntityIds(null).build(); step = new Step2(stepContext, params, event); step.init(); assertThatIllegalArgumentException().isThrownBy(() -> step.setProperties()) diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 5cf087abd..c0116c952 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -178,7 +178,7 @@ public class ControlLoopEventManager implements StepContext, Serializable { */ private long detmControlLoopTimeoutMs() { // validation checks preclude null or 0 timeout values in the policy - Integer timeout = processor.getControlLoop().getTimeout(); + Integer timeout = processor.getPolicy().getProperties().getTimeout(); return TimeUnit.MILLISECONDS.convert(timeout, TimeUnit.SECONDS); } @@ -221,6 +221,7 @@ public class ControlLoopEventManager implements StepContext, Serializable { * @param name name of the property of interest * @return {@code true} if the context contains the property, {@code false} otherwise */ + @Override public boolean contains(String name) { return properties.containsKey(name); } @@ -232,6 +233,7 @@ public class ControlLoopEventManager implements StepContext, Serializable { * @param name name of the property whose value is to be retrieved * @return the property's value, or {@code null} if it does not yet have a value */ + @Override @SuppressWarnings("unchecked") public <T> T getProperty(String name) { return (T) properties.get(name); @@ -243,6 +245,7 @@ public class ControlLoopEventManager implements StepContext, Serializable { * @param name property name * @param value new property value */ + @Override public void setProperty(String name, Serializable value) { logger.error("set property {}={} manager={}", name, value, this); properties.put(name, value); @@ -253,6 +256,7 @@ public class ControlLoopEventManager implements StepContext, Serializable { * * @param name property name */ + @Override public void removeProperty(String name) { properties.remove(name); } diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java index 5f611c098..556fa31d5 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java @@ -54,14 +54,14 @@ import org.onap.policy.controlloop.ControlLoopResponse; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.actorserviceprovider.ActorService; +import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; import org.onap.policy.controlloop.ophistory.OperationHistoryDataManager; -import org.onap.policy.controlloop.policy.FinalResult; -import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.processor.ControlLoopProcessor; import org.onap.policy.drools.core.lock.LockCallback; +import org.onap.policy.drools.domain.models.operational.Operation; import org.onap.policy.drools.system.PolicyEngineConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -151,7 +151,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { private final ControlLoopProcessor processor; private final AtomicReference<ControlLoopOperationManager2> currentOperation = new AtomicReference<>(); - private FinalResult finalResult = null; + private OperationFinalResult finalResult = null; @Getter private VirtualControlLoopNotification notification; @@ -289,7 +289,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { } catch (ControlLoopException | RuntimeException e) { // processor problem - this is fatal logger.warn("{}: cannot start next step for {}", closedLoopControlName, requestId, e); - finalResult = FinalResult.FINAL_FAILURE_EXCEPTION; + finalResult = OperationFinalResult.FINAL_FAILURE_EXCEPTION; controlLoopResponse = null; notification = makeNotification(); notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); @@ -363,7 +363,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); notification.setMessage("Control Loop timed out"); notification.setHistory(controlLoopHistory); - finalResult = FinalResult.FINAL_FAILURE; + finalResult = OperationFinalResult.FINAL_FAILURE; break; case OPERATION_FAILURE: @@ -460,7 +460,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { */ private long detmControlLoopTimeoutMs() { // validation checks preclude null or 0 timeout values in the policy - Integer timeout = processor.getControlLoop().getTimeout(); + Integer timeout = processor.getPolicy().getProperties().getTimeout(); return TimeUnit.MILLISECONDS.convert(timeout, TimeUnit.SECONDS); } @@ -612,8 +612,8 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { // the following methods may be overridden by junit tests - protected ControlLoopOperationManager2 makeOperationManager(ControlLoopEventContext ctx, Policy policy) { - return new ControlLoopOperationManager2(this, ctx, policy, getExecutor()); + protected ControlLoopOperationManager2 makeOperationManager(ControlLoopEventContext ctx, Operation operation) { + return new ControlLoopOperationManager2(this, ctx, operation, getExecutor()); } protected Executor getExecutor() { diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java index 7672622d3..31402f4cf 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java @@ -28,6 +28,7 @@ import java.time.Instant; import java.util.Deque; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentLinkedDeque; @@ -46,11 +47,12 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actor.guard.GuardActor; import org.onap.policy.controlloop.actor.sdnr.SdnrActor; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +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.actorserviceprovider.pipeline.PipelineUtil; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.drools.domain.models.operational.OperationalTarget; import org.onap.policy.sdnr.PciMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,7 +92,7 @@ public class ControlLoopOperationManager2 implements Serializable { private final transient ManagerContext operContext; private final transient ControlLoopEventContext eventContext; - private final Policy policy; + private final org.onap.policy.drools.domain.models.operational.Operation policy; @Getter @ToString.Include @@ -156,25 +158,35 @@ public class ControlLoopOperationManager2 implements Serializable { @Getter private final String operation; + private final String targetStr; + private final OperationalTarget target; + /** * Construct an instance. * * @param operContext this operation's context * @param context event context - * @param policy operation's policy + * @param operation2 operation's policy * @param executor executor for the Operation */ - public ControlLoopOperationManager2(ManagerContext operContext, ControlLoopEventContext context, Policy policy, - Executor executor) { + public ControlLoopOperationManager2(ManagerContext operContext, ControlLoopEventContext context, + org.onap.policy.drools.domain.models.operational.Operation operation2, Executor executor) { this.operContext = operContext; this.eventContext = context; - this.policy = policy; + this.policy = operation2; this.requestId = context.getEvent().getRequestId().toString(); - this.policyId = "" + policy.getId(); - this.actor = policy.getActor(); - this.operation = policy.getRecipe(); + this.policyId = "" + operation2.getId(); + this.actor = operation2.getActorOperation().getActor(); + this.operation = operation2.getActorOperation().getOperation(); + this.target = operation2.getActorOperation().getTarget(); + + String targetType = (target != null ? target.getTargetType() : null); + Map<String, String> entityIds = (target != null ? target.getEntityIds() : null); + + // TODO encode()? + this.targetStr = (target != null ? target.toString() : null); // @formatter:off params = ControlLoopOperationParams.builder() @@ -183,7 +195,8 @@ public class ControlLoopOperationManager2 implements Serializable { .operation(operation) .context(context) .executor(executor) - .target(policy.getTarget()) + .targetType(TargetType.toTargetType(targetType)) + .targetEntityIds(entityIds) .startCallback(this::onStart) .completeCallback(this::onComplete) .build(); @@ -201,7 +214,7 @@ public class ControlLoopOperationManager2 implements Serializable { private static final long serialVersionUID = 1L; private int attempt; - private PolicyResult policyResult; + private OperationResult policyResult; private ControlLoopOperation clOperation; private ControlLoopResponse clResponse; @@ -214,7 +227,7 @@ public class ControlLoopOperationManager2 implements Serializable { attempt = ControlLoopOperationManager2.this.attempts; policyResult = outcome.getResult(); clOperation = outcome.toControlLoopOperation(); - clOperation.setTarget(policy.getTarget().toString()); + clOperation.setTarget(targetStr); clResponse = makeControlLoopResponse(outcome); if (outcome.getEnd() == null) { @@ -268,14 +281,14 @@ public class ControlLoopOperationManager2 implements Serializable { // @formatter:off ControlLoopOperationParams params2 = params.toBuilder() .payload(new LinkedHashMap<>()) - .retry(policy.getRetry()) + .retry(policy.getRetries()) .timeoutSec(policy.getTimeout()) .targetEntity(targetEntity) .build(); // @formatter:on - if (policy.getPayload() != null) { - params2.getPayload().putAll(policy.getPayload()); + if (policy.getActorOperation().getPayload() != null) { + params2.getPayload().putAll(policy.getActorOperation().getPayload()); } return params2.start(); @@ -481,28 +494,28 @@ public class ControlLoopOperationManager2 implements Serializable { case CL_TIMEOUT_ACTOR: state = State.CONTROL_LOOP_TIMEOUT; - processAbort(outcome, PolicyResult.FAILURE, "Control loop timed out"); + processAbort(outcome, OperationResult.FAILURE, "Control loop timed out"); break; case LOCK_ACTOR: // lock is no longer available if (state == State.ACTIVE) { state = State.LOCK_DENIED; - storeFailureInDataBase(outcome, PolicyResult.FAILURE_GUARD, "Operation denied by Lock"); + storeFailureInDataBase(outcome, OperationResult.FAILURE_GUARD, "Operation denied by Lock"); } else { state = State.LOCK_LOST; - processAbort(outcome, PolicyResult.FAILURE, "Operation aborted by Lock"); + processAbort(outcome, OperationResult.FAILURE, "Operation aborted by Lock"); } break; case GUARD_ACTOR: if (outcome.getEnd() == null) { state = State.GUARD_STARTED; - } else if (outcome.getResult() == PolicyResult.SUCCESS) { + } else if (outcome.getResult() == OperationResult.SUCCESS) { state = State.GUARD_PERMITTED; } else { state = State.GUARD_DENIED; - storeFailureInDataBase(outcome, PolicyResult.FAILURE_GUARD, "Operation denied by Guard"); + storeFailureInDataBase(outcome, OperationResult.FAILURE_GUARD, "Operation denied by Guard"); } break; @@ -517,7 +530,7 @@ public class ControlLoopOperationManager2 implements Serializable { * Operation completed. If the last entry was a "start" (i.e., "end" field * is null), then replace it. Otherwise, just add the completion. */ - state = (outcome.getResult() == PolicyResult.SUCCESS ? State.OPERATION_SUCCESS + state = (outcome.getResult() == OperationResult.SUCCESS ? State.OPERATION_SUCCESS : State.OPERATION_FAILURE); controlLoopResponse = makeControlLoopResponse(outcome); if (!operationHistory.isEmpty() && operationHistory.peekLast().getClOperation().getEnd() == null) { @@ -542,7 +555,7 @@ public class ControlLoopOperationManager2 implements Serializable { * @param result result to put into the DB * @param message message to put into the DB */ - private void processAbort(OperationOutcome outcome, PolicyResult result, String message) { + private void processAbort(OperationOutcome outcome, OperationResult result, String message) { if (operationHistory.isEmpty() || operationHistory.peekLast().getClOperation().getEnd() != null) { // last item was not a "start" operation @@ -612,9 +625,9 @@ public class ControlLoopOperationManager2 implements Serializable { * * @return the operation result */ - public PolicyResult getOperationResult() { + public OperationResult getOperationResult() { Operation last = operationHistory.peekLast(); - return (last == null ? PolicyResult.FAILURE_EXCEPTION : last.getPolicyResult()); + return (last == null ? OperationResult.FAILURE_EXCEPTION : last.getPolicyResult()); } /** @@ -652,7 +665,7 @@ public class ControlLoopOperationManager2 implements Serializable { * @param result result to put into the DB * @param message message to put into the DB */ - private void storeFailureInDataBase(OperationOutcome outcome, PolicyResult result, String message) { + private void storeFailureInDataBase(OperationOutcome outcome, OperationResult result, String message) { // don't include this in history yet holdLast = true; @@ -680,15 +693,15 @@ public class ControlLoopOperationManager2 implements Serializable { * already been determined */ protected CompletableFuture<OperationOutcome> detmTarget() { - if (policy.getTarget() == null) { + if (target == null) { throw new IllegalArgumentException("The target is null"); } - if (policy.getTarget().getType() == null) { + if (target.getTargetType() == null) { throw new IllegalArgumentException("The target type is null"); } - switch (policy.getTarget().getType()) { + switch (TargetType.toTargetType(target.getTargetType())) { case PNF: return detmPnfTarget(); case VM: diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java index 835600086..91b5325e2 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/LockData.java @@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.drools.core.lock.Lock; import org.onap.policy.drools.core.lock.LockCallback; import org.slf4j.Logger; @@ -130,7 +130,7 @@ public class LockData implements LockCallback { theLock = lock; OperationOutcome outcome = makeOutcome(); - outcome.setResult(PolicyResult.SUCCESS); + outcome.setResult(OperationResult.SUCCESS); outcome.setMessage(ControlLoopOperation.SUCCESS_MSG); future.get().complete(outcome); @@ -141,7 +141,7 @@ public class LockData implements LockCallback { synchronized (this) { logger.warn("lock unavailable on {} for {}", targetEntity, requestId); failedOutcome = makeOutcome(); - failedOutcome.setResult(PolicyResult.FAILURE); + failedOutcome.setResult(OperationResult.FAILURE); failedOutcome.setMessage(ControlLoopOperation.FAILED_MSG); } diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java index f578c8a85..153b081a1 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java @@ -21,47 +21,34 @@ package org.onap.policy.controlloop.processor; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.util.stream.Collectors; import lombok.Getter; -import org.apache.commons.beanutils.BeanUtils; import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardYamlCoder; import org.onap.policy.controlloop.ControlLoopException; +import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; -import org.onap.policy.controlloop.policy.ControlLoop; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.policy.FinalResult; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyParam; -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.drools.domain.models.DroolsPolicy; import org.onap.policy.drools.domain.models.operational.Operation; import org.onap.policy.drools.domain.models.operational.OperationalPolicy; -import org.onap.policy.drools.domain.models.operational.OperationalTarget; import org.onap.policy.drools.system.PolicyEngineConstants; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; public class ControlLoopProcessor implements Serializable { private static final long serialVersionUID = 1L; - private static final Logger logger = LoggerFactory.getLogger(ControlLoopProcessor.class); + + private static final StandardYamlCoder coder = new StandardYamlCoder(); @Getter - private final ControlLoopPolicy policy; + private final OperationalPolicy policy; private String currentNestedPolicyId; // not serializable, thus must be transient @Getter private transient ToscaPolicy toscaOpPolicy; - // not serializable, thus must be transient - @Getter - private transient DroolsPolicy domainOpPolicy; + //@Getter + //private ControlLoop controlLoop; /** * Construct an instance from yaml. @@ -70,19 +57,7 @@ public class ControlLoopProcessor implements Serializable { * @throws ControlLoopException if an error occurs */ public ControlLoopProcessor(String yaml) throws ControlLoopException { - try { - final Yaml y = new Yaml(new CustomClassLoaderConstructor(ControlLoopPolicy.class, - ControlLoopPolicy.class.getClassLoader())); - final Object obj = y.load(yaml); - - this.policy = (ControlLoopPolicy) obj; - this.currentNestedPolicyId = this.policy.getControlLoop().getTrigger_policy(); - } catch (final Exception e) { - // - // Most likely this is a YAML Exception - // - throw new ControlLoopException(e); - } + this(decodeTosca(yaml)); } /** @@ -90,72 +65,30 @@ public class ControlLoopProcessor implements Serializable { */ public ControlLoopProcessor(ToscaPolicy toscaPolicy) throws ControlLoopException { try { - this.policy = buildPolicyFromToscaCompliant(toscaPolicy); - - this.currentNestedPolicyId = this.policy.getControlLoop().getTrigger_policy(); + this.policy = + PolicyEngineConstants.getManager().getDomainMaker().convertTo(toscaPolicy, OperationalPolicy.class); + this.currentNestedPolicyId = this.policy.getProperties().getTrigger(); this.toscaOpPolicy = toscaPolicy; } catch (RuntimeException | CoderException e) { throw new ControlLoopException(e); } } - private Target toStandardTarget(OperationalTarget opTarget) { - Target target = new Target(TargetType.valueOf(opTarget.getTargetType())); + private static ToscaPolicy decodeTosca(String yaml) throws ControlLoopException { try { - BeanUtils.populate(target, opTarget.getEntityIds()); - } catch (IllegalAccessException | InvocationTargetException e) { - logger.warn("target entityIds cannot be mapped (unexpected): {}", opTarget, e); - } - return target; - } - - protected ControlLoopPolicy buildPolicyFromToscaCompliant(ToscaPolicy policy) throws CoderException { - OperationalPolicy domainPolicy = - PolicyEngineConstants.getManager().getDomainMaker().convertTo(policy, OperationalPolicy.class); - - ControlLoopPolicy backwardsCompatiblePolicy = new ControlLoopPolicy(); - - // @formatter:off - backwardsCompatiblePolicy.setPolicies( - domainPolicy.getProperties().getOperations().stream().map(this::convertPolicy) - .collect(Collectors.toList())); - // @formatter:on - - ControlLoop controlLoop = new ControlLoop(); - controlLoop.setAbatement(domainPolicy.getProperties().isAbatement()); - controlLoop.setControlLoopName(domainPolicy.getProperties().getId()); - controlLoop.setTimeout(domainPolicy.getProperties().getTimeout()); - controlLoop.setTrigger_policy(domainPolicy.getProperties().getTrigger()); - controlLoop.setVersion(domainPolicy.getVersion()); + ToscaServiceTemplate template = coder.decode(yaml, ToscaServiceTemplate.class); + if (template == null || template.getToscaTopologyTemplate() == null) { + throw new IllegalArgumentException("Cannot decode yaml into ToscaServiceTemplate"); + } - backwardsCompatiblePolicy.setControlLoop(controlLoop); - this.domainOpPolicy = domainPolicy; - return backwardsCompatiblePolicy; - } + return template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next(); - private Policy convertPolicy(Operation operation) { - // @formatter:off - Policy newPolicy = new Policy(PolicyParam.builder() - .id(operation.getId()) - .name(operation.getActorOperation().getOperation()) - .description(operation.getDescription()) - .actor(operation.getActorOperation().getActor()) - .payload(operation.getActorOperation().getPayload()) - .recipe(operation.getActorOperation().getOperation()) - .retries(operation.getRetries()) - .timeout(operation.getTimeout()) - .target(toStandardTarget(operation.getActorOperation().getTarget())) - .build()); - // @formatter:on - - newPolicy.setSuccess(operation.getSuccess()); - newPolicy.setFailure(operation.getFailure()); - newPolicy.setFailure_exception(operation.getFailureException()); - newPolicy.setFailure_guard(operation.getFailureGuard()); - newPolicy.setFailure_retries(operation.getFailureRetries()); - newPolicy.setFailure_timeout(operation.getFailureTimeout()); - - return newPolicy; + } catch (final Exception e) { + // + // Most likely this is a YAML Exception + // + throw new ControlLoopException(e); + } } /** @@ -164,21 +97,17 @@ public class ControlLoopProcessor implements Serializable { public ControlLoopParams getControlLoopParams() { ControlLoopParams controlLoopParams = new ControlLoopParams(); - controlLoopParams.setClosedLoopControlName(this.getControlLoop().getControlLoopName()); - controlLoopParams.setPolicyScope(domainOpPolicy.getType() + ":" + domainOpPolicy.getTypeVersion()); - controlLoopParams.setPolicyName(domainOpPolicy.getName()); - controlLoopParams.setPolicyVersion(domainOpPolicy.getVersion()); + controlLoopParams.setClosedLoopControlName(this.policy.getProperties().getId()); + controlLoopParams.setPolicyScope(policy.getType() + ":" + policy.getTypeVersion()); + controlLoopParams.setPolicyName(policy.getName()); + controlLoopParams.setPolicyVersion(policy.getVersion()); controlLoopParams.setToscaPolicy(toscaOpPolicy); return controlLoopParams; } - public ControlLoop getControlLoop() { - return this.policy.getControlLoop(); - } - - public FinalResult checkIsCurrentPolicyFinal() { - return FinalResult.toResult(this.currentNestedPolicyId); + public OperationFinalResult checkIsCurrentPolicyFinal() { + return OperationFinalResult.toResult(this.currentNestedPolicyId); } /** @@ -187,12 +116,14 @@ public class ControlLoopProcessor implements Serializable { * @return the current policy * @throws ControlLoopException if an error occurs */ - public Policy getCurrentPolicy() throws ControlLoopException { - if (this.policy == null || this.policy.getPolicies() == null) { + public Operation getCurrentPolicy() throws ControlLoopException { + if (this.policy == null || this.policy.getProperties() == null + || this.policy.getProperties().getOperations() == null + || this.policy.getProperties().getOperations().isEmpty()) { throw new ControlLoopException("There are no policies defined."); } - for (final Policy nestedPolicy : this.policy.getPolicies()) { + for (final Operation nestedPolicy : this.policy.getProperties().getOperations()) { if (nestedPolicy.getId().equals(this.currentNestedPolicyId)) { return nestedPolicy; } @@ -206,8 +137,8 @@ public class ControlLoopProcessor implements Serializable { * @param result the result of the current policy * @throws ControlLoopException if an error occurs */ - public void nextPolicyForResult(PolicyResult result) throws ControlLoopException { - final Policy currentPolicy = this.getCurrentPolicy(); + public void nextPolicyForResult(OperationResult result) throws ControlLoopException { + final Operation currentPolicy = this.getCurrentPolicy(); try { if (currentPolicy == null) { throw new ControlLoopException("There is no current policy to determine where to go to."); @@ -220,21 +151,21 @@ public class ControlLoopProcessor implements Serializable { this.currentNestedPolicyId = currentPolicy.getFailure(); break; case FAILURE_TIMEOUT: - this.currentNestedPolicyId = currentPolicy.getFailure_timeout(); + this.currentNestedPolicyId = currentPolicy.getFailureTimeout(); break; case FAILURE_RETRIES: - this.currentNestedPolicyId = currentPolicy.getFailure_retries(); + this.currentNestedPolicyId = currentPolicy.getFailureRetries(); break; case FAILURE_EXCEPTION: - this.currentNestedPolicyId = currentPolicy.getFailure_exception(); + this.currentNestedPolicyId = currentPolicy.getFailureException(); break; case FAILURE_GUARD: default: - this.currentNestedPolicyId = currentPolicy.getFailure_guard(); + this.currentNestedPolicyId = currentPolicy.getFailureGuard(); break; } } catch (final ControlLoopException e) { - this.currentNestedPolicyId = FinalResult.FINAL_FAILURE_EXCEPTION.toString(); + this.currentNestedPolicyId = OperationFinalResult.FINAL_FAILURE_EXCEPTION.toString(); throw e; } } diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java index 9534f938a..05eba6450 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/SupportUtil.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; @@ -53,15 +53,15 @@ public final class SupportUtil { * @return a Pair * @throws IOException if the file cannot be read */ - public static Pair<ControlLoopPolicy, String> loadYaml(String testFile) throws IOException { + public static Pair<ToscaPolicy, String> loadYaml(String testFile) throws IOException { try (InputStream is = new FileInputStream(new File(testFile))) { String contents = IOUtils.toString(is, StandardCharsets.UTF_8); // // Read the yaml into our Java Object // - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - Object obj = yaml.load(contents); - return new Pair<>((ControlLoopPolicy) obj, contents); + Yaml yaml = new Yaml(new Constructor(ToscaPolicy.class)); + ToscaPolicy obj = yaml.load(contents); + return new Pair<>(obj, contents); } } diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java index 86381ebec..1c4030c08 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java @@ -47,7 +47,6 @@ import java.util.function.Consumer; import org.drools.core.WorkingMemory; import org.junit.Before; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.kie.api.runtime.rule.FactHandle; import org.mockito.ArgumentCaptor; import org.mockito.Mock; @@ -66,18 +65,16 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.actorserviceprovider.ActorService; 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.drl.legacy.ControlLoopParams; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2.NewEventStatus; import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager2.State; import org.onap.policy.controlloop.ophistory.OperationHistoryDataManager; -import org.onap.policy.controlloop.policy.Policy; -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.drools.core.lock.LockCallback; import org.onap.policy.drools.core.lock.LockImpl; import org.onap.policy.drools.core.lock.LockState; +import org.onap.policy.drools.domain.models.operational.Operation; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @@ -117,7 +114,6 @@ public class ControlLoopEventManager2Test { private long preCreateTimeMs; private List<LockImpl> locks; - private Target target; private ToscaPolicy tosca; private ControlLoopParams params; private VirtualControlLoopEvent event; @@ -158,10 +154,7 @@ public class ControlLoopEventManager2Test { event.setAai(new TreeMap<>(Map.of(ControlLoopOperationManager2.VSERVER_VSERVER_NAME, MY_TARGET))); event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setClosedLoopControlName(CL_NAME); - event.setTargetType(TargetType.VNF.toString()); - - target = new Target(); - target.setType(TargetType.VNF); + event.setTargetType(ControlLoopTargetType.VNF); params = new ControlLoopParams(); params.setClosedLoopControlName(CL_NAME); @@ -217,11 +210,11 @@ public class ControlLoopEventManager2Test { for (ControlLoopOperationManager2 oper : Arrays.asList(oper1, oper2, oper3)) { assertTrue(mgr.isActive()); - nextStep(oper, true, PolicyResult.SUCCESS); + nextStep(oper, true, OperationResult.SUCCESS); runRule(); assertTrue(mgr.isActive()); - nextStep(oper, false, PolicyResult.SUCCESS); + nextStep(oper, false, OperationResult.SUCCESS); runRule(); } @@ -257,7 +250,7 @@ public class ControlLoopEventManager2Test { @Test public void testNextStep_testStartOperationSuccess() throws ControlLoopException { - runOperation(PolicyResult.SUCCESS); + runOperation(OperationResult.SUCCESS); VirtualControlLoopNotification notif = mgr.getNotification(); assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notif.getNotification()); @@ -291,7 +284,7 @@ public class ControlLoopEventManager2Test { */ @Test public void testStartOperationException() throws ControlLoopException { - runOperation(PolicyResult.FAILURE_EXCEPTION); + runOperation(OperationResult.FAILURE_EXCEPTION); VirtualControlLoopNotification notif = mgr.getNotification(); assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notif.getNotification()); @@ -303,7 +296,7 @@ public class ControlLoopEventManager2Test { */ @Test public void testStartOperationFailure() throws ControlLoopException { - runOperation(PolicyResult.FAILURE); + runOperation(OperationResult.FAILURE); VirtualControlLoopNotification notif = mgr.getNotification(); assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notif.getNotification()); @@ -315,7 +308,7 @@ public class ControlLoopEventManager2Test { */ @Test public void testStartOperationOpenLoop() throws ControlLoopException { - runOperation(PolicyResult.FAILURE_GUARD); + runOperation(OperationResult.FAILURE_GUARD); VirtualControlLoopNotification notif = mgr.getNotification(); assertEquals(ControlLoopNotificationType.FINAL_OPENLOOP, notif.getNotification()); @@ -441,7 +434,7 @@ public class ControlLoopEventManager2Test { mgr.start(); - nextStep(oper1, true, PolicyResult.SUCCESS); + nextStep(oper1, true, OperationResult.SUCCESS); runRule(); // check notification while running @@ -451,7 +444,7 @@ public class ControlLoopEventManager2Test { List<ControlLoopOperation> history = notif.getHistory(); assertNotNull(history); - nextStep(oper1, false, PolicyResult.SUCCESS); + nextStep(oper1, false, OperationResult.SUCCESS); runRule(); assertFalse(mgr.isActive()); @@ -635,7 +628,7 @@ public class ControlLoopEventManager2Test { event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "ACTIVE")); assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); - + event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "inactive")); assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) .isInstanceOf(IllegalStateException.class); @@ -701,11 +694,11 @@ public class ControlLoopEventManager2Test { } - private void nextStep(ControlLoopOperationManager2 oper, boolean moreSteps, PolicyResult result) { + private void nextStep(ControlLoopOperationManager2 oper, boolean moreSteps, OperationResult result) { when(oper.nextStep()).thenReturn(moreSteps); when(oper.getOperationResult()).thenReturn(result); - if (result == PolicyResult.SUCCESS) { + if (result == OperationResult.SUCCESS) { when(oper.getState()).thenReturn(State.OPERATION_SUCCESS); } else { when(oper.getState()).thenReturn(State.OPERATION_FAILURE); @@ -723,13 +716,13 @@ public class ControlLoopEventManager2Test { mgr.nextStep(); } - private void runOperation(PolicyResult finalResult) throws ControlLoopException { + private void runOperation(OperationResult finalResult) throws ControlLoopException { mgr.start(); verify(oper1).start(anyLong()); assertTrue(mgr.isActive()); - nextStep(oper1, true, PolicyResult.SUCCESS); + nextStep(oper1, true, OperationResult.SUCCESS); runRule(); nextStep(oper1, false, finalResult); @@ -814,8 +807,8 @@ public class ControlLoopEventManager2Test { } @Override - protected ControlLoopOperationManager2 makeOperationManager(ControlLoopEventContext ctx, Policy policy) { - switch (policy.getActor()) { + protected ControlLoopOperationManager2 makeOperationManager(ControlLoopEventContext ctx, Operation policy) { + switch (policy.getActorOperation().getActor()) { case "First": return oper1; case "Second": @@ -823,7 +816,7 @@ public class ControlLoopEventManager2Test { case "Third": return oper3; default: - throw new IllegalArgumentException("unknown policy actor " + policy.getActor()); + throw new IllegalArgumentException("unknown policy actor " + policy.getActorOperation().getActor()); } } } diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index 0b37abb14..e4c233281 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -47,10 +47,8 @@ import org.onap.policy.common.utils.io.Serializer; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.controlloop.ControlLoopException; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; -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.drools.core.lock.LockCallback; import org.onap.policy.drools.core.lock.LockImpl; import org.onap.policy.drools.core.lock.LockState; @@ -73,7 +71,6 @@ public class ControlLoopEventManagerTest { private long preCreateTimeMs; private List<LockImpl> locks; - private Target target; private ToscaPolicy tosca; private ControlLoopParams params; private ControlLoopEventManager mgr; @@ -85,9 +82,6 @@ public class ControlLoopEventManagerTest { public void setUp() throws ControlLoopException, CoderException { MockitoAnnotations.initMocks(this); - target = new Target(); - target.setType(TargetType.VNF); - params = new ControlLoopParams(); params.setClosedLoopControlName(CL_NAME); params.setPolicyName(POLICY_NAME); @@ -189,11 +183,11 @@ public class ControlLoopEventManagerTest { // indicate that the first lock failed locks.get(0).notifyUnavailable(); - verifyLock(PolicyResult.FAILURE); + verifyLock(OperationResult.FAILURE); assertTrue(mgr.getOutcomes().isEmpty()); } - private void verifyLock(PolicyResult result) { + private void verifyLock(OperationResult result) { OperationOutcome outcome = mgr.getOutcomes().poll(); assertNotNull(outcome); assertEquals(ActorConstants.LOCK_ACTOR, outcome.getActor()); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java index add4c41aa..0b066651b 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2Test.java @@ -61,15 +61,15 @@ import org.onap.policy.controlloop.actor.guard.GuardActor; 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.TargetType; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.ophistory.OperationHistoryDataManager; -import org.onap.policy.controlloop.policy.Policy; -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.drools.domain.models.operational.ActorOperation; +import org.onap.policy.drools.domain.models.operational.OperationalTarget; import org.onap.policy.sdnr.PciBody; import org.onap.policy.sdnr.PciMessage; import org.onap.policy.sdnr.PciResponse; @@ -114,9 +114,11 @@ public class ControlLoopOperationManager2Test { private CompletableFuture<OperationOutcome> lockFuture; private CompletableFuture<OperationOutcome> policyFuture; - private Target target; + private ActorOperation operation; + private OperationalTarget target; + private Map<String, String> entityIds; private Map<String, String> payload; - private Policy policy; + private org.onap.policy.drools.domain.models.operational.Operation policy; private VirtualControlLoopEvent event; private ControlLoopEventContext context; private PseudoExecutor executor; @@ -145,19 +147,28 @@ public class ControlLoopOperationManager2Test { when(vnf.getVnfId()).thenReturn(MY_VNF_ID); when(cqdata.getDefaultGenericVnf()).thenReturn(vnf); - target = new Target(); - target.setType(TargetType.VM); + entityIds = Map.of("entity-name-A", "entity-value-A"); + + target = OperationalTarget.builder() + .targetType(TargetType.VM.toString()) + .entityIds(entityIds) + .build(); payload = Map.of(PAYLOAD_KEY, PAYLOAD_VALUE); - policy = new Policy(); - policy.setId(POLICY_ID); - policy.setActor(POLICY_ACTOR); - policy.setRecipe(POLICY_OPERATION); - policy.setTarget(target); - policy.setPayload(payload); - policy.setRetry(POLICY_RETRY); - policy.setTimeout(POLICY_TIMEOUT); + operation = ActorOperation.builder() + .actor(POLICY_ACTOR) + .operation(POLICY_OPERATION) + .payload(payload) + .target(target) + .build(); + + policy = org.onap.policy.drools.domain.models.operational.Operation.builder() + .id(POLICY_ID) + .actorOperation(operation) + .retries(POLICY_RETRY) + .timeout(POLICY_TIMEOUT) + .build(); event = new VirtualControlLoopEvent(); event.setRequestId(REQ_ID); @@ -200,7 +211,7 @@ public class ControlLoopOperationManager2Test { assertFalse(mgr.nextStep()); OperationOutcome outcome = mgr.getOutcomes().peek(); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertTrue(outcome.isFinalOutcome()); verify(mgrctx, times(4)).updated(mgr); @@ -211,7 +222,8 @@ public class ControlLoopOperationManager2Test { */ @Test public void testStartDetmTargetException() { - policy.setTarget(new Target()); + operation.setTarget(OperationalTarget.builder().build()); + mgr = new ControlLoopOperationManager2(mgrctx, context, policy, executor); mgr.start(REMAINING_MS); runToCompletion(); @@ -309,14 +321,15 @@ public class ControlLoopOperationManager2Test { assertSame(REQ_ID, params.getRequestId()); assertSame(POLICY_RETRY, params.getRetry()); assertNotNull(params.getStartCallback()); - assertSame(target, params.getTarget()); + assertEquals(target.getTargetType().toString(), params.getTargetType().toString()); + assertSame(entityIds, params.getTargetEntityIds()); assertEquals(MY_TARGET, params.getTargetEntity()); assertSame(POLICY_TIMEOUT, params.getTimeoutSec()); } @Test public void testStartOperationNullPayload() { - policy.setPayload(null); + operation.setPayload(null); mgr.start(REMAINING_MS); lockFuture.complete(new OperationOutcome()); @@ -341,7 +354,8 @@ public class ControlLoopOperationManager2Test { assertSame(REQ_ID, params.getRequestId()); assertSame(POLICY_RETRY, params.getRetry()); assertNotNull(params.getStartCallback()); - assertSame(target, params.getTarget()); + assertEquals(target.getTargetType().toString(), params.getTargetType().toString()); + assertSame(entityIds, params.getTargetEntityIds()); assertEquals(MY_TARGET, params.getTargetEntity()); assertSame(POLICY_TIMEOUT, params.getTimeoutSec()); } @@ -367,7 +381,7 @@ public class ControlLoopOperationManager2Test { /* * now work with SDNR actor */ - policy.setActor("SDNR"); + operation.setActor("SDNR"); mgr = new ControlLoopOperationManager2(mgrctx, context, policy, executor); // should return null for a null input @@ -407,7 +421,7 @@ public class ControlLoopOperationManager2Test { assertNotNull(mgr.getOperationResult()); runCyle(); - assertEquals(PolicyResult.SUCCESS, mgr.getOperationResult()); + assertEquals(OperationResult.SUCCESS, mgr.getOperationResult()); } /** @@ -420,7 +434,7 @@ public class ControlLoopOperationManager2Test { genLockFailure(); runToCompletion(); - assertEquals(PolicyResult.FAILURE_GUARD, mgr.getOperationResult()); + assertEquals(OperationResult.FAILURE_GUARD, mgr.getOperationResult()); } /** @@ -490,7 +504,7 @@ public class ControlLoopOperationManager2Test { // generate failure outcome for ANOTHER actor - should be ignored OperationOutcome outcome = mgr.getParams().makeOutcome(); outcome.setActor(OTHER_ACTOR); - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); outcome.setStart(Instant.now()); mgr.getParams().callbackStarted(new OperationOutcome(outcome)); @@ -514,7 +528,7 @@ public class ControlLoopOperationManager2Test { assertFalse(mgr.nextStep()); - assertEquals(PolicyResult.SUCCESS, mgr.getOutcomes().peek().getResult()); + assertEquals(OperationResult.SUCCESS, mgr.getOutcomes().peek().getResult()); verify(mgrctx, times(4)).updated(mgr); } @@ -556,7 +570,7 @@ public class ControlLoopOperationManager2Test { assertFalse(mgr.nextStep()); verify(mgrctx).updated(mgr); - verifyDb(1, PolicyResult.FAILURE_GUARD, "Operation denied by Lock"); + verifyDb(1, OperationResult.FAILURE_GUARD, "Operation denied by Lock"); } /** @@ -588,7 +602,7 @@ public class ControlLoopOperationManager2Test { assertFalse(mgr.nextStep()); verify(mgrctx, times(3)).updated(mgr); - verifyDb(1, PolicyResult.FAILURE, "Operation aborted by Lock"); + verifyDb(1, OperationResult.FAILURE, "Operation aborted by Lock"); } /** @@ -634,7 +648,7 @@ public class ControlLoopOperationManager2Test { assertFalse(mgr.nextStep()); verify(mgrctx, times(2)).updated(mgr); - verifyDb(1, PolicyResult.FAILURE_GUARD, "Operation denied by Guard"); + verifyDb(1, OperationResult.FAILURE_GUARD, "Operation denied by Guard"); } /** @@ -664,7 +678,7 @@ public class ControlLoopOperationManager2Test { assertFalse(mgr.nextStep()); verify(mgrctx, times(4)).updated(mgr); - verifyDb(2, PolicyResult.SUCCESS, null); + verifyDb(2, OperationResult.SUCCESS, null); } /** @@ -690,7 +704,7 @@ public class ControlLoopOperationManager2Test { assertTrue(mgr.nextStep()); assertEquals(ControlLoopOperationManager2.State.OPERATION_FAILURE, mgr.getState()); - verifyDb(2, PolicyResult.FAILURE, null); + verifyDb(2, OperationResult.FAILURE, null); assertThat(mgr.toString()).contains("attempts=1"); @@ -703,7 +717,7 @@ public class ControlLoopOperationManager2Test { assertTrue(mgr.nextStep()); assertEquals(ControlLoopOperationManager2.State.OPERATION_FAILURE, mgr.getState()); - verifyDb(4, PolicyResult.FAILURE, null); + verifyDb(4, OperationResult.FAILURE, null); assertThat(mgr.toString()).contains("attempts=2"); @@ -715,7 +729,7 @@ public class ControlLoopOperationManager2Test { assertTrue(mgr.nextStep()); assertEquals(ControlLoopOperationManager2.State.OPERATION_SUCCESS, mgr.getState()); - verifyDb(6, PolicyResult.SUCCESS, null); + verifyDb(6, OperationResult.SUCCESS, null); assertThat(mgr.toString()).contains("attempts=3"); @@ -744,29 +758,30 @@ public class ControlLoopOperationManager2Test { @Test public void testDetmTargetVm() { - target.setType(TargetType.VM); + target.setTargetType(TargetType.VM.toString()); assertNull(mgr.detmTarget()); assertEquals(MY_TARGET, mgr.getTargetEntity()); - target.setType(TargetType.VNF); + target.setTargetType(TargetType.VNF.toString()); assertNull(mgr.detmTarget()); assertEquals(MY_TARGET, mgr.getTargetEntity()); - target.setType(TargetType.VFMODULE); + target.setTargetType(TargetType.VFMODULE.toString()); assertNull(mgr.detmTarget()); assertEquals(MY_TARGET, mgr.getTargetEntity()); // unsupported type - target.setType(TargetType.VFC); + target.setTargetType(TargetType.VFC.toString()); assertThatIllegalArgumentException().isThrownBy(() -> mgr.detmTarget()) .withMessage("The target type is not supported"); // null type - target.setType(null); + target.setTargetType(null); assertThatIllegalArgumentException().isThrownBy(() -> mgr.detmTarget()).withMessage("The target type is null"); // null target - policy.setTarget(null); + operation.setTarget(null); + mgr = new ControlLoopOperationManager2(mgrctx, context, policy, executor); assertThatIllegalArgumentException().isThrownBy(() -> mgr.detmTarget()).withMessage("The target is null"); } @@ -899,7 +914,7 @@ public class ControlLoopOperationManager2Test { OperationOutcome outcome = new OperationOutcome(); outcome.setActor(ControlLoopOperationManager2.LOCK_ACTOR); outcome.setOperation(ControlLoopOperationManager2.LOCK_OPERATION); - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); outcome.setStart(Instant.now()); outcome.setEnd(Instant.now()); outcome.setFinalOutcome(true); @@ -936,7 +951,7 @@ public class ControlLoopOperationManager2Test { mgr.getParams().callbackStarted(new OperationOutcome(outcome)); if (!permit) { - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); } outcome.setEnd(Instant.now()); @@ -969,7 +984,7 @@ public class ControlLoopOperationManager2Test { if (success) { outcome.setFinalOutcome(true); } else { - outcome.setResult(PolicyResult.FAILURE); + outcome.setResult(OperationResult.FAILURE); } outcome.setEnd(Instant.now()); @@ -986,7 +1001,7 @@ public class ControlLoopOperationManager2Test { event.getAai().clear(); event.getAai().putAll(Map.of(ControlLoopOperationManager2.PNF_NAME, MY_TARGET)); - target.setType(TargetType.PNF); + target.setTargetType(TargetType.PNF.toString()); } /** @@ -997,7 +1012,7 @@ public class ControlLoopOperationManager2Test { event.getAai().clear(); event.getAai().putAll(Map.of(ControlLoopOperationManager2.GENERIC_VNF_VNF_ID, MY_TARGET)); - target.setType(TargetType.VNF); + target.setTargetType(TargetType.VNF.toString()); } private void checkResp(OperationOutcome outcome, String expectedPayload) { @@ -1007,7 +1022,7 @@ public class ControlLoopOperationManager2Test { assertEquals(expectedPayload, resp.getPayload()); } - private void verifyDb(int nrecords, PolicyResult expectedResult, String expectedMsg) { + private void verifyDb(int nrecords, OperationResult expectedResult, String expectedMsg) { ArgumentCaptor<String> entityCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<ControlLoopOperation> opCaptor = ArgumentCaptor.forClass(ControlLoopOperation.class); verify(dataMgr, times(nrecords)).store(any(), any(), entityCaptor.capture(), opCaptor.capture()); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java index 13ad56259..a2f01344f 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java @@ -33,7 +33,6 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerImpl; diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/LockDataTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/LockDataTest.java index dc470e7c8..98ff04da5 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/LockDataTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/LockDataTest.java @@ -43,7 +43,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.drools.core.lock.Lock; public class LockDataTest { @@ -135,7 +135,7 @@ public class LockDataTest { assertEquals(ControlLoopOperationManager2.LOCK_ACTOR, outcome.getActor()); assertEquals(ControlLoopOperationManager2.LOCK_OPERATION, outcome.getOperation()); assertEquals(ENTITY, outcome.getTarget()); - assertEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage()); Instant start = outcome.getStart(); @@ -176,7 +176,7 @@ public class LockDataTest { assertEquals(ControlLoopOperationManager2.LOCK_ACTOR, outcome.getActor()); assertEquals(ControlLoopOperationManager2.LOCK_OPERATION, outcome.getOperation()); assertEquals(ENTITY, outcome.getTarget()); - assertEquals(PolicyResult.FAILURE, outcome.getResult()); + assertEquals(OperationResult.FAILURE, outcome.getResult()); assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage()); Instant start = outcome.getStart(); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java index c4121bb38..efcc6101a 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/StepTest.java @@ -47,30 +47,27 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.onap.policy.controlloop.ControlLoopTargetType; 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.TargetType; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -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.drools.domain.models.operational.OperationalTarget; public class StepTest { private static final UUID REQ_ID = UUID.randomUUID(); - private static final String POLICY_ID = "my-policy"; private static final String POLICY_ACTOR = "my-actor"; private static final String POLICY_OPERATION = "my-operation"; private static final String MY_TARGET = "my-target"; private static final String PAYLOAD_KEY = "payload-key"; private static final String PAYLOAD_VALUE = "payload-value"; private static final long REMAINING_MS = 5000; - private static final Integer POLICY_RETRY = 3; - private static final Integer POLICY_TIMEOUT = 20; private static final String EXPECTED_EXCEPTION = "expected exception"; @Mock @@ -83,9 +80,9 @@ public class StepTest { private ActorService actors; private CompletableFuture<OperationOutcome> future; - private Target target; + private OperationalTarget target; + private Map<String, String> entityIds; private Map<String, String> payload; - private Policy policy; private VirtualControlLoopEvent event; private ControlLoopEventContext context; private BlockingQueue<OperationOutcome> starts; @@ -109,19 +106,14 @@ public class StepTest { when(policyOperator.buildOperation(any())).thenReturn(policyOperation); when(policyOperation.start()).thenReturn(future); - target = new Target(); - target.setType(TargetType.VM); + entityIds = Map.of("entity-name-A", "entity-value-A"); - payload = Map.of(PAYLOAD_KEY, PAYLOAD_VALUE); + target = OperationalTarget.builder() + .targetType(ControlLoopTargetType.VM) + .entityIds(entityIds) + .build(); - policy = new Policy(); - policy.setId(POLICY_ID); - policy.setActor(POLICY_ACTOR); - policy.setRecipe(POLICY_OPERATION); - policy.setTarget(target); - policy.setPayload(payload); - policy.setRetry(POLICY_RETRY); - policy.setTimeout(POLICY_TIMEOUT); + payload = Map.of(PAYLOAD_KEY, PAYLOAD_VALUE); event = new VirtualControlLoopEvent(); event.setRequestId(REQ_ID); @@ -136,7 +128,8 @@ public class StepTest { params = ControlLoopOperationParams.builder().actor(POLICY_ACTOR).actorService(actors) .completeCallback(completions::add).context(context).executor(ForkJoinPool.commonPool()) .operation(POLICY_OPERATION).payload(new TreeMap<>(payload)).startCallback(starts::add) - .target(target).targetEntity(MY_TARGET).build(); + .targetType(TargetType.valueOf(target.getTargetType())).targetEntityIds(target.getEntityIds()) + .targetEntity(MY_TARGET).build(); startTime = new AtomicReference<>(); @@ -171,7 +164,8 @@ public class StepTest { assertEquals("operB", params2.getOperation()); assertNull(params2.getRetry()); assertNull(params2.getTimeoutSec()); - assertSame(target, params2.getTarget()); + assertEquals(target.getTargetType().toString(), params2.getTargetType().toString()); + assertSame(entityIds, params2.getTargetEntityIds()); assertEquals(MY_TARGET, params2.getTargetEntity()); assertTrue(params2.getPayload().isEmpty()); @@ -257,7 +251,7 @@ public class StepTest { OperationOutcome outcome = completions.poll(); assertNotNull(outcome); - assertNotEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertNotEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(POLICY_ACTOR, outcome.getActor()); assertTrue(outcome.isFinalOutcome()); } @@ -276,7 +270,7 @@ public class StepTest { OperationOutcome outcome = completions.poll(); assertNotNull(outcome); - assertNotEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertNotEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(POLICY_ACTOR, outcome.getActor()); assertTrue(outcome.isFinalOutcome()); } @@ -318,7 +312,7 @@ public class StepTest { OperationOutcome outcome = completions.poll(); assertNotNull(outcome); - assertNotEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertNotEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(POLICY_ACTOR, outcome.getActor()); assertTrue(outcome.isFinalOutcome()); assertEquals(POLICY_OPERATION, outcome.getOperation()); @@ -348,7 +342,7 @@ public class StepTest { // verify that the future was cancelled assertTrue(future.isCancelled()); - assertNotEquals(PolicyResult.SUCCESS, outcome.getResult()); + assertNotEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(ActorConstants.CL_TIMEOUT_ACTOR, outcome.getActor()); assertTrue(outcome.isFinalOutcome()); assertNull(outcome.getOperation()); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java index 1031c86c7..0ca98720c 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java @@ -30,7 +30,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Paths; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.junit.Test; @@ -38,9 +37,9 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.controlloop.ControlLoopException; -import org.onap.policy.controlloop.policy.FinalResult; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; +import org.onap.policy.drools.domain.models.operational.Operation; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.slf4j.Logger; @@ -52,8 +51,7 @@ public class ControlLoopProcessorTest { @Test public void testControlLoopProcessor() throws IOException, ControlLoopException { - InputStream is = new FileInputStream(new File("src/test/resources/test.yaml")); - String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8); + String yamlString = Files.readString(new File("src/test/resources/test.yaml").toPath(), StandardCharsets.UTF_8); this.testSuccess(yamlString); this.testFailure(yamlString); } @@ -116,18 +114,18 @@ public class ControlLoopProcessorTest { String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8); assertThatThrownBy(() -> new ControlLoopProcessor(yamlString)) - .hasMessageStartingWith("Cannot create property=string for JavaBean=ControlLoopPolicy"); + .hasMessageEndingWith("Cannot decode yaml into ToscaServiceTemplate"); } @Test public void testControlLoopProcessorBadTriggerYaml() throws IOException, ControlLoopException { - InputStream is = new FileInputStream(new File("src/test/resources/badtriggerpolicy.yaml")); - String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8); + String yamlString = Files.readString(new File("src/test/resources/badtriggerpolicy.yaml").toPath(), + StandardCharsets.UTF_8); ControlLoopProcessor clProcessor = new ControlLoopProcessor(yamlString); assertNull(clProcessor.getCurrentPolicy()); - assertThatThrownBy(() -> clProcessor.nextPolicyForResult(PolicyResult.SUCCESS)) + assertThatThrownBy(() -> clProcessor.nextPolicyForResult(OperationResult.SUCCESS)) .hasMessageStartingWith("There is no current policy to determine where to go to."); } @@ -146,12 +144,12 @@ public class ControlLoopProcessorTest { InputStream is = new FileInputStream(new File("src/test/resources/test.yaml")); String yamlString = IOUtils.toString(is, StandardCharsets.UTF_8); - for (PolicyResult result : PolicyResult.values()) { + for (OperationResult result : OperationResult.values()) { checkResult(yamlString, result); } } - private void checkResult(String yamlString, PolicyResult result) throws ControlLoopException { + private void checkResult(String yamlString, OperationResult result) throws ControlLoopException { ControlLoopProcessor clProcessor = new ControlLoopProcessor(yamlString); clProcessor.getCurrentPolicy(); clProcessor.nextPolicyForResult(result); @@ -165,17 +163,17 @@ public class ControlLoopProcessorTest { */ public void testSuccess(String yaml) throws ControlLoopException { ControlLoopProcessor processor = new ControlLoopProcessor(yaml); - logger.debug("testSuccess: {}", processor.getControlLoop()); + logger.debug("testSuccess: {}", processor.getCurrentPolicy()); while (true) { - FinalResult result = processor.checkIsCurrentPolicyFinal(); + OperationFinalResult result = processor.checkIsCurrentPolicyFinal(); if (result != null) { logger.debug("{}", result); break; } - Policy policy = processor.getCurrentPolicy(); + Operation policy = processor.getCurrentPolicy(); assertNotNull(policy); - logger.debug("current policy is: {} {}", policy.getId(), policy.getName()); - processor.nextPolicyForResult(PolicyResult.SUCCESS); + logger.debug("current policy is: {}", policy.getId()); + processor.nextPolicyForResult(OperationResult.SUCCESS); } } @@ -187,17 +185,17 @@ public class ControlLoopProcessorTest { */ public void testFailure(String yaml) throws ControlLoopException { ControlLoopProcessor processor = new ControlLoopProcessor(yaml); - logger.debug("testFailure: {}", processor.getControlLoop()); + logger.debug("testFailure: {}", processor.getCurrentPolicy()); while (true) { - FinalResult result = processor.checkIsCurrentPolicyFinal(); + OperationFinalResult result = processor.checkIsCurrentPolicyFinal(); if (result != null) { logger.debug("{}", result); break; } - Policy policy = processor.getCurrentPolicy(); + Operation policy = processor.getCurrentPolicy(); assertNotNull(policy); - logger.debug("current policy is: {} {}", policy.getId(), policy.getName()); - processor.nextPolicyForResult(PolicyResult.FAILURE); + logger.debug("current policy is: {}", policy.getId()); + processor.nextPolicyForResult(OperationResult.FAILURE); } } } diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java index c590741f2..9e29af511 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/utils/ControlLoopUtilsTest.java @@ -24,8 +24,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import java.nio.file.Files; -import java.nio.file.Paths; import org.junit.Test; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; diff --git a/controlloop/common/eventmanager/src/test/resources/badtriggerpolicy.yaml b/controlloop/common/eventmanager/src/test/resources/badtriggerpolicy.yaml index 8044c9eb8..e4db8c646 100644 --- a/controlloop/common/eventmanager/src/test/resources/badtriggerpolicy.yaml +++ b/controlloop/common/eventmanager/src/test/resources/badtriggerpolicy.yaml @@ -1,4 +1,4 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved +# Copyright 2018, 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. @@ -11,65 +11,44 @@ # 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. -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-vService-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: service1 - resources: - - resourceName: resource1 - resourceType: VF - - resourceName: resource2 - resourceType: VF - - resourceName: resource3 - resourceType: VF - - resourceName: resource4 - resourceType: VF - - resourceName: resource5 - resourceType: VF - trigger_policy: a-policy-that-does-not-exist - timeout: 60 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: - type: VNF - retry: 1 - timeout: 20 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 10 - success: final_success - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 30 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - operational.scaleout: + type: onap.policies.controlloop.operational.common.Drools + type_version: 1.0.0 + version: 1.0.0 + name: operational.scaleout + metadata: + policy-id: operational.scaleout + properties: + id: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + timeout: 1200 + abatement: false + trigger: a-policy-id-that-does-not-exist + operations: + - id: unique-policy-id-1-scale-up + description: Create a new VF Module + operation: + actor: SO + operation: VF Module Create + target: + targetType: VFMODULE + entityIds: + modelInvariantId: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e + modelVersionId: 94b18b1d-cc91-4f43-911a-e6348665f292 + modelName: VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0 + modelVersion: "1" + modelCustomizationId: 47958575-138f-452a-8c8d-d89b595f8164 + payload: + requestParameters: '{"usePreload":true,"userParams":[]}' + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]' + timeout: 1200 + retries: 0 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard + controllerName: frankfurt diff --git a/controlloop/common/eventmanager/src/test/resources/nopolicy.yaml b/controlloop/common/eventmanager/src/test/resources/nopolicy.yaml index 85f8aebab..f69299ee4 100644 --- a/controlloop/common/eventmanager/src/test/resources/nopolicy.yaml +++ b/controlloop/common/eventmanager/src/test/resources/nopolicy.yaml @@ -1,4 +1,4 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved +# Copyright 2018, 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. @@ -11,21 +11,20 @@ # 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. -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-vService-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: service1 - resources: - - resourceName: resource1 - resourceType: VF - - resourceName: resource2 - resourceType: VF - - resourceName: resource3 - resourceType: VF - - resourceName: resource4 - resourceType: VF - - resourceName: resource5 - resourceType: VF - trigger_policy: a-policy-that-does-not-exist - timeout: 60 +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - operational.scaleout: + type: onap.policies.controlloop.operational.common.Drools + type_version: 1.0.0 + version: 1.0.0 + name: operational.scaleout + metadata: + policy-id: operational.scaleout + properties: + id: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + timeout: 1200 + abatement: false + trigger: unique-policy-id-1-scale-up + operations: [] + controllerName: frankfurt diff --git a/controlloop/common/eventmanager/src/test/resources/test.yaml b/controlloop/common/eventmanager/src/test/resources/test.yaml index aac390ce4..02d51e2a5 100644 --- a/controlloop/common/eventmanager/src/test/resources/test.yaml +++ b/controlloop/common/eventmanager/src/test/resources/test.yaml @@ -1,4 +1,4 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved +# Copyright 2018, 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. @@ -11,65 +11,44 @@ # 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. -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-vService-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: service1 - resources: - - resourceName: resource1 - resourceType: VF - - resourceName: resource2 - resourceType: VF - - resourceName: resource3 - resourceType: VF - - resourceName: resource4 - resourceType: VF - - resourceName: resource5 - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 60 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: - type: VNF - retry: 1 - timeout: 20 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 10 - success: final_success - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 30 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception +tosca_definitions_version: tosca_simple_yaml_1_1_0 +topology_template: + policies: + - operational.scaleout: + type: onap.policies.controlloop.operational.common.Drools + type_version: 1.0.0 + version: 1.0.0 + name: operational.scaleout + metadata: + policy-id: operational.scaleout + properties: + id: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + timeout: 1200 + abatement: false + trigger: unique-policy-id-1-scale-up + operations: + - id: unique-policy-id-1-scale-up + description: Create a new VF Module + operation: + actor: SO + operation: VF Module Create + target: + targetType: VFMODULE + entityIds: + modelInvariantId: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e + modelVersionId: 94b18b1d-cc91-4f43-911a-e6348665f292 + modelName: VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0 + modelVersion: "1" + modelCustomizationId: 47958575-138f-452a-8c8d-d89b595f8164 + payload: + requestParameters: '{"usePreload":true,"userParams":[]}' + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]' + timeout: 1200 + retries: 0 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard + controllerName: frankfurt diff --git a/controlloop/common/feature-controlloop-management/pom.xml b/controlloop/common/feature-controlloop-management/pom.xml index 2fcb0dee5..0b2f5905c 100644 --- a/controlloop/common/feature-controlloop-management/pom.xml +++ b/controlloop/common/feature-controlloop-management/pom.xml @@ -257,21 +257,6 @@ </exclusions> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions</groupId> - <artifactId>model-yaml</artifactId> - <version>${policy.models.version}</version> - <exclusions> - <exclusion> - <artifactId>guava</artifactId> - <groupId>com.google.guava</groupId> - </exclusion> - <exclusion> - <artifactId>snakeyaml</artifactId> - <groupId>org.yaml</groupId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>org.onap.policy.drools-pdp</groupId> <artifactId>policy-management</artifactId> <version>${version.policy.drools-pdp}</version> diff --git a/controlloop/common/rules-test/src/test/resources/rulesTest.drl b/controlloop/common/rules-test/src/test/resources/rulesTest.drl index 11e99e960..734282ee9 100644 --- a/controlloop/common/rules-test/src/test/resources/rulesTest.drl +++ b/controlloop/common/rules-test/src/test/resources/rulesTest.drl @@ -25,7 +25,6 @@ import org.onap.policy.controlloop.CanonicalOnset; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2; import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager2.NewEventStatus; import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager2; |