summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib/src/test
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
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')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java55
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml38
2 files changed, 92 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"));
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml
index ce02d0c034..8022d996b7 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/mock/analyzerService/NestedServiceTemplateReqTest.yaml
@@ -25,6 +25,44 @@ imports:
node_types:
org.openecomp.resource.vfc.nodes.heat.cmaui_image:
derived_from: org.openecomp.resource.vfc.nodes.heat.nova.Server
+ properties:
+ admin_pass:
+ description: The administrator password for the server
+ type: string
+ status: SUPPORTED
+ default: overridden default value
+ required: false
+ new_property:
+ description: new property
+ type: string
+ status: SUPPORTED
+ required: false
+data_types:
+ org.openecomp.datatypes.heat.network.MyAddressPair:
+ derived_from: org.openecomp.datatypes.heat.network.AddressPair
+ description: My MAC/IP address pairs
+ properties:
+ mac_address:
+ description: MAC address
+ type: string
+ status: SUPPORTED
+ required: false
+ default: overridden default value
+ new_property:
+ description: new property
+ type: string
+ status: SUPPORTED
+ required: false
+ org.openecomp.datatypes.heat.network.MyNewAddressPair:
+ derived_from: org.openecomp.datatypes.heat.network.MyAddressPair
+ description: My new MAC/IP address pairs
+ properties:
+ mac_address:
+ description: MAC address
+ type: string
+ status: SUPPORTED
+ required: true
+ default: overridden default value
topology_template:
inputs:
cmaui_names: