Program: 62363
Project: 62363
Buggy source:
/** 
 * Parse an attribute value that can be :   {@link ConcatPropertyValue} / {@link AttributeDefinition}
 * @param attributeId
 * @param attributeValue
 * @param topology
 * @param runtimeInformations
 * @param currentInstance
 * @param basePaaSTemplate
 * @param builtPaaSTemplates
 * @return
 */
public static String parseAttribute(String attributeId,IValue attributeValue,Topology topology,Map<String,Map<String,InstanceInformation>> runtimeInformations,String currentInstance,IPaaSTemplate<? extends IndexedToscaElement> 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("String_Node_Str") && !runtimeAttributeValue.equals("String_Node_Str") && !runtimeAttributeValue.equals(null)) {
        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="String_Node_Str" + functionPropertyValue.getElementNameToFetch() + "String_Node_Str";
evaluatedAttribute.append(extractRuntimeInformationOperationOutput(runtimeInformations,currentInstance,paasTemplates,functionPropertyValue,defaultValue));
default :
log.warn("String_Node_Str",functionPropertyValue.getFunction());
}
}
}
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;
}

Fixed version (ground truth):
/** 
 * Parse an attribute value that can be :   {@link ConcatPropertyValue} / {@link AttributeDefinition}
 * @param attributeId
 * @param attributeValue
 * @param topology
 * @param runtimeInformations
 * @param currentInstance
 * @param basePaaSTemplate
 * @param builtPaaSTemplates
 * @return
 */
public static String parseAttribute(String attributeId,IValue attributeValue,Topology topology,Map<String,Map<String,InstanceInformation>> runtimeInformations,String currentInstance,IPaaSTemplate<? extends IndexedToscaElement> 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("String_Node_Str") && !runtimeAttributeValue.equals("String_Node_Str")) {
        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="String_Node_Str" + functionPropertyValue.getElementNameToFetch() + "String_Node_Str";
evaluatedAttribute.append(extractRuntimeInformationOperationOutput(runtimeInformations,currentInstance,paasTemplates,functionPropertyValue,defaultValue));
break;
default :
log.warn("String_Node_Str",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;
}