summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test/java
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2020-08-24 20:04:52 -0500
committerjhh <jorge.hernandez-herrero@att.com>2020-08-25 10:54:58 -0500
commit5c71b5a62f4208030b3c3cd18b3f42398a0a86e5 (patch)
tree482c785dae07a441e2a30176c1faf8ff8b62e3d8 /feature-lifecycle/src/test/java
parent13d8a3204013f1c0bc02ddede96ab37ac3d64129 (diff)
block status operations until controllers ready
Status messages to the PAP won't be send until all mandatory resources specified in the lifecycle.pdp.policytypes property are functional. Issue-ID: POLICY-2669 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ia9d4c678fcfbdb232059d0827235845ee11f1201 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/test/java')
-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
2 files changed, 22 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));