summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test/java
diff options
context:
space:
mode:
authorshiria <shiri.amichai@amdocs.com>2018-03-19 15:23:23 +0200
committershiria <shiri.amichai@amdocs.com>2018-03-22 08:21:36 +0200
commit43187c8495b88589f3187e110cf8d592a091c37f (patch)
tree87ffaf38a95344d76547478f0306b2a923896e44 /openecomp-be/lib/openecomp-tosca-lib/src/test/java
parentd049ca05bbfb6fa6b86b2a093b09ffc1fc0a6e37 (diff)
Update FlatEntity in TOSCA
Add support of dataType entity flat hierarchy in TOSCA Fix existing nodeType entity flat hierarchy in TOSCA Change-Id: I52cd188c595a263c70c2067fd1aac9752f7e24a4 Issue-ID: SDC-1147 Signed-off-by: shiria <shiri.amichai@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test/java')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
index 4e17e50e25..713e8d2eaa 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java
@@ -34,6 +34,7 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.tosca.datatypes.model.DataType;
import org.openecomp.sdc.tosca.datatypes.model.DefinitionOfDataType;
+import org.openecomp.sdc.tosca.datatypes.model.DataType;
import org.openecomp.sdc.tosca.datatypes.model.Import;
import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinitionType;
import org.openecomp.sdc.tosca.datatypes.model.InterfaceType;
@@ -107,7 +108,26 @@ public class ToscaAnalyzerServiceImplTest {
}
@Test
- public void testGetFlatEntity() throws Exception {
+ public void testGetFlatEntityNotFound() throws Exception {
+ thrown.expect(CoreException.class);
+ thrown.expectMessage(
+ "Entity Type 'org.openecomp.resource.vfc.notFound' or one of its derivedFrom type hierarchy, is not defined in tosca service model");
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
+
+ ServiceTemplate
+ serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ toscaAnalyzerService
+ .getFlatEntity(ToscaElementTypes.NODE_TYPE, "org.openecomp.resource.vfc.notFound",
+ serviceTemplateFromYaml, toscaServiceModel);
+ }
+ }
+
+ @Test
+ public void testGetFlatEntityNodeType() throws Exception {
ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
try (InputStream yamlFile = toscaExtensionYamlUtil
.loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
@@ -123,6 +143,39 @@ public class ToscaAnalyzerServiceImplTest {
Assert.assertNotNull(flatEntity);
Assert.assertEquals("org.openecomp.resource.vfc.nodes.heat.nova.Server", flatEntity
.getDerived_from());
+ Assert.assertEquals(20, flatEntity.getProperties().size());
+ Assert.assertEquals("overridden default value",
+ flatEntity.getProperties().get("admin_pass").get_default());
+ Assert.assertEquals("REBUILD",
+ flatEntity.getProperties().get("image_update_policy").get_default());
+ Assert.assertNotNull(flatEntity.getProperties().get("new_property"));
+ }
+ }
+
+ @Test
+ public void testGetFlatEntityDataType() throws Exception {
+ ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
+ try (InputStream yamlFile = toscaExtensionYamlUtil
+ .loadYamlFileIs("/mock/analyzerService/NestedServiceTemplateReqTest.yaml")) {
+
+ ServiceTemplate
+ serviceTemplateFromYaml =
+ toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
+
+ final DataType flatEntity = (DataType) toscaAnalyzerService
+ .getFlatEntity(ToscaElementTypes.DATA_TYPE,
+ "org.openecomp.datatypes.heat.network.MyNewAddressPair", serviceTemplateFromYaml,
+ toscaServiceModel);
+
+ Assert.assertNotNull(flatEntity);
+ Assert.assertEquals("org.openecomp.datatypes.heat.network.MyAddressPair", flatEntity
+ .getDerived_from());
+ Assert.assertEquals(3, flatEntity.getProperties().size());
+ Assert.assertEquals("overridden default value",
+ flatEntity.getProperties().get("mac_address").get_default());
+ Assert.assertEquals(true,
+ flatEntity.getProperties().get("mac_address").getRequired());
+ Assert.assertNotNull(flatEntity.getProperties().get("new_property"));
}
}