diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2022-02-14 11:06:52 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2022-02-14 11:06:52 -0600 |
commit | e9d1d70a203d06c3f0e4695c3710b527b0a6eab3 (patch) | |
tree | 3dcce9b90f2a572dd712e1f1586eaf4d22e15e03 /feature-lifecycle/src/test | |
parent | 355bc6f553089e93e87c64e85c435c13ce6fcf88 (diff) |
Handle metadata policy-id as object
Issue-ID: POLICY-3832
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I60b4c3b9f8d6f74161d2e9532b3c3adba10cdc6b
Diffstat (limited to 'feature-lifecycle/src/test')
2 files changed, 20 insertions, 13 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java index df9e5eed..0ad776cc 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2021-2022 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,7 @@ import java.nio.file.Paths; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import org.junit.AfterClass; import org.junit.Before; @@ -259,17 +260,23 @@ public class LifecycleFsmTest { fsm.deployedPolicyAction(opPolicy); fsm.deployedPolicyAction(controllerPolicy); - assertEquals(List.of(opPolicy, controllerPolicy), fsm.getActivePolicies()); - assertEquals(List.of(opPolicy, controllerPolicy), fsm.mergePolicies(List.of(), List.of())); - assertEquals(List.of(opPolicy), fsm.mergePolicies(List.of(), List.of(controllerPolicy.getIdentifier()))); - - assertEquals(List.of(controllerPolicy, op2Policy, valPolicy, opPolicy, unvalPolicy), - fsm.mergePolicies(List.of(op2Policy, valPolicy, unvalPolicy), List.of())); - assertEquals(List.of(controllerPolicy, op2Policy, valPolicy, opPolicy, unvalPolicy), - fsm.mergePolicies(List.of(controllerPolicy, opPolicy, op2Policy, valPolicy, unvalPolicy), List.of())); - assertEquals(List.of(op2Policy, valPolicy, unvalPolicy), - fsm.mergePolicies(List.of(op2Policy, valPolicy, unvalPolicy), - List.of(controllerPolicy.getIdentifier(), opPolicy.getIdentifier()))); + assertEquals(Set.of(opPolicy, controllerPolicy), toSet(fsm.getActivePolicies())); + assertEquals(Set.of(opPolicy, controllerPolicy), toSet(fsm.mergePolicies(List.of(), List.of()))); + assertEquals(Set.of(opPolicy), toSet(fsm.mergePolicies(List.of(), List.of(controllerPolicy.getIdentifier())))); + + assertEquals(Set.of(controllerPolicy, op2Policy, valPolicy, opPolicy, unvalPolicy), + toSet(fsm.mergePolicies(List.of(op2Policy, valPolicy, unvalPolicy), List.of()))); + assertEquals(Set.of(controllerPolicy, op2Policy, valPolicy, opPolicy, unvalPolicy), + toSet(fsm.mergePolicies(List.of(controllerPolicy, opPolicy, op2Policy, valPolicy, unvalPolicy), + List.of()))); + assertEquals(Set.of(op2Policy, valPolicy, unvalPolicy), + toSet(fsm.mergePolicies(List.of(op2Policy, valPolicy, unvalPolicy), + List.of(controllerPolicy.getIdentifier(), opPolicy.getIdentifier())))); + } + + private Set<ToscaPolicy> toSet(List<ToscaPolicy> policies) { + return Set.copyOf(policies); + } @Test diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java index cb2d5add..b8139e6e 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java @@ -254,7 +254,7 @@ public class RestLifecycleManagerTest { ToscaPolicy opPolicy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE); opPolicy.getProperties().put("controllerName", "lifecycle"); if (StringUtils.isBlank(opPolicy.getName())) { - opPolicy.setName(opPolicy.getMetadata().get("policy-id")); + opPolicy.setName("" + opPolicy.getMetadata().get("policy-id")); } testNotNativePolicy(opPolicy); |