<groupId>org.onap.sdc.jtosca</groupId>
<artifactId>jtosca</artifactId>
- <version>1.4.4-SNAPSHOT</version>
+ <version>1.4.5-SNAPSHOT</version>
<name>sdc-jtosca</name>
<properties>
public LinkedHashMap<String,Property> getProperties() {
LinkedHashMap<String,Property> props = new LinkedHashMap<>();
for(Property po: getPropertiesObjects()) {
- props.put(((Property)po).getName(),po);
+ props.put(po.getName(),po);
}
return props;
}
public Object getPropertyValue(String name) {
- LinkedHashMap<String,Property> props = getProperties();
- Property p = (Property)props.get(name);
- return p != null ? p.getValue() : null;
- }
+ LinkedHashMap<String,Property> props = getProperties();
+ Property p = props.get(name);
+ return p != null ? p.getValue() : null;
+ }
+
+ public String getPropertyType(String name) {
+ Property property = getProperties().get(name);
+ if (property != null) {
+ return property.getType();
+ }
+ return null;
+ }
public ArrayList<InterfacesDef> getInterfaces() {
if(_interfaces == null) {
package org.onap.sdc.toscaparser.api;
import static org.onap.sdc.toscaparser.api.elements.EntityType.TOSCA_DEF;
+
+import com.google.common.collect.Lists;
import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
import java.util.ArrayList;
private static final String METADATA = "metadata";
+
@SuppressWarnings("unchecked")
public NodeTemplate(String name,
LinkedHashMap<String,Object> ntnodeTemplates,
}
}
+ public Object getPropertyValueFromTemplatesByName(String propertyName) {
+ LinkedHashMap<String,Object> nodeObject = (LinkedHashMap<String,Object>) templates.get(name);
+ if (nodeObject != null) {
+ LinkedHashMap<String,Object> properties = (LinkedHashMap<String, Object>)nodeObject.get(PROPERTIES);
+ if (properties != null) {
+ return properties.get(propertyName);
+ }
+ }
+ return null;
+ }
+
private Metadata _metaData() {
if(entityTpl.get(METADATA) != null) {
return new Metadata((Map<String,Object>)entityTpl.get(METADATA));
return ((ArrayList) value).get((Integer) args.get(1));
}
/* commented out for network cloud (SDNC)
- else{
- ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE273",String.format(
+ ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE273",String.format(
"GetInputError: cannot resolve input name \"%s\", the expected structure is an argument with a name of input type list and a second argument with an index in the list", args.get(0))));
- return null;
- }*/
+ return null;
+*/
}
return value;
}
if ( args.get(1) instanceof Integer
&& ((ArrayList) inputDef.getDefault()).size()> ((Integer)args.get(1)).intValue()) {
return ((ArrayList) inputDef.getDefault()).get(((Integer)args.get(1)).intValue());
- }else{
- ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE274",(String.format(
- "GetInputError: cannot resolve input Def name \"%s\", the expected structure is an argument with a name of input type list and a second argument with an index in the list", args.get(0)))));
- return null;
}
+/*
+ commented out for network cloud (SDNC)
+ ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE274",(String.format(
+ "GetInputError: cannot resolve input Def name \"%s\", the expected structure is an argument with a name of input type list and a second argument with an index in the list", args.get(0)))));
+ return null;
+*/
}
return inputDef.getDefault();
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class JToscaImportTest {
assertTrue(inputs.stream().filter(i -> i.getAnnotations() != null).collect(Collectors.toList()).isEmpty());
}
- private void validateInputsAnnotations(List<Input> inputs) {
+ @Test
+ public void testGetPropertyNameTest() 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);
+
+ ArrayList<String> valueList = (ArrayList<String>)nodeTemplate.getPropertyValueFromTemplatesByName("vmxvpfe_sriov41_0_port_vlanfilter");
+ assertEquals(4, valueList.size());
+
+ assertEquals("vPE", (String) nodeTemplate.getPropertyValueFromTemplatesByName("nf_role"));
+
+ assertNull(nodeTemplate.getPropertyValueFromTemplatesByName("test"));
+ }
+
+ private void validateInputsAnnotations(List<Input> inputs) {
List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null)
.collect(Collectors.toList());
assertTrue(!inputs.isEmpty());
major=1
minor=4
-patch=4
+patch=5
base_version=${major}.${minor}.${patch}