aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorXue Gao <xg353y@intl.att.com>2020-03-10 10:18:34 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-10 10:18:34 +0000
commit0c4e6af85daabe730917898f466a1d45cbc16f92 (patch)
tree7fe94ceecd7d69e57858ae8b25babdaaedb6ca3f /src/test/java/org
parent5c3a825851bb1a345620c5c4951726c5b94a0341 (diff)
parent2dd4e997c1ccf5dab4dfb7665ce74c0fd1f13e49 (diff)
Merge "Rework tosca converter"
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();