diff options
author | Jim Hahn <jrh3@att.com> | 2020-11-10 10:12:53 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-11-10 10:34:18 -0500 |
commit | fece3044e254866abd948629b05107f0de6b9ba2 (patch) | |
tree | b5009c0cdaa049f29401532d1ec7f2ef935381f1 /controlloop/common | |
parent | 3e73215bd626d5508a25f6cd8edd11455d965254 (diff) |
Allow mixed case in check of prov-status
Apparently SO/AAI in Frankfurt are setting the prov-status to "active"
instead of "ACTIVE". Modified the code to ignore case when comparing.
Issue-ID: POLICY-2890-prov-status
Change-Id: Ibe2bcf451dcdc05361f40d2c5c5146eb6a9cb620
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common')
4 files changed, 33 insertions, 6 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 6e88ce982..08cd82fda 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -768,8 +768,9 @@ public class ControlLoopEventManager implements Serializable { */ protected static boolean isProvStatusInactive(VirtualControlLoopEvent event) { Map<String, String> aai = event.getAai(); - return (!PROV_STATUS_ACTIVE.equals(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE)) - || !PROV_STATUS_ACTIVE.equals(aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE))); + return (!PROV_STATUS_ACTIVE.equalsIgnoreCase(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE)) + || !PROV_STATUS_ACTIVE.equalsIgnoreCase( + aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE))); } /** diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java index 5f611c098..b3bd2e347 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java @@ -554,8 +554,9 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { */ private static boolean isProvStatusInactive(VirtualControlLoopEvent event) { Map<String, String> aai = event.getAai(); - return !(PROV_STATUS_ACTIVE.equals(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE)) - && PROV_STATUS_ACTIVE.equals(aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE))); + return !(PROV_STATUS_ACTIVE.equalsIgnoreCase(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE)) + && PROV_STATUS_ACTIVE.equalsIgnoreCase( + aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE))); } /** diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java index d09c2c88b..e38ef2f4e 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java @@ -193,6 +193,19 @@ public class ControlLoopEventManager2Test { assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) .hasMessage("prov-status is not ACTIVE on VServer or VNF"); + // test with both prov-status flags, with mixed case + event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_PROV_STATUS, "ACTIVE")); + assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + + event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_PROV_STATUS, "active")); + assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + + event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "ACTIVE")); + assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + + event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "active")); + assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); + // valid event.setAai(orig); assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException(); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index db16c4528..7c89f1897 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -733,13 +733,25 @@ public class ControlLoopEventManagerTest { aai.remove(ControlLoopEventManager.VSERVER_PROV_STATUS); assertFalse(ControlLoopEventManager.isProvStatusInactive(onset)); + // null, ACTIVE + aai.remove(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS); + aai.put(ControlLoopEventManager.VSERVER_PROV_STATUS, ControlLoopEventManager.PROV_STATUS_ACTIVE.toUpperCase()); + assertFalse(ControlLoopEventManager.isProvStatusInactive(onset)); + // null, active aai.remove(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS); - aai.put(ControlLoopEventManager.VSERVER_PROV_STATUS, ControlLoopEventManager.PROV_STATUS_ACTIVE); + aai.put(ControlLoopEventManager.VSERVER_PROV_STATUS, ControlLoopEventManager.PROV_STATUS_ACTIVE.toLowerCase()); + assertFalse(ControlLoopEventManager.isProvStatusInactive(onset)); + + // ACTIVE, null + aai.put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, + ControlLoopEventManager.PROV_STATUS_ACTIVE.toUpperCase()); + aai.remove(ControlLoopEventManager.VSERVER_PROV_STATUS); assertFalse(ControlLoopEventManager.isProvStatusInactive(onset)); // active, null - aai.put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, ControlLoopEventManager.PROV_STATUS_ACTIVE); + aai.put(ControlLoopEventManager.GENERIC_VNF_PROV_STATUS, + ControlLoopEventManager.PROV_STATUS_ACTIVE.toLowerCase()); aai.remove(ControlLoopEventManager.VSERVER_PROV_STATUS); assertFalse(ControlLoopEventManager.isProvStatusInactive(onset)); |