diff options
Diffstat (limited to 'feature-lifecycle/src/test/java')
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)); |