aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-03-04 15:47:39 -0800
committersebdet <sebastien.determe@intl.att.com>2020-03-09 09:07:45 -0700
commit2dd4e997c1ccf5dab4dfb7665ce74c0fd1f13e49 (patch)
treeddea40175352505c75e8eac343587e62c99a49dc /src/test/java/org
parent897a3e004a858ef68d989dad15dde91a69e151a5 (diff)
Rework tosca converter
New code to convert the Policy Tosca Yaml to Json Schema for the Clamp UI Issue-ID: CLAMP-647 Signed-off-by: sebdet <sebastien.determe@intl.att.com> Change-Id: Id15ddedc1910f6a40bf6e407b34e343e00135571
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java1
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java85
-rw-r--r--src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java14
6 files changed, 101 insertions, 7 deletions
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java
index abf65c366..c65c84a45 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java
@@ -38,7 +38,8 @@ public class ArrayFieldTest extends TestCase {
*/
public void testDeploy() throws IOException {
TemplateManagement templateManagement = new TemplateManagement(ResourceFileUtil.getResourceAsString(
- "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),
+ "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
Property property = component.getProperties().get("actor");
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java
index 0494ee11d..f5d2fe6ee 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java
@@ -41,6 +41,7 @@ public class ComponentTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
assertEquals(reference, component.propertiesNames());
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java
index a71ea8ac4..6f1046ea9 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java
@@ -33,6 +33,7 @@ public class ConstraintTest extends TestCase {
TemplateManagement templateManagement = new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/constraints.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Operation");
@@ -41,7 +42,7 @@ public class ConstraintTest extends TestCase {
}
/**
- * Test get value array.
+ * Test get value array.
*/
public void testGetValuesArray() {
Property property = component.getProperties().get("timeout");
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java
index cf183af81..5a9955999 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java
@@ -42,6 +42,7 @@ public class PropertyTest extends TestCase {
public void testParseArray() throws IOException {
TemplateManagement templateManagement = new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
Property property = component.getProperties().get("actor");
@@ -57,6 +58,7 @@ public class PropertyTest extends TestCase {
public void testAddConstraintsAsJson() throws IOException {
TemplateManagement templateManagement = new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.operation.Failure");
Property property = component.getProperties().get("category");
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java
index 8e411069c..4447a98cd 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java
@@ -32,6 +32,86 @@ import org.onap.clamp.clds.util.ResourceFileUtil;
public class TemplateManagementTest extends TestCase {
/**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationTca() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationFrequencyLimiter() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationApex() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.operational.common.Apex/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.controlloop.operational.common.Apex";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationDrools() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.operational.common.Drools/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.controlloop.operational.common.Drools";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
* Test the launch translation.
*
* @throws IOException In case of failure
@@ -41,6 +121,7 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
assertNull(templateManagement.getParseToJson());
String componentName = "onap.policies.controlloop.operational.common.Drools";
@@ -57,6 +138,7 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
int count = templateManagement.getTemplates().size();
ArrayList<String> templateFields =
@@ -74,6 +156,7 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
int count = templateManagement.getTemplates().size();
templateManagement.removeTemplate("string");
@@ -89,6 +172,7 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
int count = templateManagement.getTemplates().get("integer").getFields().size();
templateManagement.updateTemplate("integer", "type", false);
@@ -104,6 +188,7 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
boolean has = true;
ArrayList<String> templateFieldsString =
diff --git a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
index 2cd301850..f08e86e8e 100644
--- a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
+++ b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
@@ -69,11 +69,15 @@ public class PolicyEngineControllerTestItCase {
assertThat(firstExecution).isNotNull();
List<PolicyModel> policyModelsList = policyModelsRepository.findAll();
assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(5);
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.Drools", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.Apex", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.FrequencyLimiter", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.Blacklist", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.MinMax", null, "2.0.0"));
+ assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Drools",
+ null, "1.0.0"));
+ assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Apex",
+ null, "1.0.0"));
+ assertThat(policyModelsList)
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.FrequencyLimiter", null, "1.0.0"));
+ assertThat(policyModelsList)
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.Blacklist", null, "1.0.0"));
+ assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.common.MinMax", null, "2.0.0"));
// Re-do it to check that there is no issue with duplicate key
policyController.synchronizeAllPolicies();