lifecycle routing policy types to controllers.

Issue-ID: POLICY-2356
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I49585507542f41a75e4c7bde2c7be343e19038f3
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index d43357a..b37d014 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -30,6 +30,7 @@
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.NonNull;
 import lombok.Setter;
@@ -46,6 +47,7 @@
 import org.onap.policy.common.utils.coder.StandardCoderObject;
 import org.onap.policy.common.utils.network.NetworkUtil;
 import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+import org.onap.policy.drools.policies.DomainMaker;
 import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
@@ -65,6 +67,8 @@
  */
 public class LifecycleFsm implements Startable {
 
+    private static final Logger logger = LoggerFactory.getLogger(LifecycleFsm.class);
+
     protected static final String CONFIGURATION_PROPERTIES_NAME = "feature-lifecycle";
     protected static final String GROUP_NAME = "lifecycle.pdp.group";
     protected static final String DEFAULT_PDP_GROUP = "defaultGroup";
@@ -72,10 +76,17 @@
     protected static final long MIN_STATUS_INTERVAL_SECONDS = 5L;
     protected static final String PDP_MESSAGE_NAME = "messageName";
 
-    private static final Logger logger = LoggerFactory.getLogger(LifecycleFsm.class);
+    protected static final ToscaPolicyTypeIdentifier POLICY_TYPE_DROOLS_NATIVE_RULES =
+            new ToscaPolicyTypeIdentifier("onap.policies.native.Drools", "1.0.0");
+
+    protected static final ToscaPolicyTypeIdentifier POLICY_TYPE_DROOLS_CONTROLLER =
+            new ToscaPolicyTypeIdentifier("onap.policies.drools.Controller", "1.0.0");
 
     protected final Properties properties;
 
+    @Getter(AccessLevel.PACKAGE)
+    protected final DomainMaker domainMaker = new DomainMaker();
+
     protected TopicSource source;
     protected TopicSinkClient client;
 
@@ -110,7 +121,7 @@
     protected String subgroup;
 
     @Getter
-    protected final Map<ToscaPolicyTypeIdentifier, PolicyController> policyTypesMap = new HashMap<>();
+    protected final Map<ToscaPolicyTypeIdentifier, PolicyTypeController> policyTypesMap = new HashMap<>();
 
     protected final Map<ToscaPolicyIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
 
@@ -120,6 +131,13 @@
     public LifecycleFsm() {
         this.properties = SystemPersistenceConstants.getManager().getProperties(CONFIGURATION_PROPERTIES_NAME);
         this.group = this.properties.getProperty(GROUP_NAME, DEFAULT_PDP_GROUP);
+
+        this.policyTypesMap.put(
+                POLICY_TYPE_DROOLS_CONTROLLER,
+                new PolicyTypeNativeController(this, POLICY_TYPE_DROOLS_CONTROLLER));
+        this.policyTypesMap.put(
+                POLICY_TYPE_DROOLS_NATIVE_RULES,
+                 new PolicyTypeRulesController(this, POLICY_TYPE_DROOLS_NATIVE_RULES));
     }
 
     @Override
@@ -149,7 +167,7 @@
         logger.info("lifecycle event: start controller: {}", controller.getName());
         for (ToscaPolicyTypeIdentifier id : controller.getPolicyTypes()) {
             if (isToscaPolicyType(id.getName())) {
-                policyTypesMap.put(id, controller);
+                policyTypesMap.put(id, new PolicyTypeDroolsController(this, id, controller));
             }
         }
     }
@@ -263,7 +281,7 @@
         return stopTimers() && startTimers();
     }
 
