summaryrefslogtreecommitdiffstats
path: root/models-provider
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-03-15 12:36:38 +0000
committerliamfallon <liam.fallon@est.tech>2019-03-15 12:36:38 +0000
commit8fdf84c7f2bd03332e69d13e35414020053c2977 (patch)
treed2ce197064b2a23ac06ac8195a4e1ef7603ee3ed /models-provider
parent4c28d2cdbf03be9dfe51caa05d45ba341b4c94cd (diff)
Add serialization for Tosca Model
Added tests for Yaml policy monitoring Added provider interface calls in provider and structure for handling legacy APIs. Issue-ID: POLICY-1195 Change-Id: I4825272e0713b9e6a4b89753828de8905bcffbd1 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java85
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java4
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java (renamed from models-provider/src/main/java/org/onap/policy/models/provider/impl/PolicyModelsProviderImpl.java)60
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java168
-rw-r--r--models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json48
-rw-r--r--models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json48
-rw-r--r--models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json48
-rw-r--r--models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json48
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java49
9 files changed, 545 insertions, 13 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
index 0144f8c68..fbdf092c2 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
@@ -24,8 +24,9 @@ import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfReferenceKey;
import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
/**
* This interface describes the operations that are provided to users and components for reading
@@ -86,7 +87,7 @@ public interface PolicyModelsProvider {
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public ToscaServiceTemplate getPolicies(@NonNull final PfReferenceKey policyKey) throws PfModelException;
+ public ToscaServiceTemplate getPolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
/**
* Create policies.
@@ -118,7 +119,83 @@ public interface PolicyModelsProvider {
* @return the TOSCA service template containing the policy types that were deleted
* @throws PfModelException on errors deleting policies
*/
- public ToscaServiceTemplate deletePolicies(@NonNull final PfReferenceKey policyKey) throws PfModelException;
+ public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException;
+
+ /**
+ * Get legacy operational policy.
+ *
+ * @param policyId ID of the policy.
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException;
+
+ /**
+ * Create legacy operational policy.
+ *
+ * @param legacyOperationalPolicy the definition of the policy to be created.
+ * @return the created policy
+ * @throws PfModelException on errors creating policies
+ */
+ public LegacyOperationalPolicy createOperationalPolicy(
+ @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
+
+ /**
+ * Update legacy operational policy.
+ *
+ * @param legacyOperationalPolicy the definition of the policy to be updated
+ * @return the updated policy
+ * @throws PfModelException on errors updating policies
+ */
+ public LegacyOperationalPolicy updateOperationalPolicy(
+ @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException;
+
+ /**
+ * Delete legacy operational policy.
+ *
+ * @param policyId ID of the policy.
+ * @return the deleted policy
+ * @throws PfModelException on errors deleting policies
+ */
+ public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException;
+
+ /**
+ * Get legacy guard policy.
+ *
+ * @param policyId ID of the policy.
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public LegacyGuardPolicy getGuardPolicy(@NonNull final String policyId) throws PfModelException;
+
+ /**
+ * Create legacy guard policy.
+ *
+ * @param legacyGuardPolicy the definition of the policy to be created.
+ * @return the created policy
+ * @throws PfModelException on errors creating policies
+ */
+ public LegacyGuardPolicy createGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
+ throws PfModelException;
+
+ /**
+ * Update legacy guard policy.
+ *
+ * @param legacyGuardPolicy the definition of the policy to be updated
+ * @return the updated policy
+ * @throws PfModelException on errors updating policies
+ */
+ public LegacyGuardPolicy updateGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy)
+ throws PfModelException;
+
+ /**
+ * Delete legacy guard policy.
+ *
+ * @param policyId ID of the policy.
+ * @return the deleted policy
+ * @throws PfModelException on errors deleting policies
+ */
+ public LegacyGuardPolicy deleteGuardPolicy(@NonNull final String policyId) throws PfModelException;
/**
* Get PDP groups.
@@ -152,5 +229,5 @@ public interface PolicyModelsProvider {
* @param somePdpGroupFilter a filter for the get
* @throws PfModelException on errors deleting PDP groups
*/
- public void deletePdpGroups(@NonNull final Object somePdpGroupFilter) throws PfModelException;
+ public Object deletePdpGroups(@NonNull final Object somePdpGroupFilter) throws PfModelException;
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java
index 5c4342800..b4b5f1ddc 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java
@@ -20,7 +20,7 @@
package org.onap.policy.models.provider;
-import org.onap.policy.models.provider.impl.PolicyModelsProviderImpl;
+import org.onap.policy.models.provider.impl.DummyPolicyModelsProviderImpl;
/**
* A factory for creating PolicyModelsProvider objects using the default Policy Framework implementation.
@@ -33,6 +33,6 @@ public class PolicyModelsProviderFactory {
* Creates a new PolicyModelsProvider object from its implementation.
*/
public PolicyModelsProvider createPolicyModelsProvider() {
- return new PolicyModelsProviderImpl();
+ return new DummyPolicyModelsProviderImpl();
}
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/PolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index 12d7686b3..3f41dac7c 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/PolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -24,16 +24,18 @@ import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfReferenceKey;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
/**
- * This class provides the implementaiton of the defalut Policy Models Provider for the ONAP Policy Framework.
+ * This class provides an implementation of the Policy Models Provider for the ONAP Policy Framework
+ * that works towards a relational database.
*
* @author Liam Fallon (liam.fallon@est.tech)
*/
-public class PolicyModelsProviderImpl implements PolicyModelsProvider {
+public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
@Override
public ToscaServiceTemplate getPolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException {
@@ -47,12 +49,18 @@ public class PolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
+ public ToscaServiceTemplate updatePolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate)
+ throws PfModelException {
+ return null;
+ }
+
+ @Override
public ToscaServiceTemplate deletePolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException {
return null;
}
@Override
- public ToscaServiceTemplate getPolicies(@NonNull PfReferenceKey policyKey) throws PfModelException {
+ public ToscaServiceTemplate getPolicies(@NonNull PfConceptKey policyKey) throws PfModelException {
return null;
}
@@ -67,17 +75,53 @@ public class PolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public ToscaServiceTemplate deletePolicies(@NonNull PfReferenceKey policyKey) throws PfModelException {
+ public ToscaServiceTemplate deletePolicies(@NonNull PfConceptKey policyKey) throws PfModelException {
return null;
}
@Override
- public ToscaServiceTemplate updatePolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate)
+ public LegacyOperationalPolicy getOperationalPolicy(@NonNull String policyId) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public LegacyOperationalPolicy createOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy)
throws PfModelException {
return null;
}
@Override
+ public LegacyOperationalPolicy updateOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy)
+ throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull String policyId) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public LegacyGuardPolicy getGuardPolicy(@NonNull String policyId) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public LegacyGuardPolicy createGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public LegacyGuardPolicy updateGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public LegacyGuardPolicy deleteGuardPolicy(@NonNull String policyId) throws PfModelException {
+ return null;
+ }
+
+ @Override
public Object getPdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException {
return null;
}
@@ -93,6 +137,8 @@ public class PolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public void deletePdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException {
+ public Object deletePdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException {
+ return null;
}
+
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
new file mode 100644
index 000000000..9b92ea3ee
--- /dev/null
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.provider.impl;
+
+import com.google.gson.Gson;
+
+import javax.ws.rs.core.Response;
+
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy;
+import org.onap.policy.models.tosca.serialization.simple.ToscaServiceTemplateMessageBodyHandler;
+
+/**
+ * This class provides a dummy implementation of the Policy Models Provider for the ONAP Policy
+ * Framework.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
+ @Override
+ public ToscaServiceTemplate getPolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException {
+ return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json");
+ }
+
+ @Override
+ public ToscaServiceTemplate createPolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate)
+ throws PfModelException {
+ return serviceTemplate;
+ }
+
+ @Override
+ public ToscaServiceTemplate updatePolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate)
+ throws PfModelException {
+ return serviceTemplate;
+ }
+
+ @Override
+ public ToscaServiceTemplate deletePolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException {
+ return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json");
+ }
+
+ @Override
+ public ToscaServiceTemplate getPolicies(@NonNull PfConceptKey policyKey) throws PfModelException {
+ return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json");
+ }
+
+ @Override
+ public ToscaServiceTemplate createPolicies(@NonNull ToscaServiceTemplate serviceTemplate) throws PfModelException {
+ return serviceTemplate;
+ }
+
+ @Override
+ public ToscaServiceTemplate updatePolicies(@NonNull ToscaServiceTemplate serviceTemplate) throws PfModelException {
+ return serviceTemplate;
+ }
+
+ @Override
+ public ToscaServiceTemplate deletePolicies(@NonNull PfConceptKey policyKey) throws PfModelException {
+ return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json");
+ }
+
+ @Override
+ public LegacyOperationalPolicy getOperationalPolicy(@NonNull String policyId) throws PfModelException {
+ return new LegacyOperationalPolicy();
+ }
+
+ @Override
+ public LegacyOperationalPolicy createOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy)
+ throws PfModelException {
+ return legacyOperationalPolicy;
+ }
+
+ @Override
+ public LegacyOperationalPolicy updateOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy)
+ throws PfModelException {
+ return legacyOperationalPolicy;
+ }
+
+ @Override
+ public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull String policyId) throws PfModelException {
+ return new LegacyOperationalPolicy();
+ }
+
+ @Override
+ public LegacyGuardPolicy getGuardPolicy(@NonNull String policyId) throws PfModelException {
+ return new LegacyGuardPolicy();
+ }
+
+ @Override
+ public LegacyGuardPolicy createGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException {
+ return legacyGuardPolicy;
+ }
+
+ @Override
+ public LegacyGuardPolicy updateGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException {
+ return legacyGuardPolicy;
+ }
+
+ @Override
+ public LegacyGuardPolicy deleteGuardPolicy(@NonNull String policyId) throws PfModelException {
+ return new LegacyGuardPolicy();
+ }
+
+ @Override
+ public Object getPdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public Object createPdpGroups(@NonNull Object somePdpGroupSpecification) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public Object updatePdpGroups(@NonNull Object somePdpGroupSpecification) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public Object deletePdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Return a ToscaServicetemplate dummy response.
+ *
+ * @param fileName the file name containing the dummy response
+ * @return the ToscaServiceTemplate with the dummy response
+ */
+ private ToscaServiceTemplate getDummyResponse(@NonNull final String fileName) {
+ Gson gson = new ToscaServiceTemplateMessageBodyHandler().getGson();
+ ToscaServiceTemplate serviceTemplate;
+
+ try {
+ serviceTemplate = gson.fromJson(TextFileUtils.getTextFileAsString(fileName), ToscaServiceTemplate.class);
+ } catch (Exception exc) {
+ throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "error serializing object", exc);
+ }
+
+ return serviceTemplate;
+ }
+}
diff --git a/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json
new file mode 100644
index 000000000..27de380c2
--- /dev/null
+++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json
@@ -0,0 +1,48 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.vcpe.tca": {
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "onap.vcpe.tca"
+ },
+ "properties": {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "eventName": "Measurement_vGMUX",
+ "controlLoopSchemaType": "VNF",
+ "policyScope": "DCAE",
+ "policyName": "DCAE.Config_tca-hi-lo",
+ "policyVersion": "v0.0.1",
+ "thresholds": [
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "EQUAL",
+ "severity": "MAJOR",
+ "closedLoopEventStatus": "ABATED"
+ },
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "GREATER",
+ "severity": "CRITICAL",
+ "closedLoopEventStatus": "ONSET"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json
new file mode 100644
index 000000000..27de380c2
--- /dev/null
+++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json
@@ -0,0 +1,48 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.vcpe.tca": {
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "onap.vcpe.tca"
+ },
+ "properties": {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "eventName": "Measurement_vGMUX",
+ "controlLoopSchemaType": "VNF",
+ "policyScope": "DCAE",
+ "policyName": "DCAE.Config_tca-hi-lo",
+ "policyVersion": "v0.0.1",
+ "thresholds": [
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "EQUAL",
+ "severity": "MAJOR",
+ "closedLoopEventStatus": "ABATED"
+ },
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "GREATER",
+ "severity": "CRITICAL",
+ "closedLoopEventStatus": "ONSET"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json
new file mode 100644
index 000000000..27de380c2
--- /dev/null
+++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json
@@ -0,0 +1,48 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.vcpe.tca": {
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "onap.vcpe.tca"
+ },
+ "properties": {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "eventName": "Measurement_vGMUX",
+ "controlLoopSchemaType": "VNF",
+ "policyScope": "DCAE",
+ "policyName": "DCAE.Config_tca-hi-lo",
+ "policyVersion": "v0.0.1",
+ "thresholds": [
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "EQUAL",
+ "severity": "MAJOR",
+ "closedLoopEventStatus": "ABATED"
+ },
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "GREATER",
+ "severity": "CRITICAL",
+ "closedLoopEventStatus": "ONSET"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json
new file mode 100644
index 000000000..27de380c2
--- /dev/null
+++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json
@@ -0,0 +1,48 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.vcpe.tca": {
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "onap.vcpe.tca"
+ },
+ "properties": {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "eventName": "Measurement_vGMUX",
+ "controlLoopSchemaType": "VNF",
+ "policyScope": "DCAE",
+ "policyName": "DCAE.Config_tca-hi-lo",
+ "policyVersion": "v0.0.1",
+ "thresholds": [
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "EQUAL",
+ "severity": "MAJOR",
+ "closedLoopEventStatus": "ABATED"
+ },
+ {
+ "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
+ "version": "1.0.2",
+ "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "GREATER",
+ "severity": "CRITICAL",
+ "closedLoopEventStatus": "ONSET"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
new file mode 100644
index 000000000..d4808ee70
--- /dev/null
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.provider.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate;
+
+/**
+ * Test the dummy moldes provider implementation.
+ *
+ * @author Liam Fallon (liam.fallon@est.tech)
+ */
+public class DummyPolicyModelsProviderTest {
+
+ @Test
+ public void test() throws PfModelException {
+ PolicyModelsProvider dummyProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider();
+
+ ToscaServiceTemplate serviceTemplate = dummyProvider.getPolicies(new PfConceptKey());
+ assertNotNull(serviceTemplate);
+ assertEquals("onap.vcpe.tca:1.0.0",
+ serviceTemplate.getTopologyTemplate().getPolicies().get("onap.vcpe.tca").getId());
+ }
+}