summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-10-04 16:13:59 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-10-04 16:14:33 +0100
commitb6d09ef9da41191199f2da7958d5b418ed2da8d9 (patch)
tree0a14755192f1418ab4c14e06858d0993a090bb40 /feature-lifecycle
parent396f60280265a37379916ad12752a94691118f65 (diff)
Remove AAF from drools-pdp
Issue-ID: POLICY-4592 Change-Id: Ibe7fb63017f862bdab4a80444a00324040b1ab87 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'feature-lifecycle')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java1
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java6
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java18
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java132
4 files changed, 76 insertions, 81 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java
index 953f0b37..a50deb21 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
index 80d0bc7e..202eb98b 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@ package org.onap.policy.drools.lifecycle;
import java.util.Collections;
import lombok.NonNull;
import lombok.ToString;
+import org.jetbrains.annotations.NotNull;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -44,12 +46,12 @@ public class LifecycleStateActive extends LifecycleStateRunning {
}
@Override
- protected boolean stateChangeToActive(PdpStateChange change) {
+ protected boolean stateChangeToActive(@NotNull PdpStateChange change) {
return fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS, null));
}
@Override
- protected boolean stateChangeToPassive(PdpStateChange change) {
+ protected boolean stateChangeToPassive(@NotNull PdpStateChange change) {
undeployPolicies(Collections.emptyList());
fsm.transitionToAction(new LifecycleStatePassive(fsm));
return fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS, null));
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index db4f23d8..fc62b947 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Bell Canada.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,10 +157,10 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
failedPolicies.addAll(results.getRight());
// If there are *new* native controller policies deployed, there may
- // existing native artifact policies (previous to the update event
+ // be existing native artifact policies (previous to the update event
// processing) that would need to be reapplied. This requires
// going through the list of those native artifact policies that
- // were neither deployed or undeployed and re-apply them on top
+ // were neither deployed nor undeployed and re-apply them on top
// of the controllers.
failedPolicies.addAll(reApplyNativeArtifactPolicies(activePoliciesPreUpdate, activePoliciesPreUpdateMap));
@@ -169,7 +169,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
// non-native policies (previous to the update event processing)
// that will need to be reapplied as the new controllers don't know about them.
// This requires going through the list of those non-native policies
- // which neither were undeployed or deployed and re-apply them on top of the
+ // which neither were undeployed nor deployed and re-apply them on top of the
// new "brained" controllers.
failedPolicies.addAll(reApplyNonNativePolicies(activePoliciesPreUpdateMap));
@@ -228,11 +228,11 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
return Collections.emptyList();
}
- // need to re-apply non native policies
+ // need to re-apply non-native policies
// get the non-native policies to be reapplied, this is just the intersection of
- // the original active set, and the new active set (i.e policies that have not changed,
- // or in other words, have not been neither deployed or undeployed.
+ // the original active set, and the new active set (i.e. policies that have not changed,
+ // or in other words, have not been deployed or undeployed).
List<ToscaPolicy> preNonNativePolicies = fsm.getNonNativePolicies(preActivePoliciesMap);
preNonNativePolicies.retainAll(fsm.getNonNativePolicies(activePoliciesByType));
@@ -262,8 +262,8 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
// need to re-apply native artifact policies
// get the native artifact policies to be reapplied, this is just the intersection of
- // the original active set, and the new active set (i.e policies that have not changed,
- // or in other words, have not been neither deployed or undeployed).
+ // the original active set, and the new active set (i.e. policies that have not changed,
+ // or in other words, have not been deployed or undeployed).
List<ToscaPolicy> preNativeArtifactPolicies = fsm.getNativeArtifactPolicies(preActivePoliciesMap);
preNativeArtifactPolicies.retainAll(fsm.getNativeArtifactPolicies(activePoliciesByType));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
index 90c0d94c..3fa8ac9f 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,34 +69,34 @@ public class LifecycleFsmUpdateTest {
private static final String EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME = "example.controller";
private static final String EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON =
- "src/test/resources/tosca-policy-native-controller-example.json";
+ "src/test/resources/tosca-policy-native-controller-example.json";
private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_NAME = "example.artifact";
private static final String EXAMPLE_NATIVE_ARTIFACT_POLICY_JSON =
- "src/test/resources/tosca-policy-native-artifact-example.json";
+ "src/test/resources/tosca-policy-native-artifact-example.json";
private static final String EXAMPLE_OTHER_UNVAL_POLICY_NAME = "other-unvalidated";
private static final String EXAMPLE_OTHER_UNVAL_POLICY_JSON =
- "src/test/resources/tosca-policy-other-unvalidated.json";
+ "src/test/resources/tosca-policy-other-unvalidated.json";
private static final String EXAMPLE_OTHER_VAL_POLICY_NAME = "other-validated";
private static final String EXAMPLE_OTHER_VAL_POLICY_JSON = "src/test/resources/tosca-policy-other-validated.json";
private static final String FOO_NATIVE_CONTROLLER_POLICY_NAME = "foo.controller";
private static final String FOO_NATIVE_CONTROLLER_POLICY_JSON =
- "src/test/resources/tosca-policy-native-controller-foo.json";
+ "src/test/resources/tosca-policy-native-controller-foo.json";
private static final String FOO_NATIVE_ARTIFACT_POLICY_NAME = "foo.artifact";
private static final String FOO_NATIVE_ARTIFACT_POLICY_JSON =
- "src/test/resources/tosca-policy-native-artifact-foo.json";
+ "src/test/resources/tosca-policy-native-artifact-foo.json";
private static final String VCPE_OP_POLICY_NAME = "operational.restart";
private static final String VCPE_OPERATIONAL_DROOLS_POLICY_JSON =
- "policies/vCPE.policy.operational.input.tosca.json";
+ "policies/vCPE.policy.operational.input.tosca.json";
private static final String VFW_OP_POLICY_NAME = "operational.modifyconfig";
private static final String VFW_OPERATIONAL_DROOLS_POLICY_JSON =
- "policies/vFirewall.policy.operational.input.tosca.json";
+ "policies/vFirewall.policy.operational.input.tosca.json";
private static final StandardCoder coder = new StandardCoder();
@@ -156,9 +156,9 @@ public class LifecycleFsmUpdateTest {
NoopTopicFactories.getSinkFactory().destroy();
try {
Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
- "lifecycle-controller.properties.bak"));
+ "lifecycle-controller.properties.bak"));
Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
- "foo-controller.properties.bak"));
+ "foo-controller.properties.bak"));
} catch (IOException ignored) { // NOSONAR
// checkstyle
}
@@ -198,7 +198,7 @@ public class LifecycleFsmUpdateTest {
opPolicy = getExamplesPolicy(VFW_OPERATIONAL_DROOLS_POLICY_JSON, VFW_OP_POLICY_NAME);
op2Policy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, VCPE_OP_POLICY_NAME);
controllerPolicy =
- getPolicyFromFile(EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON, EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME);
+ getPolicyFromFile(EXAMPLE_NATIVE_CONTROLLER_POLICY_JSON, EXAMPLE_NATIVE_CONTROLLER_POLICY_NAME);
controller2Policy = getPolicyFromFile(FOO_NATIVE_CONTROLLER_POLICY_JSON, FOO_NATIVE_CONTROLLER_POLICY_NAME);
artifactPolicy = getPolicyFromFile(EXAMPLE_NATIVE_ARTIFACT_POLICY_JSON, EXAMPLE_NATIVE_ARTIFACT_POLICY_NAME);
artifact2Policy = getExamplesPolicy(FOO_NATIVE_ARTIFACT_POLICY_JSON, FOO_NATIVE_ARTIFACT_POLICY_NAME);
@@ -212,16 +212,16 @@ public class LifecycleFsmUpdateTest {
// native controller policy - deploy
// Delta: +controllerPolicy
- deltaUpdate(List.of(controllerPolicy), List.of(), List.of(controllerPolicy), 1, 1, 0, 0, 0, 0);
+ deltaUpdate(List.of(controllerPolicy), List.of(), List.of(controllerPolicy));
// no policies - undeploy
// Delta: -controllerPolicy
- deltaUpdate(List.of(), List.of(controllerPolicy), List.of(), 1, 1, 0, 1, 1, 0);
+ deltaUpdate(List.of(), List.of(controllerPolicy), List.of());
// native controller + artifact policy (out of order) - deploy
// Delta: +artifactPolicy, +controllerPolicy
- deltaUpdate(List.of(artifactPolicy, controllerPolicy), List.of(), List.of(artifactPolicy, controllerPolicy), 3,
- 3, 0, 1, 1, 0);
+ deltaUpdate(List.of(artifactPolicy, controllerPolicy), List.of(),
+ List.of(artifactPolicy, controllerPolicy));
// attempt to deploy opPolicy but invalid controller
// Delta: +opPolicy
@@ -229,29 +229,28 @@ public class LifecycleFsmUpdateTest {
assertEquals(1, PolicyControllerConstants.getFactory().inventory().size());
assertFalse(fsm.getActivePolicies().contains(opPolicy));
verifyExists(false, "lifecycle", List.of(opPolicy));
- verifyDeploy(List.of(artifactPolicy, controllerPolicy), 4, 3, 1, 1, 1, 0);
+ verifyDeploy(List.of(artifactPolicy, controllerPolicy));
// Delta: +opPolicy
opPolicy.getProperties().remove("controllerName");
- deltaUpdate(List.of(opPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy), 5, 4, 1, 1, 1,
- 0);
+ deltaUpdate(List.of(opPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: -opPolicy
- deltaUpdate(List.of(), List.of(opPolicy), List.of(controllerPolicy, artifactPolicy), 5, 4, 1, 2, 2, 0);
+ deltaUpdate(List.of(), List.of(opPolicy), List.of(controllerPolicy, artifactPolicy));
assertFalse(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().exists(opPolicy));
// Delta: -artifactPolicy
- deltaUpdate(List.of(), List.of(artifactPolicy), List.of(controllerPolicy), 5, 4, 1, 3, 3, 0);
+ deltaUpdate(List.of(), List.of(artifactPolicy), List.of(controllerPolicy));
assertFalse(PolicyControllerConstants.getFactory().get("lifecycle").getDrools().isBrained());
// Delta: -controllerPolicy
- deltaUpdate(List.of(), List.of(controllerPolicy), List.of(), 5, 4, 1, 4, 4, 0);
+ deltaUpdate(List.of(), List.of(controllerPolicy), List.of());
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("lifecycle"));
// Delta: +controllerPolicy, +artifactPolicy, and +opPolicy
deltaUpdate(List.of(opPolicy, artifactPolicy, controllerPolicy), List.of(),
- List.of(opPolicy, artifactPolicy, controllerPolicy), 8, 7, 1, 4, 4, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: -artifactPolicy
@@ -261,8 +260,7 @@ public class LifecycleFsmUpdateTest {
// Delta: +artifactPolicy
// from deltas, all delta updates should be successfully applied
- deltaUpdate(List.of(artifactPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy), 9, 8, 1, 5,
- 5, 0);
+ deltaUpdate(List.of(artifactPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: -controllerPolicy
@@ -272,30 +270,27 @@ public class LifecycleFsmUpdateTest {
// Delta: +controllerPolicy
// from deltas, all delta updates should be successfully applied
- deltaUpdate(List.of(controllerPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy), 10, 9, 1,
- 6, 6, 0);
+ deltaUpdate(List.of(controllerPolicy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy));
// Delta: +op2Policy, +controller2Policy
// from deltas, all delta updates should be successfully applied
op2Policy.getProperties().put("controllerName", "lifecycle");
deltaUpdate(List.of(op2Policy, controller2Policy), List.of(),
- List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy), 12, 11, 1, 6, 6, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy));
assertFalse(PolicyControllerConstants.getFactory().get("foo").getDrools().isBrained());
// same operation with duplicates - idempotent operation
deltaUpdate(List.of(op2Policy, controller2Policy, opPolicy), List.of(valPolicy, unvalPolicy),
- List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy), 12, 11, 1, 6, 6, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy));
assertFalse(PolicyControllerConstants.getFactory().get("foo").getDrools().isBrained());
// Delta: +artifact2policy, +valPolicy, +unvalPolicy
// from deltas, all delta updates should be successfully applied
- deltaUpdate(
- List.of(valPolicy, unvalPolicy, artifact2Policy), List.of(), List.of(opPolicy, artifactPolicy,
- controllerPolicy, op2Policy, controller2Policy, valPolicy, unvalPolicy, artifact2Policy),
- 15, 14, 1, 6, 6, 0);
+ deltaUpdate(List.of(valPolicy, unvalPolicy, artifact2Policy), List.of(), List.of(opPolicy, artifactPolicy,
+ controllerPolicy, op2Policy, controller2Policy, valPolicy, unvalPolicy, artifact2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy, valPolicy, unvalPolicy));
verifyExists(true, "foo", List.of(valPolicy, unvalPolicy));
verifyExists(false, "foo", List.of(opPolicy, op2Policy));
@@ -303,8 +298,7 @@ public class LifecycleFsmUpdateTest {
// Delta: -artifact2Policy, -unvalPolicy
// from deltas, all delta updates should be successfully applied, and unvalPolicy disabled
deltaUpdate(List.of(), List.of(artifact2Policy, unvalPolicy),
- List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy, valPolicy), 15, 14, 1,
- 8, 8, 0);
+ List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy, controller2Policy, valPolicy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy, valPolicy));
verifyExists(false, "lifecycle", List.of(unvalPolicy));
assertFalse(PolicyControllerConstants.getFactory().get("foo").getDrools().isBrained());
@@ -314,7 +308,7 @@ public class LifecycleFsmUpdateTest {
// should be re-applied.
assertTrue(fsm.update(getPdpUpdate(List.of(artifact2Policy), List.of())));
deltaUpdate(List.of(artifact2Policy), List.of(), List.of(opPolicy, artifactPolicy, controllerPolicy, op2Policy,
- controller2Policy, valPolicy, artifact2Policy), 16, 15, 1, 8, 8, 0);
+ controller2Policy, valPolicy, artifact2Policy));
verifyExists(true, "lifecycle", List.of(opPolicy, op2Policy, valPolicy));
verifyExists(false, "lifecycle", List.of(unvalPolicy));
verifyExists(true, "foo", List.of(valPolicy));
@@ -329,18 +323,18 @@ public class LifecycleFsmUpdateTest {
// since -controllerPolicy delta => the existing artifact2Policy, opPolicy, op2Policy become disabled as no
// policy type is readily available to host them until there is a host.
verifyActivePoliciesWithDisables(
- List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy),
- List.of(opPolicy.getIdentifier(), op2Policy.getIdentifier()));
+ List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy),
+ List.of(opPolicy.getIdentifier(), op2Policy.getIdentifier()));
// Delta: -opPolicy, -op2Policy, -controller2Policy, -valPolicy, -artifact2Policy, -unvalPolicy
- // from deltas, -opPolicy and -op2Policy undeploys will fail since there is not controller with that
+ // from deltas, -opPolicy and -op2Policy undeploys will fail since there is no controller with that
// policy type supported
assertFalse(fsm.update(getPdpUpdate(List.of(),
- List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy))));
+ List.of(opPolicy, op2Policy, controller2Policy, valPolicy, artifact2Policy, unvalPolicy))));
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("lifecycle"));
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("foo"));
assertEquals(0, PolicyControllerConstants.getFactory().inventory().size());
- verifyDeploy(List.of(), 17, 16, 1, 16, 14, 2);
+ verifyDeploy(List.of());
fsm.shutdown();
}
@@ -361,15 +355,13 @@ public class LifecycleFsmUpdateTest {
return update;
}
- protected void deltaUpdate(List<ToscaPolicy> deploy, List<ToscaPolicy> undeploy, List<ToscaPolicy> active,
- long deployCount, long deploySuccess, long deployFail, long undeployCount, long undeploySuccess,
- long undeployFail) throws CoderException {
+ protected void deltaUpdate(List<ToscaPolicy> deploy, List<ToscaPolicy> undeploy, List<ToscaPolicy> active)
+ throws CoderException {
assertTrue(fsm.update(getPdpUpdate(deploy, undeploy)));
- verifyDeploy(active, deployCount, deploySuccess, deployFail, undeployCount, undeploySuccess, undeployFail);
+ verifyDeploy(active);
}
- private void verifyDeploy(List<ToscaPolicy> active, long deployCount, long deploySuccess, long deployFail,
- long undeployCount, long undeploySuccess, long undeployFail) throws CoderException {
+ private void verifyDeploy(List<ToscaPolicy> active) throws CoderException {
verifyActivePolicies(active);
}
@@ -377,7 +369,7 @@ public class LifecycleFsmUpdateTest {
assertTrue(PolicyControllerConstants.getFactory().get(controller).getDrools().isBrained());
for (ToscaPolicy policy : policies) {
assertEquals("ID: " + controller + ":" + policy.getIdentifier(), exists,
- PolicyControllerConstants.getFactory().get(controller).getDrools().exists(policy));
+ PolicyControllerConstants.getFactory().get(controller).getDrools().exists(policy));
}
}
@@ -386,14 +378,14 @@ public class LifecycleFsmUpdateTest {
}
protected void verifyActivePoliciesWithDisables(List<ToscaPolicy> testPolicies,
- List<ToscaConceptIdentifier> nativeDisables) throws CoderException {
+ List<ToscaConceptIdentifier> nativeDisables) throws CoderException {
// verify that each policy is tracked in the active lists
for (ToscaPolicy policy : testPolicies) {
assertTrue(policy.getIdentifier().toString(), fsm.getActivePolicies().contains(policy));
if (!nativeDisables.contains(policy.getIdentifier())) {
assertTrue(policy.getIdentifier().toString(),
- fsm.getPolicyTypesMap().containsKey(policy.getTypeIdentifier()));
+ fsm.getPolicyTypesMap().containsKey(policy.getTypeIdentifier()));
}
}
assertEquals(testPolicies.size(), fsm.getActivePolicies().size());
@@ -407,7 +399,7 @@ public class LifecycleFsmUpdateTest {
// verify that a controller exists for each controller policy
assertEquals(fsm.getNativeControllerPolicies(testPoliciesMap).size(),
- PolicyControllerConstants.getFactory().inventory().size());
+ PolicyControllerConstants.getFactory().inventory().size());
// verify that a brained controller with same application coordinates exist for
// each native artifact policy
@@ -428,21 +420,21 @@ public class LifecycleFsmUpdateTest {
String controllerName = artifactPolicy.getProperties().getController().getName();
assertTrue(PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
assertEquals(artifactPolicy.getProperties().getRulesArtifact().getGroupId(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().getGroupId());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().getGroupId());
assertEquals(artifactPolicy.getProperties().getRulesArtifact().getArtifactId(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().getArtifactId());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().getArtifactId());
assertEquals(artifactPolicy.getProperties().getRulesArtifact().getVersion(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().getVersion());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().getVersion());
}
}
protected void verifyNonNativePolicy(ToscaPolicy testPolicy, List<ToscaConceptIdentifier> nativeDisables)
- throws CoderException {
+ throws CoderException {
List<ToscaPolicy> nativeArtifactPolicies =
- fsm.getNativeArtifactPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
+ fsm.getNativeArtifactPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
List<ToscaPolicy> nativeControllerPolicies =
- fsm.getNativeControllerPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
+ fsm.getNativeControllerPolicies(fsm.groupPoliciesByPolicyType(fsm.getActivePolicies()));
String controllerName = (String) testPolicy.getProperties().get("controllerName");
@@ -454,21 +446,21 @@ public class LifecycleFsmUpdateTest {
for (ToscaPolicy nativePolicy : nativeArtifactPolicies) {
NativeArtifactPolicy artifactPolicy =
- fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
+ fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
String artifactControllerName = artifactPolicy.getProperties().getController().getName();
// brained controller check
assertTrue(artifactControllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(artifactControllerName).getDrools().isBrained());
+ PolicyControllerConstants.getFactory().get(artifactControllerName).getDrools().isBrained());
// non native tosca policy as a fact in drools
if (PolicyControllerConstants.getFactory().get(artifactControllerName).getPolicyTypes()
- .contains(testPolicy.getTypeIdentifier())) {
+ .contains(testPolicy.getTypeIdentifier())) {
assertTrue(artifactControllerName + ":" + testPolicy.getIdentifier(), PolicyControllerConstants
- .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
+ .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
} else {
assertFalse(artifactControllerName + ":" + testPolicy.getIdentifier(), PolicyControllerConstants
- .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
+ .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
}
// there should always be a controller policy for each artifact policy
@@ -493,13 +485,13 @@ public class LifecycleFsmUpdateTest {
// verify the policy is present as a fact if there is matching artifact policy
List<NativeArtifactPolicy> candidateNativeArtifactPolicies =
- getNativeArtifactPolicies(nativeArtifactPolicies, controllerName);
+ getNativeArtifactPolicies(nativeArtifactPolicies, controllerName);
if (candidateNativeArtifactPolicies.size() == 1) {
assertTrue(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
assertTrue(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().exists(testPolicy));
+ PolicyControllerConstants.getFactory().get(controllerName).getDrools().exists(testPolicy));
// verify that the other brained controllers don't have this non-native policy
@@ -522,11 +514,11 @@ public class LifecycleFsmUpdateTest {
// at this point the only valid possibility is that there is no native artifact policies
assertTrue("There is more than 1 native artifact policy for " + controllerName,
- candidateNativeArtifactPolicies.isEmpty());
+ candidateNativeArtifactPolicies.isEmpty());
}
protected List<NativeArtifactPolicy> getNativeArtifactPoliciesBut(List<ToscaPolicy> nativePolicies,
- String controllerName) {
+ String controllerName) {
return nativePolicies.stream().map(nativePolicy -> {
try {
return fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
@@ -534,11 +526,11 @@ public class LifecycleFsmUpdateTest {
throw new RuntimeException(nativePolicy.getIdentifier().toString(), ex);
}
}).filter(nativeArtifactPolicy -> !controllerName
- .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
+ .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
}
protected List<NativeArtifactPolicy> getNativeArtifactPolicies(List<ToscaPolicy> nativePolicies,
- String controllerName) {
+ String controllerName) {
return nativePolicies.stream().map(nativePolicy -> {
try {
return fsm.getDomainMaker().convertTo(nativePolicy, NativeArtifactPolicy.class);
@@ -546,11 +538,11 @@ public class LifecycleFsmUpdateTest {
throw new RuntimeException(nativePolicy.getIdentifier().toString(), ex);
}
}).filter(nativeArtifactPolicy -> controllerName
- .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
+ .equals(nativeArtifactPolicy.getProperties().getController().getName())).collect(Collectors.toList());
}
protected List<ControllerPolicy> getNativeControllerPolicies(List<ToscaPolicy> nativePolicies,
- String controllerName) {
+ String controllerName) {
return nativePolicies.stream().map(controllerPolicy -> {
try {
return fsm.getDomainMaker().convertTo(controllerPolicy, ControllerPolicy.class);