FunctionEvaluator { public static String parseAttribute(String attributeId, IValue attributeValue, Topology topology, Map<String, Map<String, InstanceInformation>> runtimeInformations, String currentInstance, IPaaSTemplate<? extends AbstractToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates) { if (attributeValue == null) { return null; } if (attributeValue instanceof AttributeDefinition) { String runtimeAttributeValue = extractRuntimeInformationAttribute(runtimeInformations, currentInstance, Lists.newArrayList(basePaaSTemplate), attributeId); if (runtimeAttributeValue != null) { if (!runtimeAttributeValue.contains("=Error!]") && !runtimeAttributeValue.equals("")) { return runtimeAttributeValue; } } return ((AttributeDefinition) attributeValue).getDefault(); } if (attributeValue instanceof ConcatPropertyValue) { StringBuilder evaluatedAttribute = new StringBuilder(); ConcatPropertyValue concatPropertyValue = (ConcatPropertyValue) attributeValue; for (IValue concatParam : concatPropertyValue.getParameters()) { if (concatParam instanceof ScalarPropertyValue) { evaluatedAttribute.append(((ScalarPropertyValue) concatParam).getValue()); } else if (concatParam instanceof PropertyDefinition) { evaluatedAttribute.append(((PropertyDefinition) concatParam).getDefault()); } else if (concatParam instanceof FunctionPropertyValue) { FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) concatParam; List<? extends IPaaSTemplate> paasTemplates = getPaaSTemplatesFromKeyword(basePaaSTemplate, functionPropertyValue.getTemplateName(), builtPaaSTemplates); switch (functionPropertyValue.getFunction()) { case ToscaFunctionConstants.GET_ATTRIBUTE: evaluatedAttribute.append(extractRuntimeInformationAttribute(runtimeInformations, currentInstance, paasTemplates, functionPropertyValue.getElementNameToFetch())); break; case ToscaFunctionConstants.GET_PROPERTY: evaluatedAttribute.append(extractRuntimeInformationProperty(topology, functionPropertyValue.getElementNameToFetch(), paasTemplates)); break; case ToscaFunctionConstants.GET_OPERATION_OUTPUT: String defaultValue = "<" + functionPropertyValue.getElementNameToFetch() + ">"; evaluatedAttribute.append(extractRuntimeInformationOperationOutput(runtimeInformations, currentInstance, paasTemplates, functionPropertyValue, defaultValue)); break; default: log.warn("Function [{}] is not yet handled in concat operation.", functionPropertyValue.getFunction()); break; } } } return evaluatedAttribute.toString(); } if (attributeValue instanceof FunctionPropertyValue) { FunctionPropertyValue function = (FunctionPropertyValue) attributeValue; switch (function.getFunction()) { case ToscaFunctionConstants.GET_OPERATION_OUTPUT: List<? extends IPaaSTemplate> paasTemplates = getPaaSTemplatesFromKeyword(basePaaSTemplate, function.getTemplateName(), builtPaaSTemplates); return extractRuntimeInformationOperationOutput(runtimeInformations, currentInstance, paasTemplates, function, null); default: return null; } } return null; }  static String parseAttribute(String attributeId, IValue attributeValue, Topology topology,
            Map<String, Map<String, InstanceInformation>> runtimeInformations, String currentInstance,
            IPaaSTemplate<? extends AbstractToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates); static List<? extends IPaaSTemplate> getPaaSTemplatesFromKeyword(IPaaSTemplate<? extends AbstractToscaType> basePaaSTemplate, String keyword,
            Map<String, PaaSNodeTemplate> builtPaaSTemplates); static String evaluateGetPropertyFunction(FunctionPropertyValue functionParam,
            IPaaSTemplate<? extends AbstractInheritableToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates); static AbstractPropertyValue processGetPropertyFunction(FunctionPropertyValue functionParam,
            IPaaSTemplate<? extends AbstractInheritableToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates); static Map<String, String> getScalarValues(Map<String, AbstractPropertyValue> propertyValues); static boolean isGetAttribute(FunctionPropertyValue function); static boolean isGetOperationOutput(FunctionPropertyValue function); static boolean isGetInput(AbstractPropertyValue propertyValue); static boolean isGetInput(FunctionPropertyValue function); static boolean isGetSecret(AbstractPropertyValue propertyValue); static boolean isGetSecret(FunctionPropertyValue function);  }
@Test public void testParseAttributConcatScalar() { Map<String, NodeTemplate> nodeTemplates = Maps.newHashMap(); NodeTemplate nodeTemplate1 = new NodeTemplate(); nodeTemplate1.setProperties( MapUtil.newHashMap(new String[] { "the_property_name_1" }, new AbstractPropertyValue[] { new ScalarPropertyValue("the_property_value_1") })); nodeTemplates.put("the_node_tempalte_1", nodeTemplate1); NodeTemplate nodeTemplate2 = new NodeTemplate(); nodeTemplate2.setProperties( MapUtil.newHashMap(new String[] { "the_property_name_2" }, new AbstractPropertyValue[] { new ScalarPropertyValue("the_property_value_2") })); nodeTemplates.put("the_node_tempalte_2", nodeTemplate2); Topology topology = new Topology(); topology.setNodeTemplates(nodeTemplates); Map<String, Map<String, InstanceInformation>> runtimeInformations = Maps.newHashMap(); ConcatPropertyValue concatAttributeValue = new ConcatPropertyValue(); ScalarPropertyValue scalarParameter1 = new ScalarPropertyValue(); ScalarPropertyValue scalarParameter2 = new ScalarPropertyValue(); ScalarPropertyValue scalarParameter3 = new ScalarPropertyValue(); ScalarPropertyValue scalarParameter4 = new ScalarPropertyValue(); scalarParameter1.setValue("http: scalarParameter2.setValue("mywebsiteurl"); scalarParameter3.setValue(":"); scalarParameter4.setValue("port"); concatAttributeValue.setParameters(new ArrayList<>()); concatAttributeValue.getParameters().add(scalarParameter1); concatAttributeValue.getParameters().add(scalarParameter2); concatAttributeValue.getParameters().add(scalarParameter3); concatAttributeValue.getParameters().add(scalarParameter4); String parsedConcatString = FunctionEvaluator.parseAttribute(null, concatAttributeValue, topology, runtimeInformations, "0", null, null); String fullUrl = scalarParameter1.getValue() + scalarParameter2.getValue() + scalarParameter3.getValue() + scalarParameter4.getValue(); Assert.assertEquals(fullUrl, parsedConcatString); }