diff options
Diffstat (limited to 'src/test/java/org')
-rw-r--r-- | src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java | 8 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java | 22 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java | 18 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java | 6 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java (renamed from src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java) | 118 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java (renamed from src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java) | 12 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java | 5 |
7 files changed, 94 insertions, 95 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 a99d4ab56..83c374e9d 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 @@ -37,12 +37,12 @@ public class ArrayFieldTest extends TestCase { * @throws IOException in case of failure */ public void testDeploy() throws IOException { - TemplateManagement templateManagement = new TemplateManagement(ResourceFileUtil.getResourceAsString( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager(ResourceFileUtil.getResourceAsString( "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor"); - Property property = component.getProperties().get("actor"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Actor"); + Property property = toscaElement.getProperties().get("actor"); ArrayField arrayParser = new ArrayField((ArrayList<Object>) property.getItems().get("default")); JsonArray toTest = arrayParser.deploy(); String reference = "[1,\"String\",5.5,true]"; 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 a4d329e29..a73fd6736 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 @@ -31,12 +31,12 @@ import org.onap.clamp.clds.util.ResourceFileUtil; public class ConstraintTest extends TestCase { - TemplateManagement templateManagement = new TemplateManagement( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/constraints.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Operation"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Operation"); public ConstraintTest() throws IOException { } @@ -45,15 +45,15 @@ public class ConstraintTest extends TestCase { * Test get value array. */ public void testGetValuesArray() { - Property property = component.getProperties().get("timeout"); - Template template = templateManagement.getTemplates().get("integer"); + Property property = toscaElement.getProperties().get("timeout"); + Template template = toscaConverterManager.getTemplates().get("integer"); JsonObject resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList<Object>) property.getItems().get("constraints"), template); String reference = "{\"enum\":[3,4,5.5,6,10]}"; assertEquals(reference, String.valueOf(resultProcess)); - property = component.getProperties().get("success"); - template = templateManagement.getTemplates().get("string"); + property = toscaElement.getProperties().get("success"); + template = toscaConverterManager.getTemplates().get("string"); resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList<Object>) property.getItems().get("constraints"), template); @@ -66,8 +66,8 @@ public class ConstraintTest extends TestCase { */ public void testGetSpecificLength() { //Test for string type, same process for array - Property property = component.getProperties().get("id"); - Template template = templateManagement.getTemplates().get("string"); + Property property = toscaElement.getProperties().get("id"); + Template template = toscaConverterManager.getTemplates().get("string"); JsonObject resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList<Object>) property.getItems().get("constraints"), template); @@ -83,8 +83,8 @@ public class ConstraintTest extends TestCase { */ public void testGetLimitValue() { //Test for array type, same process for string - Property property = component.getProperties().get("description"); - Template template = templateManagement.getTemplates().get("array"); + Property property = toscaElement.getProperties().get("description"); + Template template = toscaConverterManager.getTemplates().get("array"); JsonObject resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList<Object>) property.getItems().get("constraints"), template); 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 62def32b8..bb1929f98 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 @@ -40,12 +40,12 @@ public class PropertyTest extends TestCase { * @throws IOException In case of failure */ public void testParseArray() throws IOException { - TemplateManagement templateManagement = new TemplateManagement( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor"); - Property property = component.getProperties().get("actor"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Actor"); + Property property = toscaElement.getProperties().get("actor"); JsonArray toTest = property.parseArray((ArrayList<Object>) property.getItems().get("default")); assertNotNull(toTest); } @@ -56,13 +56,13 @@ public class PropertyTest extends TestCase { * @throws IOException In case of failure */ public void testAddConstraintsAsJson() throws IOException { - TemplateManagement templateManagement = new TemplateManagement( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.operation.Failure"); - Property property = component.getProperties().get("category"); - Template template = templateManagement.getTemplates().get("string"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.operation.Failure"); + Property property = toscaElement.getProperties().get("category"); + Template template = toscaConverterManager.getTemplates().get("string"); JsonObject toTest = new JsonObject(); property.addConstraintsAsJson(toTest, (ArrayList<Object>) property.getItems().get("constraints"), template); String test = "{\"enum\":[\"error\",\"timeout\",\"retries\",\"guard\",\"exception\"]}"; diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java index 4ffb4e28e..02c5747b6 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java @@ -35,11 +35,11 @@ public class TemplateTest extends TestCase { */ public void testCheckFields() { Template toTest = new Template("toTest"); - List<Field> fields = new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"),new Field( + List<TemplateField> templateFields = new ArrayList<>(Arrays.asList(new TemplateField("type"), new TemplateField("description"),new TemplateField( "enum"))); - toTest.setFields(fields); + toTest.setTemplateFields(templateFields); Template reference = new Template("toTest"); - reference.setFields(fields); + reference.setTemplateFields(templateFields); assertTrue(toTest.checkFields(reference)); } diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java index aaa549386..493841215 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java @@ -30,7 +30,7 @@ import java.util.List; import junit.framework.TestCase; import org.onap.clamp.clds.util.ResourceFileUtil; -public class TemplateManagementTest extends TestCase { +public class ToscaConverterManagerTest extends TestCase { /** * Test the launch translation wit operational policies. @@ -39,17 +39,17 @@ public class TemplateManagementTest extends TestCase { * @throws UnknownComponentException In case of failure */ public void testLaunchTranslationTca() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0?" + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); + assertNull(toscaConverterManager.getParseToJson()); String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); } /** @@ -59,17 +59,17 @@ public class TemplateManagementTest extends TestCase { * @throws UnknownComponentException In case of failure */ public void testLaunchTranslationFrequencyLimiter() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0?" + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); + assertNull(toscaConverterManager.getParseToJson()); String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); } /** @@ -79,17 +79,17 @@ public class TemplateManagementTest extends TestCase { * @throws UnknownComponentException In case of failure */ public void testLaunchTranslationApex() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.operational.common.Apex/versions/1.0.0?" + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); + assertNull(toscaConverterManager.getParseToJson()); String componentName = "onap.policies.controlloop.operational.common.Apex"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); } /** @@ -99,17 +99,17 @@ public class TemplateManagementTest extends TestCase { * @throws UnknownComponentException In case of failure */ public void testLaunchTranslationDrools() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + ".policies.controlloop.operational.common.Drools/versions/1.0.0?" + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); + assertNull(toscaConverterManager.getParseToJson()); String componentName = "onap.policies.controlloop.operational.common.Drools"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); } /** @@ -119,15 +119,15 @@ public class TemplateManagementTest extends TestCase { * @throws UnknownComponentException In case of failure */ public void testLaunchTranslation() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); + assertNull(toscaConverterManager.getParseToJson()); String componentName = "onap.policies.controlloop.operational.common.Drools"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); } /** @@ -136,18 +136,18 @@ public class TemplateManagementTest extends TestCase { * @throws IOException In case of failure */ public void testAddTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - int count = templateManagement.getTemplates().size(); - List<Field> templateFields = new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"), - new Field( + int count = toscaConverterManager.getTemplates().size(); + List<TemplateField> templateFields = new ArrayList<>(Arrays.asList(new TemplateField("type"), new TemplateField("description"), + new TemplateField( "required"), - new Field("metadata"), new Field("constraints"))); - templateManagement.addTemplate("test", templateFields); - assertNotSame(count, templateManagement.getTemplates().size()); + new TemplateField("metadata"), new TemplateField("constraints"))); + toscaConverterManager.addTemplate("test", templateFields); + assertNotSame(count, toscaConverterManager.getTemplates().size()); } /** @@ -156,14 +156,14 @@ public class TemplateManagementTest extends TestCase { * @throws IOException In case of failure */ public void testRemoveTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - int count = templateManagement.getTemplates().size(); - templateManagement.removeTemplate("string"); - assertNotSame(count, templateManagement.getTemplates().size()); + int count = toscaConverterManager.getTemplates().size(); + toscaConverterManager.removeTemplate("string"); + assertNotSame(count, toscaConverterManager.getTemplates().size()); } /** @@ -172,14 +172,14 @@ public class TemplateManagementTest extends TestCase { * @throws IOException In case of failure */ public void testUpdateTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - int count = templateManagement.getTemplates().get("integer").getFields().size(); - templateManagement.updateTemplate("integer", new Field("type"), false); - assertNotSame(count, templateManagement.getTemplates().get("integer").getFields().size()); + int count = toscaConverterManager.getTemplates().get("integer").getTemplateFields().size(); + toscaConverterManager.updateTemplate("integer", new TemplateField("type"), false); + assertNotSame(count, toscaConverterManager.getTemplates().get("integer").getTemplateFields().size()); } /** @@ -188,17 +188,17 @@ public class TemplateManagementTest extends TestCase { * @throws IOException In case of failure */ public void testHasTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); boolean has = true; - List<Field> templateFieldsString = - new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"), new Field("required"), - new Field("metadata"), new Field("constraints"))); + List<TemplateField> templateFieldsString = + new ArrayList<>(Arrays.asList(new TemplateField("type"), new TemplateField("description"), new TemplateField("required"), + new TemplateField("metadata"), new TemplateField("constraints"))); Template templateTest = new Template("String", templateFieldsString); - has = templateManagement.hasTemplate(templateTest); + has = toscaConverterManager.hasTemplate(templateTest); assertEquals(false, has); } diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java index 565547e4b..7ffba4e00 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java @@ -29,7 +29,7 @@ import java.util.Arrays; import junit.framework.TestCase;
import org.onap.clamp.clds.util.ResourceFileUtil;
-public class ComponentTest extends TestCase {
+public class ToscaElementTest extends TestCase {
/**
* Test propertiesName.
@@ -38,13 +38,13 @@ public class ComponentTest extends TestCase { */
public void testPropertiesNames() throws IOException {
ArrayList<String> reference = new ArrayList<>(Arrays.asList("actor", "operation", "target", "payload"));
- TemplateManagement templateManagement =
- new TemplateManagement(
+ ToscaConverterManager toscaConverterManager =
+ new ToscaConverterManager(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"),
ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
- Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
- assertEquals(reference, component.propertiesNames());
+ ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Actor");
+ assertEquals(reference, toscaElement.propertiesNames());
}
}
diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index fd215dd39..a57a35ea4 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -27,7 +27,6 @@ package org.onap.clamp.loop; import static org.assertj.core.api.Assertions.assertThat; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -50,7 +49,7 @@ import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; -import org.onap.clamp.loop.service.ServiceRepository; +import org.onap.clamp.loop.service.ServicesRepository; import org.onap.clamp.loop.template.LoopTemplate; import org.onap.clamp.loop.template.LoopTemplateLoopElementModel; import org.onap.clamp.loop.template.LoopTemplatesRepository; @@ -87,7 +86,7 @@ public class CsarInstallerItCase { private LoopTemplatesRepository loopTemplatesRepo; @Autowired - ServiceRepository serviceRepository; + ServicesRepository serviceRepository; @Autowired PolicyModelsRepository policyModelsRepository; |