summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'feature-lifecycle/src/test')
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java18
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java8
-rw-r--r--feature-lifecycle/src/test/resources/feature-lifecycle.properties1
3 files changed, 23 insertions, 4 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
index 49e439d9..2b0e65bf 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
@@ -23,6 +23,7 @@ package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -32,6 +33,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
@@ -83,6 +85,22 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
}
@Test
+ public void testMandatoryPolicyTypes() {
+ assertEquals(Set.of("onap.policies.native.drools.Artifact", "onap.policies.native.drools.Controller"),
+ fsm.getMandatoryPolicyTypes());
+ assertEquals(fsm.getMandatoryPolicyTypes(), fsm.getCurrentPolicyTypes());
+ assertTrue(fsm.isMandatoryPolicyTypesCompliant());
+ assertTrue(fsm.status());
+
+ fsm.mandatoryPolicyTypes.add("blah");
+ assertEquals(Set.of("onap.policies.native.drools.Artifact", "onap.policies.native.drools.Controller", "blah"),
+ fsm.getMandatoryPolicyTypes());
+ assertNotEquals(fsm.getMandatoryPolicyTypes(), fsm.getCurrentPolicyTypes());
+ assertFalse(fsm.isMandatoryPolicyTypesCompliant());
+ assertFalse(fsm.status());
+ }
+
+ @Test
public void testUpdatePolicies() throws IOException, CoderException {
assertEquals(2, fsm.policyTypesMap.size());
assertNotNull(fsm.getPolicyTypesMap().get(
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index e8a9c825..39a3a939 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -205,7 +205,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
ToscaPolicy toscaPolicyRestartV1 =
getExamplesPolicy("policies/vCPE.policy.operational.input.tosca.json", "operational.restart");
toscaPolicyRestartV1.getProperties().put("controllerName", "lifecycle");
- update.setPolicies(Arrays.asList(toscaPolicyRestartV1));
+ update.setPolicies(Collections.singletonList(toscaPolicyRestartV1));
int qlength = fsm.client.getSink().getRecentEvents().length;
@@ -260,7 +260,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
// redeploy operational.restart policy
- update.setPolicies(Arrays.asList(toscaPolicyRestartV1));
+ update.setPolicies(Collections.singletonList(toscaPolicyRestartV1));
assertTrue(fsm.update(update));
assertEquals(qlength + 4, fsm.client.getSink().getRecentEvents().length);
assertEquals(3, fsm.policyTypesMap.size());
@@ -279,7 +279,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
getExamplesPolicy("policies/vCPE.policy.operational.input.tosca.json", "operational.restart");
toscaPolicyRestartV2.setVersion("2.0.0");
toscaPolicyRestartV2.getProperties().put("controllerName", "lifecycle");
- update.setPolicies(Arrays.asList(toscaPolicyRestartV2));
+ update.setPolicies(Collections.singletonList(toscaPolicyRestartV2));
assertTrue(fsm.update(update));
assertEquals(qlength + 5, fsm.client.getSink().getRecentEvents().length);
assertEquals(3, fsm.policyTypesMap.size());
@@ -327,7 +327,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
String badIntegerPolicy =
Files.readString(Paths.get(POLICY_COMPLIANT_VCPE_BAD_INTEGER_JSON), StandardCharsets.UTF_8);
ToscaPolicy toscaPolicyRestartBad = new StandardCoder().decode(badIntegerPolicy, ToscaPolicy.class);
- update.setPolicies(Arrays.asList(toscaPolicyRestartBad));
+ update.setPolicies(Collections.singletonList(toscaPolicyRestartBad));
assertFalse(fsm.update(update));
assertTrue(controllerSupport.getController().getDrools().delete(ToscaPolicy.class));
diff --git a/feature-lifecycle/src/test/resources/feature-lifecycle.properties b/feature-lifecycle/src/test/resources/feature-lifecycle.properties
index 0c80ed45..052b0165 100644
--- a/feature-lifecycle/src/test/resources/feature-lifecycle.properties
+++ b/feature-lifecycle/src/test/resources/feature-lifecycle.properties
@@ -17,6 +17,7 @@
# ============LICENSE_END=========================================================
lifecycle.pdp.group=${envd:POLICY_PDP_PAP_GROUP:defaultGroup}
+lifecycle.pdp.policytypes=${envd:POLICY_PDP_PAP_POLICYTYPES:onap.policies.native.drools.Controller,onap.policies.native.drools.Artifact}
noop.source.topics=POLICY-PDP-PAP
noop.sink.topics=POLICY-PDP-PAP