-    protected PolicyController getController(ToscaPolicyTypeIdentifier policyType) {
+    protected PolicyTypeController getController(ToscaPolicyTypeIdentifier policyType) {
         return policyTypesMap.get(policyType);
     }
 
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
index 5e779b7..80d0bc7 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Bell Canada.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,21 +24,16 @@
 import java.util.Collections;
 import lombok.NonNull;
 import lombok.ToString;
-import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.enums.PdpResponseStatus;
 import org.onap.policy.models.pdp.enums.PdpState;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Lifecycle Active State.
  */
 @ToString
 public class LifecycleStateActive extends LifecycleStateRunning {
-    private static final Logger logger = LoggerFactory.getLogger(LifecycleStateActive.class);
-
     protected LifecycleStateActive(LifecycleFsm manager) {
         super(manager);
     }
@@ -61,10 +56,8 @@
     }
 
     @Override
-    protected boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
-        logger.info("{}: deploy {} into {}", this, policy.getIdentifier(), controller.getName());
-
-        if (!controller.offer(policy)) {
+    protected boolean deployPolicy(@NonNull PolicyTypeController controller, @NonNull ToscaPolicy policy) {
+        if (!controller.deploy(policy)) {
             return false;
         }
 
@@ -73,14 +66,8 @@
     }
 
     @Override
-    protected boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
-        logger.info("{}: undeploy {} from {}", this, policy.getIdentifier(), controller.getName());
-
-        if (!controller.getDrools().delete(policy)) {
-            logger.warn("Policy {}:{}:{}:{} was not deployed.",
-                policy.getType(), policy.getTypeVersion(), policy.getName(), policy.getVersion());
-        }
-
+    protected boolean undeployPolicy(@NonNull PolicyTypeController controller, @NonNull ToscaPolicy policy) {
+        controller.undeploy(policy);
         fsm.undeployedPolicyAction(policy);
         return true;
     }
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java
index b88a200..8bbdbe9 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java
@@ -22,21 +22,16 @@
 
 import lombok.NonNull;
 import lombok.ToString;
-import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.enums.PdpResponseStatus;
 import org.onap.policy.models.pdp.enums.PdpState;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Lifecycle Passive State.
  */
 @ToString
 public class LifecycleStatePassive extends LifecycleStateRunning {
-    private static final Logger logger = LoggerFactory.getLogger(LifecycleStatePassive.class);
-
     protected LifecycleStatePassive(LifecycleFsm manager) {
         super(manager);
     }
@@ -59,15 +54,13 @@
     }
 
     @Override
-    protected boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
-        logger.info("{}: deploy {} to {}", this, policy.getIdentifier(), controller.getName());
+    protected boolean deployPolicy(@NonNull PolicyTypeController controller, @NonNull ToscaPolicy policy) {
         fsm.deployedPolicyAction(policy);
         return true;
     }
 
     @Override
-    protected boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
-        logger.info("{}: undeploy {} from {}", this, policy.getIdentifier(), controller.getName());
+    protected boolean undeployPolicy(@NonNull PolicyTypeController controller, @NonNull ToscaPolicy policy) {
         fsm.undeployedPolicyAction(policy);
         return true;
     }
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index e9ad9ff..f762bff 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -24,7 +24,6 @@
 import java.util.List;
 import java.util.function.BiPredicate;
 import lombok.NonNull;
-import org.onap.policy.drools.system.PolicyController;
 import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
 import org.onap.policy.models.pdp.concepts.PdpStateChange;
 import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -50,9 +49,9 @@
 
     protected abstract boolean stateChangeToActive(@NonNull PdpStateChange change);
 
-    protected abstract boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy);
+    protected abstract boolean deployPolicy(@NonNull PolicyTypeController controller, @NonNull ToscaPolicy policy);
 
-    protected abstract boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy);
+    protected abstract boolean undeployPolicy(@NonNull PolicyTypeController controller, @NonNull ToscaPolicy policy);
 
     @Override
     public boolean start() {
@@ -143,7 +142,7 @@
         // running but are not present in this list.  This will include
         // policies that are overridden by a different version.   Second,
         // we will deploy those policies that are not installed but
-        // resent in this list.
+        // included in this list.
 
         boolean success = undeployPolicies(policies);
         return deployPolicies(policies) && success;
@@ -158,11 +157,11 @@
     }
 
     protected boolean syncPolicies(List<ToscaPolicy> policies,
-                                   BiPredicate<PolicyController, ToscaPolicy> sync) {
+                                   BiPredicate<PolicyTypeController, ToscaPolicy> sync) {
         boolean success = true;
         for (ToscaPolicy policy : policies) {
             ToscaPolicyTypeIdentifier policyType = policy.getTypeIdentifier();
-            PolicyController controller = fsm.getController(policyType);
+            PolicyTypeController controller = fsm.getController(policyType);
             if (controller == null) {
                 logger.warn("no controller found for {}", policyType);
                 success = false;
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeController.java
new file mode 100644
index 0000000..a61088d
--- /dev/null
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeController.java
@@ -0,0 +1,46 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.lifecycle;
+
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+
+/**
+ * Policy Type Controller.
+ */
+
+public interface PolicyTypeController {
+
+    /**
+     * Get Policy Type.
+     */
+    ToscaPolicyTypeIdentifier getPolicyType();
+
+    /**
+     * Deploy a Tosca Policy.
+     */
+    boolean deploy(ToscaPolicy policy);
+
+    /**
+     * Undeploy a Tosca Policy.
+     */
+    boolean undeploy(ToscaPolicy policy);
+}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
new file mode 100644
index 0000000..f5ceafb
--- /dev/null
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
@@ -0,0 +1,60 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.lifecycle;
+
+import lombok.Getter;
+
+import org.onap.policy.drools.system.PolicyController;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+
+/**
+ * Policy Type Drools Controller that delegates to a corresponding
+ * PolicyController that supports this policy type.
+ */
+
+@Getter
+public class PolicyTypeDroolsController implements PolicyTypeController {
+
+    protected final PolicyController controller;
+    protected final ToscaPolicyTypeIdentifier policyType;
+    protected final LifecycleFsm fsm;
+
+    /**
+     * Creates a Policy Type Drools Controller.
+     */
+    public PolicyTypeDroolsController(
+            LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType, PolicyController controller) {
+        this.policyType = policyType;
+        this.controller = controller;
+        this.fsm = fsm;
+    }
+
+    @Override
+    public boolean deploy(ToscaPolicy policy) {
+        return fsm.getDomainMaker().isConformant(policy) && this.controller.offer(policy);
+    }
+
+    @Override
+    public boolean undeploy(ToscaPolicy policy) {
+        return controller.getDrools().delete(policy);
+    }
+}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
new file mode 100644
index 0000000..87128e4
--- /dev/null
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeController.java
@@ -0,0 +1,49 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.lifecycle;
+
+import lombok.Getter;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+
+@Getter
+public class PolicyTypeNativeController implements PolicyTypeController {
+
+    protected final ToscaPolicyTypeIdentifier policyType;
+    protected final LifecycleFsm fsm;
+
+    public PolicyTypeNativeController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+        this.policyType = policyType;
+        this.fsm = fsm;
+    }
+
+    @Override
+    public boolean deploy(ToscaPolicy policy) {
+        // TODO
+        return fsm.getDomainMaker().isConformant(policy);
+    }
+
+    @Override
+    public boolean undeploy(ToscaPolicy policy) {
+        // TODO
+        return true;
+    }
+}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesController.java
new file mode 100644
index 0000000..7dd0d7a
--- /dev/null
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeRulesController.java
@@ -0,0 +1,50 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.drools.lifecycle;
+
+import lombok.Getter;
+
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+
+@Getter
+public class PolicyTypeRulesController implements PolicyTypeController {
+
+    protected final ToscaPolicyTypeIdentifier policyType;
+    protected final LifecycleFsm fsm;
+
+    public PolicyTypeRulesController(LifecycleFsm fsm, ToscaPolicyTypeIdentifier policyType) {
+        this.policyType = policyType;
+        this.fsm = fsm;
+    }
+
+    @Override
+    public boolean deploy(ToscaPolicy policy) {
+        // TODO
+        return fsm.getDomainMaker().isConformant(policy);
+    }
+
+    @Override
+    public boolean undeploy(ToscaPolicy policy) {
+        // TODO
+        return true;
+    }
+}
diff --git a/feature-lifecycle/src/main/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json b/feature-lifecycle/src/main/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json
new file mode 100644
index 0000000..e89238d
--- /dev/null
+++ b/feature-lifecycle/src/main/resources/schemas/onap.policies.controlloop.Operational-1.0.0.schema.json
@@ -0,0 +1,90 @@
+{
+    "definitions": {},
+    "$schema": "http://json-schema.org/draft-07/schema#",
+    "$id": "http://www.onap.org/policy/models/schemas/onap.policies.controlloop.Operational.schema.json",
+    "type": "object",
+    "title": "Root Schema for legacy onap.policies.controlloop.Operational policy type domain policies",
+    "required": [
+        "type",
+        "type_version",
+        "version",
+        "properties"
+    ],
+    "properties": {
+        "type": {
+            "$id": "#/properties/type",
+            "type": "string",
+            "title": "Policy Type",
+            "default": "onap.policies.controlloop.Operational",
+            "examples": [
+                "onap.policies.controlloop.Operational"
+            ],
+            "pattern": "^(.+)$"
+        },
+        "type_version": {
+            "$id": "#/properties/type_version",
+            "type": "string",
+            "title": "Policy Type Version",
+            "examples": [
+                "1.0.0"
+            ],
+            "pattern": "^(.+)$"
+        },
+        "version": {
+            "$id": "#/properties/version",
+            "type": "string",
+            "title": "Version",
+            "examples": [
+                "1.0.0"
+            ],
+            "pattern": "^(.+)$"
+        },
+        "name": {
+            "$id": "#/properties/name",
+            "type": "string",
+            "title": "Name",
+            "examples": [
+                "example"
+            ],
+            "pattern": "^(.+)$"
+        },
+        "metadata": {
+            "$id": "#/properties/metadata",
+            "type": "object",
+            "title": "Metadata",
+            "required": [
+                "policy-id"
+            ],
+            "properties": {
+                "policy-id": {
+                    "$id": "#/properties/metadata/properties/policy-id",
+                    "type": "string",
+                    "title": "Policy Name",
+                    "examples": [
+                        "example"
+                    ],
+                    "pattern": "^(.+)$"
+                }
+            }
+        },
+        "properties": {
+            "$id": "#/properties/properties",
+            "type": "object",
+            "title": "Properties",
+            "required": [
+                "content"
+            ],
+            "properties": {
+                "content": {
+                    "$id": "#/properties/properties/properties/content",
+                    "type": "string",
+                    "title": "Legacy policy in yaml format",
+                    "examples": [
+                        "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPEv2-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard"
+                    ],
+                    "pattern": "^(.+)$"
+                }
+            }
+        }
+    }
+}
diff --git a/feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json b/feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json
index d1866c6..1dd766a 100644
--- a/feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json
+++ b/feature-lifecycle/src/main/resources/schemas/onap.policies.native.Drools-1.0.0.schema.json
@@ -60,7 +60,7 @@
                 "policy-id": {
                     "$id": "#/properties/metadata/properties/policy-id",
                     "type": "string",
-                    "title": "The Policy-id Schema",
+                    "title": "Policy Name",
                     "examples": [
                         "example"
                     ],
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 7fc7fd2..c61227b 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
@@ -131,11 +131,11 @@
         int preCount = fsm.client.getSink().getRecentEvents().length;
 
         assertTrue(fsm.status());
-        assertEquals(preCount, fsm.client.getSink().getRecentEvents().length);
+        assertEquals(preCount + 1, fsm.client.getSink().getRecentEvents().length);
 
         fsm.start(controllerSupport.getController());
         assertTrue(fsm.status());
-        assertEquals(preCount + 1, fsm.client.getSink().getRecentEvents().length);
+        assertEquals(preCount + 2, fsm.client.getSink().getRecentEvents().length);
 
         fsm.stop(controllerSupport.getController());
         fsm.shutdown();
@@ -207,7 +207,7 @@
 
         assertTrue(fsm.update(update));
         assertEquals(qlength + 1, fsm.client.getSink().getRecentEvents().length);
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         PdpStatus cachedStatus = new StandardCoder()
                                     .decode(fsm.client.getSink().getRecentEvents()[qlength], PdpStatus.class);
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -221,7 +221,7 @@
 
         assertTrue(fsm.update(update));
         assertEquals(qlength + 2, fsm.client.getSink().getRecentEvents().length);
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         cachedStatus = new StandardCoder()
             .decode(fsm.client.getSink().getRecentEvents()[qlength + 1], PdpStatus.class);
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -237,7 +237,7 @@
         update.setPolicies(Collections.emptyList());
         assertTrue(fsm.update(update));
         assertEquals(qlength + 3, fsm.client.getSink().getRecentEvents().length);
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         cachedStatus = new StandardCoder()
             .decode(fsm.client.getSink().getRecentEvents()[qlength + 2], PdpStatus.class);
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -251,7 +251,7 @@
         update.setPolicies(Arrays.asList(toscaPolicyRestartV1));
         assertTrue(fsm.update(update));
         assertEquals(qlength + 4, fsm.client.getSink().getRecentEvents().length);
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         cachedStatus = new StandardCoder()
             .decode(fsm.client.getSink().getRecentEvents()[qlength + 3], PdpStatus.class);
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -269,7 +269,7 @@
         update.setPolicies(Arrays.asList(toscaPolicyRestartV2));
         assertTrue(fsm.update(update));
         assertEquals(qlength + 5, fsm.client.getSink().getRecentEvents().length);
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         cachedStatus = new StandardCoder()
             .decode(fsm.client.getSink().getRecentEvents()[qlength + 4], PdpStatus.class);
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
@@ -288,7 +288,7 @@
         update.setPolicies(Arrays.asList(toscaPolicyRestartV2, toscaPolicyFirewall));
         assertTrue(fsm.update(update));
         assertEquals(qlength + 6, fsm.client.getSink().getRecentEvents().length);
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         cachedStatus = new StandardCoder()
             .decode(fsm.client.getSink().getRecentEvents()[qlength + 5], PdpStatus.class);
         assertEquals(new ArrayList<>(fsm.policiesMap.keySet()), cachedStatus.getPolicies());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index 60d71d0..b42e0fb 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -74,8 +74,10 @@
     public void testController() {
         fsm.start(controllerSupport.getController());
         assertSame(controllerSupport.getController(),
-                        fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE,
-                                        ControllerSupport.POLICY_TYPE_VERSION)));
+            ((PolicyTypeDroolsController) fsm.getController(
+                    new ToscaPolicyTypeIdentifier(
+                            ControllerSupport.POLICY_TYPE, ControllerSupport.POLICY_TYPE_VERSION)))
+                .getController());
 
         fsm.stop(controllerSupport.getController());
         assertNull(fsm.getController(new ToscaPolicyTypeIdentifier(ControllerSupport.POLICY_TYPE,
@@ -121,7 +123,7 @@
     public void testStatus() {
         assertTrue(fsm.client.getSink().isAlive());
         assertTrue(fsm.status());
-        assertSame(0, fsm.client.getSink().getRecentEvents().length);
+        assertSame(1, fsm.client.getSink().getRecentEvents().length);
 
 
         fsm.start(controllerSupport.getController());
@@ -179,7 +181,7 @@
         assertEquals("z", fsm.getSubgroup());
         assertBasicPassive();
 
-        assertTrue(fsm.policyTypesMap.isEmpty());
+        assertEquals(2, fsm.policyTypesMap.size());
         assertTrue(fsm.policiesMap.isEmpty());
 
         update.setPdpGroup(null);
@@ -192,7 +194,7 @@
         assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
         assertNull(fsm.getSubgroup());
         assertBasicPassive();
-        assertTrue(fsm.policyTypesMap.isEmpty());
+        assertEquals(2, fsm.policyTypesMap.size());
         assertTrue(fsm.policiesMap.isEmpty());
 
         update.setPdpGroup("A");
@@ -205,15 +207,15 @@
         assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
         assertEquals("a", fsm.getSubgroup());
         assertBasicPassive();
-        assertTrue(fsm.policyTypesMap.isEmpty());
+        assertEquals(2, fsm.policyTypesMap.size());
         assertTrue(fsm.policiesMap.isEmpty());
 
         fsm.start(controllerSupport.getController());
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         assertTrue(fsm.policiesMap.isEmpty());
 
         assertTrue(fsm.update(update));
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         assertEquals(1, fsm.policiesMap.size());
         assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
         assertEquals(PdpState.PASSIVE, fsm.state());
@@ -227,7 +229,7 @@
         update.setPdpSubgroup(null);
         update.setPolicies(Collections.emptyList());
         assertTrue(fsm.update(update));
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         assertEquals(0, fsm.policiesMap.size());
         assertEquals(PdpState.PASSIVE, fsm.state());
         assertEquals(interval, fsm.getStatusTimerSeconds());
@@ -267,11 +269,11 @@
 
         controllerSupport.getController().start();
         fsm.start(controllerSupport.getController());
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         assertTrue(fsm.policiesMap.isEmpty());
 
         assertTrue(fsm.update(update));
-        assertEquals(1, fsm.policyTypesMap.size());
+        assertEquals(3, fsm.policyTypesMap.size());
         assertEquals(1, fsm.policiesMap.size());
         assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
         assertEquals(PdpState.PASSIVE, fsm.state());