<groupId>org.onap.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.4.9-SNAPSHOT</version>
+ <version>1.4.10-SNAPSHOT</version>
<name>sdc-jtosca</name>
<properties>
import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
private ArrayList<RequirementAssignment> _requirements;
private ArrayList<CapabilityAssignment> _capabilities;
+ @Nullable
+ private NodeTemplate _parentNodeTemplate;
+
// dummy constructor for subclasses that don't want super
public EntityTemplate() {
return;
}
+ public EntityTemplate(String _name,
+ LinkedHashMap<String,Object> _template,
+ String _entityName,
+ LinkedHashMap<String,Object> _customDef) {
+ this(_name, _template, _entityName, _customDef, null);
+ }
+
@SuppressWarnings("unchecked")
public EntityTemplate(String _name,
LinkedHashMap<String,Object> _template,
String _entityName,
- LinkedHashMap<String,Object> _customDef) {
+ LinkedHashMap<String,Object> _customDef,
+ NodeTemplate parentNodeTemplate) {
name = _name;
entityTpl = _template;
customDef = _customDef;
_interfaces = null;
_requirements = null;
_capabilities = null;
+ _parentNodeTemplate = parentNodeTemplate;
}
+ public NodeTemplate getParentNodeTemplate() {
+ return _parentNodeTemplate;
+ }
+
public String getType() {
if(typeDefinition != null) {
String clType = typeDefinition.getClass().getSimpleName();
ArrayList<NodeTemplate> memberNodes;
LinkedHashMap<String,Object> customDef;
Metadata metaData;
-
+
+
+ public Group(String _name, LinkedHashMap<String, Object> _templates,
+ ArrayList<NodeTemplate> _memberNodes,
+ LinkedHashMap<String, Object> _customDef){
+ this(_name, _templates, _memberNodes, _customDef, null);
+ }
public Group(String _name, LinkedHashMap<String, Object> _templates,
ArrayList<NodeTemplate> _memberNodes,
- LinkedHashMap<String, Object> _customDef) {
- super(_name, _templates, "group_type", _customDef);
+ LinkedHashMap<String, Object> _customDef, NodeTemplate parentNodeTemplate) {
+ super(_name, _templates, "group_type", _customDef, parentNodeTemplate);
name = _name;
tpl = _templates;
private static final String METADATA = "metadata";
+ public NodeTemplate(String name,
+ LinkedHashMap<String,Object> ntnodeTemplates,
+ LinkedHashMap<String,Object> ntcustomDef,
+ ArrayList<RelationshipTemplate> ntavailableRelTpls,
+ LinkedHashMap<String,Object> ntavailableRelTypes) {
+ this( name, ntnodeTemplates, ntcustomDef, ntavailableRelTpls,
+ ntavailableRelTypes, null);
+ }
@SuppressWarnings("unchecked")
public NodeTemplate(String name,
LinkedHashMap<String,Object> ntnodeTemplates,
LinkedHashMap<String,Object> ntcustomDef,
ArrayList<RelationshipTemplate> ntavailableRelTpls,
- LinkedHashMap<String,Object> ntavailableRelTypes) {
+ LinkedHashMap<String,Object> ntavailableRelTypes,
+ NodeTemplate parentNodeTemplate) {
- super(name, (LinkedHashMap<String,Object>)ntnodeTemplates.get(name), "node_type", ntcustomDef);
+ super(name, (LinkedHashMap<String,Object>)ntnodeTemplates.get(name),
+ "node_type", ntcustomDef, parentNodeTemplate);
templates = ntnodeTemplates;
_validateFields((LinkedHashMap<String,Object>)templates.get(name));
LinkedHashMap<String,Object> req = new LinkedHashMap<>();
req.put("relationship", CopyUtils.copyLhmOrAl(requirement.getRelationship()));
req.put("type",rtype);
- RelationshipTemplate tpl = new RelationshipTemplate(req, rtype, customDef, this, source);
+ RelationshipTemplate tpl = new RelationshipTemplate(req, rtype, customDef, this, source, getParentNodeTemplate());
relationshipTpl.add(tpl);
}
String targetsType;
ArrayList<Object> triggers;
LinkedHashMap<String,Object> properties;
-
+
public Policy(String _name,
LinkedHashMap<String,Object> _policy,
-// ArrayList<NodeTemplate> targetObjects,
ArrayList<Object> targetObjects,
String _targetsType,
LinkedHashMap<String,Object> _customDef) {
- super(_name,_policy,"policy_type",_customDef);
+ this(_name, _policy, targetObjects, _targetsType, _customDef, null);
+ }
+
+ public Policy(String _name,
+ LinkedHashMap<String,Object> _policy,
+// ArrayList<NodeTemplate> targetObjects,
+ ArrayList<Object> targetObjects,
+ String _targetsType,
+ LinkedHashMap<String,Object> _customDef, NodeTemplate parentNodeTemplate) {
+ super(_name,_policy,"policy_type",_customDef, parentNodeTemplate);
if(_policy.get(METADATA) != null) {
LinkedHashMap<String,Object> metadataMap = (LinkedHashMap<String,Object>)_policy.get(METADATA);
package org.onap.sdc.toscaparser.api;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.onap.sdc.toscaparser.api.elements.PropertyDef;
-import org.onap.sdc.toscaparser.api.elements.StatefulEntityType;
+import com.google.common.collect.Lists;
import org.onap.sdc.toscaparser.api.elements.constraints.Constraint;
import org.onap.sdc.toscaparser.api.elements.constraints.Schema;
import org.onap.sdc.toscaparser.api.functions.Function;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
public class Property {
// TOSCA built-in Property type
+ private static final Logger logger = LoggerFactory.getLogger(Property.class.getName());
private static final String TYPE = "type";
private static final String REQUIRED = "required";
private static final String DESCRIPTION = "description";
private static final String DEFAULT = "default";
private static final String CONSTRAINTS = "constraints";
-
+ private static String ENTRY_SCHEMA = "entry_schema";
+ private static String DATA_TYPE = "datatypes";
+
private static final String[] PROPERTY_KEYS = {
TYPE, REQUIRED, DESCRIPTION, DEFAULT, CONSTRAINTS};
private static final String ENTRYTYPE = "type";
private static final String ENTRYPROPERTIES = "properties";
+ private static final String PATH_DELIMITER = "#";
private static final String[] ENTRY_SCHEMA_KEYS = {
ENTRYTYPE, ENTRYPROPERTIES};
", customDef=" + customDef +
'}';
}
+
+ /**
+ * Retrieves property value as list of strings if<br>
+ * - the value is simple<br>
+ * - the value is list of simple values<br>
+ * - the provided path refers to a simple property inside a data type<br>
+ * @param propertyPath valid name of property for search.<br>
+ * If a name refers to a simple field inside a datatype, the property name should be defined with # delimiter.<br>
+ *
+ * @return List of property values. If not found, empty list will be returned.<br>
+ * If property value is a list either of simple fields or of simple fields inside a datatype, all values from the list should be returned
+ */
+ public List<String> getLeafPropertyValue(String propertyPath) {
+ List<String> propertyValueList = Collections.emptyList();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getLeafPropertyValue=> A new request: propertyPath: {}, value: {}", propertyPath, getValue());
+ }
+ if (propertyPath == null || getValue() == null ||
+ //if entry_schema disappears, it is datatype,
+ // otherwise it is map of simple types - should be ignored
+ isValueMapOfSimpleTypes()) {
+ logger.error("It is a wrong request - ignoring! propertyPath: {}, value: {}", propertyPath, getValue());
+ return propertyValueList;
+ }
+ String[] path = propertyPath.split(PATH_DELIMITER);
+
+ if (Schema.isRequestedTypeSimple(getPropertyTypeByPath(path))) {
+ //the internal property type in the path is either simple or list of simple types
+ if (isValueInsideDataType()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("The requested is an internal simple property inside of a data type");
+ }
+ //requested value is an internal simple property inside of a data type
+ propertyValueList = getSimplePropertyValueForComplexType(path);
+ }
+ else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("The requested property has simple type or list of simple types");
+ }
+ //the requested property is simple type or list of simple types
+ propertyValueList = getSimplePropertyValueForSimpleType();
+ }
+ }
+ return propertyValueList;
+ }
+
+ private boolean isValueMapOfSimpleTypes() {
+ if (getValue() instanceof Map && getEntrySchema() != null) {
+ logger.warn("This property value is a map of simple types");
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isValueInsideDataType() {
+ //value is either a list of values for data type
+ //or data type
+ return (Schema.LIST.equals(getType()) && isDataTypeInEntrySchema())
+ || (getEntrySchema() == null && getType().contains(DATA_TYPE));
+ }
+
+ private Object getSimpleValueFromComplexObject(Object current, String[] path) {
+ if (current == null) {
+ return null;
+ }
+ int index = 0;
+
+ if (path.length > index) {
+ for (int i = index; i < path.length; i++) {
+ if (current instanceof Map) {
+ current = ((Map<String, Object>) current).get(path[i]);
+ } else if (current instanceof List) {
+ current = ((List) current).get(0);
+ i--;
+ }
+ else {
+ return null;
+ }
+ }
+ }
+ if (current != null) {
+ return current;
+ }
+ return null;
+ }
+
+ private List<String> getSimplePropertyValueForSimpleType() {
+ if (getValue() instanceof List || getValue() instanceof Map) {
+ return getSimplePropertyValueForComplexType(null);
+ }
+ return Lists.newArrayList(String.valueOf(value));
+ }
+
+ private List<String> getSimplePropertyValueForComplexType(String[] path) {
+ if (getValue() instanceof List ) {
+ return ((List<Object>) getValue()).stream()
+ .map(v -> {
+ if (path != null) {
+ return getSimpleValueFromComplexObject(v, path);
+ } else {
+ return v;
+ }
+ })
+ //it might be null when get_input can't be resolved
+ // e.g.:
+ // - get_input has two parameters: 1. list and 2. index in this list
+ //and list has no value
+ // - neither value no default is defined for get_input
+ .filter(Objects::nonNull)
+ .map(String::valueOf)
+ .collect(Collectors.toList());
+ }
+ //it is data type
+ List<String> valueList = Lists.newArrayList();
+ String valueString = String.valueOf(getSimpleValueFromComplexObject(getValue(), path));
+ if (Objects.nonNull(valueString)) {
+ valueList.add(valueString);
+ }
+ return valueList;
+ }
+
+ private String getPropertyTypeByPath(String[] path) {
+ String propertyType = calculatePropertyType();
+
+ if (path.length > 0 && !path[0].isEmpty()) {
+ return getInternalPropertyType(propertyType, path, 0);
+ }
+ return propertyType;
+ }
+
+ private String calculatePropertyType() {
+ String propertyType = getType();
+ if (Schema.LIST.equals(propertyType)) {
+ //if it is list, return entry schema type
+ return (String)getEntrySchema().get(ENTRYTYPE);
+ }
+ return propertyType;
+ }
+
+ private String calculatePropertyType(LinkedHashMap<String, Object> property) {
+ String type = (String) property.get(TYPE);
+ if (Schema.LIST.equals(type)) {
+ //it might be a data type
+ return getEntrySchemaType(property);
+ }
+ return type;
+ }
+
+ private String getInternalPropertyType(String dataTypeName, String[] path, int index) {
+ if (path.length > index) {
+ LinkedHashMap<String, Object> complexProperty = (LinkedHashMap<String, Object>)customDef.get(dataTypeName);
+ if (complexProperty != null) {
+ LinkedHashMap<String, Object> dataTypeProperties = (LinkedHashMap<String, Object>) complexProperty.get(ENTRYPROPERTIES);
+ return getPropertyTypeFromCustomDefDeeply(path, index, dataTypeProperties);
+ }
+ }
+ //stop searching - seems as wrong flow: the path is finished but the value is not found yet
+ return null;
+ }
+
+ private String getEntrySchemaType(LinkedHashMap<String, Object> property) {
+ LinkedHashMap<String, Object> entrySchema = (LinkedHashMap<String, Object>)property.get(ENTRY_SCHEMA);
+ if (entrySchema != null) {
+ return (String) entrySchema.get(TYPE);
+ }
+ return null;
+ }
+
+ private String getPropertyTypeFromCustomDefDeeply(String[] path, int index, LinkedHashMap<String, Object> properties) {
+ if (properties != null) {
+ LinkedHashMap<String, Object> foundProperty = (LinkedHashMap<String, Object>) (properties).get(path[index]);
+ if (foundProperty != null) {
+ String propertyType = calculatePropertyType(foundProperty);
+ if (propertyType == null || index == path.length - 1){
+ return propertyType;
+ }
+ return getInternalPropertyType(propertyType, path, index + 1);
+ }
+ }
+ return null;
+ }
+
+ private boolean isDataTypeInEntrySchema() {
+ String entrySchemaType = (String)getEntrySchema().get(ENTRYTYPE);
+ return entrySchemaType != null && entrySchemaType.contains(DATA_TYPE);
+ }
+
+
}
/*python
private NodeTemplate target;
private NodeTemplate source;
private ArrayList<Property> _properties;
-
+
public RelationshipTemplate(LinkedHashMap<String,Object> rtrelationshipTemplate,
String rtname,
LinkedHashMap<String,Object> rtcustomDef,
NodeTemplate rttarget,
NodeTemplate rtsource) {
- super(rtname,rtrelationshipTemplate,"relationship_type",rtcustomDef);
+ this(rtrelationshipTemplate, rtname, rtcustomDef, rttarget, rtsource, null);
+ }
+
+ public RelationshipTemplate(LinkedHashMap<String,Object> rtrelationshipTemplate,
+ String rtname,
+ LinkedHashMap<String,Object> rtcustomDef,
+ NodeTemplate rttarget,
+ NodeTemplate rtsource, NodeTemplate parentNodeTemplate) {
+ super(rtname,rtrelationshipTemplate,"relationship_type",rtcustomDef, parentNodeTemplate);
name = rtname;
target = rttarget;
description = _tplDescription();
inputs = _inputs();
relationshipTemplates =_relationshipTemplates();
+ //todo: pass subMappedNodeTemplate to ET constractor
nodeTemplates = _nodeTemplates();
outputs = _outputs();
if(nodeTemplates != null) {
tpls,
customDefs,
relationshipTemplates,
- relTypes);
+ relTypes,
+ subMappedNodeTemplate);
if(tpl.getTypeDefinition() != null) {
boolean b = NodeType.TOSCA_DEF.get(tpl.getType()) != null;
if(b || (tpl.getCustomDef() != null && !tpl.getCustomDef().isEmpty())) {
if(tpls != null) {
for(String name: tpls.keySet()) {
RelationshipTemplate tpl = new RelationshipTemplate(
- (LinkedHashMap<String,Object>)tpls.get(name),name,customDefs,null,null);
+ (LinkedHashMap<String,Object>)tpls.get(name),name,customDefs,null,null, subMappedNodeTemplate);
alRelationshipTemplates.add(tpl);
}
policyTpl,
targetObjects,
targetsType,
- customDefs);
+ customDefs,
+ subMappedNodeTemplate);
alPolicies.add(policyObj);
}
return alPolicies;
Group group = new Group(groupName,
groupTpl,
memberNodes,
- customDefs);
+ customDefs, subMappedNodeTemplate);
groups.add(group);
}
return groups;
if(tpl.get(INPUTS) != null) {
return (LinkedHashMap<String,Object>)tpl.get(INPUTS);
}
- else {
- return new LinkedHashMap<String,Object>();
- }
+ return new LinkedHashMap<String,Object>();
}
@SuppressWarnings("unchecked")
if(tpl.get(RELATIONSHIP_TEMPLATES) != null) {
return (LinkedHashMap<String,Object>)tpl.get(RELATIONSHIP_TEMPLATES);
}
- else {
- return new LinkedHashMap<String,Object>();
- }
+ return new LinkedHashMap<String,Object>();
}
@SuppressWarnings("unchecked")
private LinkedHashMap<String,Object> _tplOutputs() {
- if(tpl.get(OUTPUTS) != null) {
- return (LinkedHashMap<String,Object>)tpl.get(OUTPUTS);
- }
- else {
- return new LinkedHashMap<String,Object>();
- }
+ if(tpl.get(OUTPUTS) != null) {
+ return (LinkedHashMap<String,Object>)tpl.get(OUTPUTS);
+ }
+ return new LinkedHashMap<String,Object>();
}
@SuppressWarnings("unchecked")
if(tpl.get(SUBSTITUTION_MAPPINGS) != null) {
return (LinkedHashMap<String,Object>)tpl.get(SUBSTITUTION_MAPPINGS);
}
- else {
- return new LinkedHashMap<String,Object>();
- }
+ return new LinkedHashMap<String,Object>();
}
@SuppressWarnings("unchecked")
if(tpl.get(GROUPS) != null) {
return (LinkedHashMap<String,Object>)tpl.get(GROUPS);
}
- else {
- return new LinkedHashMap<String,Object>();
- }
+ return new LinkedHashMap<String,Object>();
}
@SuppressWarnings("unchecked")
if(tpl.get(POLICIES) != null) {
return (LinkedHashMap<String,Object>)tpl.get(POLICIES);
}
- else {
- return new LinkedHashMap<>();
- }
+ return new LinkedHashMap<>();
}
private void _validateField() {
import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
INTEGER, STRING, BOOLEAN, FLOAT, RANGE,NUMBER, TIMESTAMP, LIST, MAP,
SCALAR_UNIT_SIZE, SCALAR_UNIT_FREQUENCY, SCALAR_UNIT_TIME,
VERSION, PORTDEF, PORTSPEC, JSON};
+
+ public static final String SIMPLE_PROPERTY_TYPES[] = {
+ INTEGER, STRING, BOOLEAN, FLOAT, RANGE,NUMBER, TIMESTAMP,
+ SCALAR_UNIT_SIZE, SCALAR_UNIT_FREQUENCY, SCALAR_UNIT_TIME,
+ VERSION};
@SuppressWarnings("unused")
private static final String SCALAR_UNIT_SIZE_DEFAULT = "B";
return (String)schema.getOrDefault(STATUS,"");
}
+ public static boolean isRequestedTypeSimple(String type) {
+ return Arrays.stream(SIMPLE_PROPERTY_TYPES).anyMatch(t->t.equals(type));
+ }
+
@SuppressWarnings("unchecked")
public ArrayList<Constraint> getConstraints() {
if(constraintsList.size() == 0) {
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
assertNull(nodeTemplate.getPropertyValueFromTemplatesByName("test"));
}
+ @Test
+ public void testGetParentNodeTemplateTest() throws JToscaException {
+
+ String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/service-AdiodVmxVpeBvService-csar.csar").getFile();
+ File file = new File(fileStr);
+ ToscaTemplate toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ NodeTemplate nodeTemplate = toscaTemplate.getNodeTemplates().get(0);
+ //parent of this VF is service (null)
+ assertNull(nodeTemplate.getParentNodeTemplate());
+ List<NodeTemplate> children = nodeTemplate.getSubMappingToscaTemplate().getNodeTemplates();
+ assertFalse(children.isEmpty());
+ NodeTemplate cVFC = children.get(4);
+ //parent is the VF above
+ assertEquals("2017-488_ADIOD-vPE 0", cVFC.getParentNodeTemplate().getName());
+ List<NodeTemplate> children1 = cVFC.getSubMappingToscaTemplate().getNodeTemplates();
+ assertFalse(children1.isEmpty());
+ //parent is the CVFC above
+ assertEquals(cVFC, children1.get(0).getParentNodeTemplate());
+
+/*
+
+ TopologyTemplate tt = nodeTemplate.getOriginComponentTemplate();
+ List<Group> groups = tt.getGroups();
+ List<Policy> policies = tt.getPolicies();
+
+ TopologyTemplate tt1 = cVFC.getOriginComponentTemplate();
+ groups = tt.getGroups();
+ policies = tt.getPolicies();
+*/
+
+ }
+
@Test
public void testNullValueHasNoNullPointerException() throws JToscaException {
--- /dev/null
+package org.onap.sdc.toscaparser.api.elements;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.sdc.toscaparser.api.JToscaImportTest;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.common.JToscaException;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CalculatePropertyByPathTest {
+ private static ToscaTemplate toscaTemplate;
+
+ @BeforeClass
+ public static void setUpClass() throws JToscaException {
+ URL scarUrl = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar");
+ if (scarUrl != null) {
+ File file = new File(scarUrl.getFile());
+ toscaTemplate = new ToscaTemplate(file.getAbsolutePath(), null, true, null);
+ }
+
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasListOfDataTypesAndPathIsNotEmpty() throws JToscaException {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0); //testVM_testVM_SRIOVtrunk1_port
+
+ Property property = cp.getProperties().get("related_networks");
+ List<String> propertyValueList = property.getLeafPropertyValue("related_network_role");
+ assertEquals(3, propertyValueList.size());
+ assertTrue(propertyValueList.contains("cor_direct_2"));
+ assertTrue(propertyValueList.contains("sgi_direct_2"));
+ assertTrue(propertyValueList.contains("int_imbl_2"));
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasDataTypeAndPathIsEmpty() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(1); //testVM_testVM_SRIOVNonTrunk0_port
+
+ Property property = cp.getProperties().get("exCP_naming");
+ List<String> propertyValueList = property.getLeafPropertyValue("");
+ assertTrue(propertyValueList.isEmpty());
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasSimpleTypeAndValueAsGetInputIsNotResolvedCorrectlyAndPathIsEmpty() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(1); //testVM_testVM_SRIOVNonTrunk0_port
+
+ Property property = cp.getProperties().get("network");
+ List<String> propertyValueList = property.getLeafPropertyValue("");
+ assertTrue(propertyValueList.isEmpty());
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasSimpleTypeAndPathIsEmpty() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(1); //testVM_testVM_SRIOVNonTrunk0_port
+
+ Property property = cp.getProperties().get("subinterface_indicator");
+ List<String> propertyValueList = property.getLeafPropertyValue("");
+ assertEquals(1, propertyValueList.size());
+ assertEquals("false", propertyValueList.get(0));
+ }
+
+
+ @Test
+ public void testGetPropertyWhenPropertyHasDataTypeAndPathIsNotEmpty() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(2); //testVM_testVM_OVS_port
+
+ Property property = cp.getProperties().get("ip_requirements");
+ List<String> propertyValueList = property.getLeafPropertyValue("ip_version");
+ assertEquals(1, propertyValueList.size());
+ assertEquals("4", propertyValueList.get(0));
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasListOfDataTypesAndPathIsNull() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(2); //testVM_testVM_OVS_port
+
+ Property property = cp.getProperties().get("ip_requirements");
+ assertTrue(property.getLeafPropertyValue(null).isEmpty());
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasListOfDataTypesAndPathIsComplex() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0); //testVM_testVM_SRIOVtrunk1_port
+
+ Property property = cp.getProperties().get("ip_requirements");
+ List<String> propertyValueList = property.getLeafPropertyValue("ip_count_required#is_required");
+ assertEquals(1, propertyValueList.size());
+ assertEquals("false", propertyValueList.get(0));
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasListOfDataTypesAndPathIsWrong() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0); //testVM_testVM_SRIOVtrunk1_port
+
+ Property property = cp.getProperties().get("ip_requirements");
+ List<String> propertyValueList = property.getLeafPropertyValue("ip_count_required#is_required_1");
+ assertEquals(0, propertyValueList.size());
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasDataTypeWithoutSchemaAndComplexPath() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0); //testVM_testVM_SRIOVtrunk1_port
+
+ Property property = cp.getProperties().get("mac_requirements");
+ List<String> propertyValueList = property.getLeafPropertyValue("mac_count_required#is_required");
+ assertEquals(1, propertyValueList.size());
+ assertEquals("false", propertyValueList.get(0));
+ }
+
+ @Test
+ public void testGetPropertyWhenPropertyHasDataTypeWithoutSchemaAndSimplePath() {
+ NodeTemplate cp = toscaTemplate.getNodeTemplates().get(0) //Network Cloud VNF MOCK 0
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0) //abstract_testVM
+ .getSubMappingToscaTemplate().getNodeTemplates().get(0); //testVM_testVM_SRIOVtrunk1_port
+
+ Property property = cp.getProperties().get("mac_requirements");
+ List<String> propertyValueList = property.getLeafPropertyValue("mac_count_required");
+ assertEquals(0, propertyValueList.size());
+ }
+}
major=1
minor=4
-patch=9
+patch=10
base_version=${major}.${minor}.${patch}