use of org.alien4cloud.tosca.model.definitions.PropertyValue in project yorc-a4c-plugin by ystia.
the class ToscaComponentUtils method formatOperationInputs.
public static String formatOperationInputs(int indentLevel, Map<String, ? extends IValue> properties) throws IOException {
StringBuilder buffer = new StringBuilder();
for (Map.Entry<String, ? extends IValue> propertyEntry : properties.entrySet()) {
if (propertyEntry.getValue() != null) {
if (propertyEntry.getValue() instanceof PropertyValue && ((PropertyValue) propertyEntry.getValue()).getValue() == null) {
continue;
}
buffer.append("\n").append(ToscaPropertySerializerUtils.indent(indentLevel)).append(propertyEntry.getKey()).append(": ");
if (!propertyEntry.getValue().isDefinition()) {
buffer.append(ToscaPropertySerializerUtils.formatPropertyValue(indentLevel, (AbstractPropertyValue) propertyEntry.getValue()));
} else {
Map<String, Object> velocityContext = ToscaComponentExporter.getVelocityContext();
velocityContext.put("indent", indentLevel + 1);
String template;
if (propertyEntry.getValue() instanceof PropertyDefinition) {
velocityContext.put("property", propertyEntry.getValue());
template = "org/ystia/yorc/alien4cloud/plugin/tosca/property_def.vm";
} else if (propertyEntry.getValue() instanceof AttributeDefinition) {
velocityContext.put("attribute", propertyEntry.getValue());
template = "org/ystia/yorc/alien4cloud/plugin/tosca/attribute_def.vm";
} else {
throw new RuntimeException("Unsupported type: " + propertyEntry.getValue().getClass());
}
StringWriter writer = new StringWriter();
VelocityUtil.generate(template, writer, velocityContext);
buffer.append("\n").append(ToscaPropertySerializerUtils.indent(indentLevel + 1)).append(writer.toString());
}
}
}
return buffer.toString();
}
use of org.alien4cloud.tosca.model.definitions.PropertyValue in project alien4cloud by alien4cloud.
the class FunctionEvaluatorTest method nodeGetComplexPropList.
@Test
public void nodeGetComplexPropList() {
FunctionEvaluatorContext context = getEvaluationContext();
NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("get_complex_prop_list"));
Assert.assertNotNull(resolved);
Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
Assert.assertEquals("list value 2", resolved.getValue());
}
use of org.alien4cloud.tosca.model.definitions.PropertyValue in project alien4cloud by alien4cloud.
the class FunctionEvaluatorTest method nodeGetComplexPropMap.
@Test
public void nodeGetComplexPropMap() {
FunctionEvaluatorContext context = getEvaluationContext();
NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("get_complex_prop_map"));
Assert.assertNotNull(resolved);
Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
Assert.assertEquals("element 1 value", resolved.getValue());
}
use of org.alien4cloud.tosca.model.definitions.PropertyValue in project alien4cloud by alien4cloud.
the class FunctionEvaluatorTest method nodeConcatGetConcatProp.
@Test
public void nodeConcatGetConcatProp() {
FunctionEvaluatorContext context = getEvaluationContext();
NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("concat_get_concat_prop"));
Assert.assertNotNull(resolved);
Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
Assert.assertEquals("get concat is: input is: scalar input value property is: scalar value", resolved.getValue());
}
use of org.alien4cloud.tosca.model.definitions.PropertyValue in project alien4cloud by alien4cloud.
the class FunctionEvaluatorTest method nodeGetConcatProp.
@Test
public void nodeGetConcatProp() {
FunctionEvaluatorContext context = getEvaluationContext();
NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("get_concat_prop"));
Assert.assertNotNull(resolved);
Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
Assert.assertEquals("input is: scalar input value property is: scalar value", resolved.getValue());
}
Aggregations