Merge "Remove m2 model from drools-apps"
diff --git a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java
index 0baac9e..7c34fc8 100644
--- a/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java
+++ b/controlloop/common/rules-test/src/main/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTest.java
@@ -88,6 +88,7 @@
     // VDNS
     private static final String VDNS_TOSCA_LEGACY_POLICY = "vdns/tosca-legacy-vdns.json";
     private static final String VDNS_TOSCA_COMPLIANT_POLICY = "vdns/tosca-compliant-vdns.json";
+    private static final String VDNS_TOSCA_COMPLIANT_RAINY_POLICY = "vdns/tosca-compliant-vdns-rainy.json";
     private static final String VDNS_ONSET = "vdns/vdns.onset.json";
 
     // VFW
@@ -334,6 +335,15 @@
         httpSunnyDay(VDNS_TOSCA_COMPLIANT_POLICY, VDNS_ONSET);
     }
 
+    /**
+      * Vdns Rainy Day with Compliant Tosca Policy.
+      */
+    @Test
+    public void testVdnsRainyDayCompliant() {
+        httpRainyDay(VDNS_TOSCA_COMPLIANT_RAINY_POLICY, VDNS_ONSET);
+    }
+
+
     // VFW
 
     /**
@@ -647,6 +657,33 @@
         waitForFinalSuccess(policy, policyClMgt);
     }
 
+    /**
+     * Rainy day scenario for use cases that use an HTTP simulator.
+     *
+     * @param policyFile file containing the ToscaPolicy to be loaded
+     * @param onsetFile file containing the ONSET to be injected
+     * @param operation expected APPC operation request
+     */
+    protected void httpRainyDay(String policyFile, String onsetFile) {
+        policyClMgt = topics.createListener(POLICY_CL_MGT_TOPIC, VirtualControlLoopNotification.class, controller);
+
+        assertEquals(0, controller.getDrools().factCount(rules.getControllerName()));
+        policy = rules.setupPolicyFromFile(policyFile);
+        assertEquals(2, controller.getDrools().factCount(rules.getControllerName()));
+
+        /* Inject an ONSET event over the DCAE topic */
+        topics.inject(DCAE_TOPIC, onsetFile);
+
+        /* Wait to acquire a LOCK and a PDP-X PERMIT */
+        waitForLockAndPermit(policy, policyClMgt);
+
+        /* --- Operation Completed --- */
+        waitForOperationFailure();
+
+        /* --- Transaction Completed --- */
+        waitForFinalFailure(policy, policyClMgt);
+    }
+
     protected long getCreateCount() {
         return ControlLoopEventManager2.getCreateCount();
     }
diff --git a/controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json b/controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json
new file mode 100644
index 0000000..53fd5f1
--- /dev/null
+++ b/controlloop/common/rules-test/src/main/resources/vdns/tosca-compliant-vdns-rainy.json
@@ -0,0 +1,48 @@
+{
+    "type": "onap.policies.controlloop.operational.common.Drools",
+    "type_version": "1.0.0",
+    "version": "1.0.0",
+    "name": "operational.scale.up",
+    "metadata": {
+        "policy-id": "operational.scale.up"
+    },
+    "properties": {
+        "controllerName": "usecases",
+        "id": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
+        "timeout": 60,
+        "abatement": false,
+        "trigger": "unique-policy-id-1-scale-up",
+        "operations": [
+            {
+                "id": "unique-policy-id-1-scale-up",
+                "description": "Scale up",
+                "operation": {
+                    "actor": "SO",
+                    "operation": "VF Module Create",
+                    "target": {
+                        "targetType": "VFMODULE",
+                        "entityIds": {
+                            "modelInvariantId": "e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e",
+                            "modelVersionId": "94b18b1d-cc91-4f43-911a-e6348665f292",
+                            "modelName": "VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0",
+                            "modelVersion": 1,
+                            "modelCustomizationId": "47958575-138f-452a-8c8d-d89b595f8164"
+                        }
+                    },
+                    "payload": {
+                        "requestParameters": "{\"usePreload\":true,\"userParams\":[{\"failure\" : \"FAIL\"}]}",
+                        "configurationParameters": "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[9]\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[23]\"}]"
+                    }
+                },
+                "timeout": 30,
+                "retries": 0,
+                "success": "final_success",
+                "failure": "final_failure",
+                "failure_timeout": "final_failure_timeout",
+                "failure_retries": "final_failure_retries",
+                "failure_exception": "final_failure_exception",
+                "failure_guard": "final_failure_guard"
+            }
+        ]
+    }
+}
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java
index cfa9c49..9f313ca 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseRuleTestTest.java
@@ -334,6 +334,11 @@
     }
 
     @Test
+    public void testTestVdnsRainyDayCompliant() {
+        checkHttpPolicyCompliantFailure(base::testVdnsRainyDayCompliant);
+    }
+
+    @Test
     public void testTestVfwSunnyDayLegacy() {
         checkAppcLegacyPolicy("ModifyConfig", base::testVfwSunnyDayLegacy);
     }
@@ -491,6 +496,21 @@
         verify(topics).inject(eq(BaseRuleTest.DCAE_TOPIC), any());
     }
 
+    protected void checkHttpPolicyCompliantFailure(Runnable test) {
+        enqueueClMgt(ControlLoopNotificationType.OPERATION_FAILURE);
+        enqueueClMgt(ControlLoopNotificationType.FINAL_FAILURE);
+
+        test.run();
+
+        assertEquals(1, permitCount);
+        assertEquals(1, finalCount);
+
+        assertTrue(clMgtQueue.isEmpty());
+
+        // initial event
+        verify(topics).inject(eq(BaseRuleTest.DCAE_TOPIC), any());
+    }
+
     private void enqueueClMgt(ControlLoopNotificationType type) {
         VirtualControlLoopNotification notif = new VirtualControlLoopNotification();
         notif.setNotification(type);