aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/controller-usecases
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-11-10 11:39:51 -0500
committerJim Hahn <jrh3@att.com>2020-11-10 11:40:22 -0500
commit21362791e6488bb36f543f0319b195e24f239dcb (patch)
treed2b86192443b4f1a892cb533f024443e39bc38f7 /controlloop/common/controller-usecases
parent5562ff741f0eb10b4d3bd4f9e5d5632c822c332c (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-status2 Change-Id: I9e868d320dadcb3ac51570718d10f33d0011ae47 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/controller-usecases')
-rw-r--r--controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java5
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java26
2 files changed, 29 insertions, 2 deletions
diff --git a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
index d92fbcfad..091b26b2d 100644
--- a/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
+++ b/controlloop/common/controller-usecases/src/main/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManager.java
@@ -707,8 +707,9 @@ public class UsecasesEventManager extends ControlLoopEventManager implements Ste
*/
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/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
index b87e56da6..d4979fb79 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/drools/apps/controller/usecases/UsecasesEventManagerTest.java
@@ -188,10 +188,36 @@ public class UsecasesEventManagerTest {
assertThatThrownBy(() -> new UsecasesEventManager(params, event, workMem))
.hasMessage("is-closed-loop-disabled is set to true on VServer or VNF");
+ // vserver ACTIVE
+ event.setAai(addAai(orig, UsecasesConstants.VSERVER_PROV_STATUS,
+ UsecasesConstants.PROV_STATUS_ACTIVE.toUpperCase()));
+ assertThatCode(() -> new UsecasesEventManager(params, event, workMem)).doesNotThrowAnyException();
+
+ // vserver active
+ event.setAai(addAai(orig, UsecasesConstants.VSERVER_PROV_STATUS,
+ UsecasesConstants.PROV_STATUS_ACTIVE.toLowerCase()));
+ assertThatCode(() -> new UsecasesEventManager(params, event, workMem)).doesNotThrowAnyException();
+
+ // vserver inactive
event.setAai(addAai(orig, UsecasesConstants.VSERVER_PROV_STATUS, "inactive"));
assertThatThrownBy(() -> new UsecasesEventManager(params, event, workMem))
.hasMessage("prov-status is not ACTIVE on VServer or VNF");
+ // vnf ACTIVE
+ event.setAai(addAai(orig, UsecasesConstants.GENERIC_VNF_PROV_STATUS,
+ UsecasesConstants.PROV_STATUS_ACTIVE.toUpperCase()));
+ assertThatCode(() -> new UsecasesEventManager(params, event, workMem)).doesNotThrowAnyException();
+
+ // vnf active
+ event.setAai(addAai(orig, UsecasesConstants.GENERIC_VNF_PROV_STATUS,
+ UsecasesConstants.PROV_STATUS_ACTIVE.toLowerCase()));
+ assertThatCode(() -> new UsecasesEventManager(params, event, workMem)).doesNotThrowAnyException();
+
+ // vnf inactive
+ event.setAai(addAai(orig, UsecasesConstants.GENERIC_VNF_PROV_STATUS, "inactive"));
+ assertThatThrownBy(() -> new UsecasesEventManager(params, event, workMem))
+ .hasMessage("prov-status is not ACTIVE on VServer or VNF");
+
// valid
event.setAai(orig);
assertThatCode(() -> mgr.checkEventSyntax(event)).doesNotThrowAnyException();