Program: 62373
Project: 62373
Buggy source:
/** 
 * Process the composition: <ul> <li>remove the 'proxy' node from the parent. <li>merge the child topology nodes into the parent nodes. <li> </ul>
 * @param compositionCouple
 */
private void processComposition(CompositionCouple compositionCouple){
  NodeTemplate proxyNodeTemplate=compositionCouple.parent.getNodeTemplates().remove(compositionCouple.nodeName);
  for (  NodeTemplate childNodeTemplate : compositionCouple.child.getNodeTemplates().values()) {
    for (    Entry<String,AbstractPropertyValue> propertyEntry : childNodeTemplate.getProperties().entrySet()) {
      AbstractPropertyValue pValue=propertyEntry.getValue();
      if (pValue instanceof FunctionPropertyValue && ((FunctionPropertyValue)pValue).getFunction().equals(ToscaFunctionConstants.GET_INPUT)) {
        String inputName=((FunctionPropertyValue)pValue).getTemplateName();
        propertyEntry.setValue(proxyNodeTemplate.getProperties().get(inputName));
      }
    }
  }
  if (proxyNodeTemplate.getRelationships() != null) {
    for (    Entry<String,RelationshipTemplate> e : proxyNodeTemplate.getRelationships().entrySet()) {
      String relationShipKey=e.getKey();
      RelationshipTemplate proxyRelationShip=e.getValue();
      String requirementName=proxyRelationShip.getRequirementName();
      SubstitutionTarget substitutionTarget=compositionCouple.child.getSubstitutionMapping().getRequirements().get(requirementName);
      NodeTemplate nodeTemplate=compositionCouple.child.getNodeTemplates().get(substitutionTarget.getNodeTemplateName());
      if (nodeTemplate.getRelationships() == null) {
        Map<String,RelationshipTemplate> relationships=Maps.newHashMap();
        nodeTemplate.setRelationships(relationships);
      }
      nodeTemplate.getRelationships().put(relationShipKey,proxyRelationShip);
      proxyRelationShip.setRequirementName(substitutionTarget.getTargetId());
    }
  }
  for (  NodeTemplate otherNodes : compositionCouple.parent.getNodeTemplates().values()) {
    if (otherNodes.getRelationships() != null) {
      for (      RelationshipTemplate relationshipTemplate : otherNodes.getRelationships().values()) {
        if (relationshipTemplate.getTarget().equals(compositionCouple.nodeName)) {
          SubstitutionTarget st=compositionCouple.child.getSubstitutionMapping().getCapabilities().get(relationshipTemplate.getTargetedCapabilityName());
          relationshipTemplate.setTarget(st.getNodeTemplateName());
          relationshipTemplate.setTargetedCapabilityName(st.getTargetId());
        }
      }
    }
  }
  if (compositionCouple.parent.getOutputAttributes() != null) {
    Set<String> outputAttributes=compositionCouple.parent.getOutputAttributes().remove(compositionCouple.nodeName);
    if (outputAttributes != null) {
      for (      String proxyAttributeName : outputAttributes) {
        sustituteGetAttribute(compositionCouple.child,compositionCouple.parent,proxyAttributeName);
      }
    }
  }
  if (compositionCouple.parent.getSubstitutionMapping() != null) {
    if (compositionCouple.parent.getSubstitutionMapping().getCapabilities() != null) {
      for (      Entry<String,SubstitutionTarget> substitutionCapabilityEntry : compositionCouple.parent.getSubstitutionMapping().getCapabilities().entrySet()) {
        if (substitutionCapabilityEntry.getValue().getNodeTemplateName().equals(compositionCouple.nodeName)) {
          String targetCapability=substitutionCapabilityEntry.getValue().getTargetId();
          substitutionCapabilityEntry.setValue(compositionCouple.child.getSubstitutionMapping().getCapabilities().get(targetCapability));
        }
      }
    }
    if (compositionCouple.parent.getSubstitutionMapping().getRequirements() != null) {
      for (      Entry<String,SubstitutionTarget> e : compositionCouple.parent.getSubstitutionMapping().getRequirements().entrySet()) {
        if (e.getValue().getNodeTemplateName().equals(compositionCouple.nodeName)) {
          String targetCapability=e.getValue().getTargetId();
          e.setValue(compositionCouple.child.getSubstitutionMapping().getRequirements().get(targetCapability));
        }
      }
    }
  }
  compositionCouple.parent.getNodeTemplates().putAll(compositionCouple.child.getNodeTemplates());
}

Fixed version (ground truth):
/** 
 * Process the composition: <ul> <li>remove the 'proxy' node from the parent. <li>merge the child topology nodes into the parent nodes. <li> </ul>
 * @param compositionCouple
 */
private void processComposition(CompositionCouple compositionCouple){
  NodeTemplate proxyNodeTemplate=compositionCouple.parent.getNodeTemplates().remove(compositionCouple.nodeName);
  for (  NodeTemplate childNodeTemplate : compositionCouple.child.getNodeTemplates().values()) {
    for (    Entry<String,AbstractPropertyValue> propertyEntry : childNodeTemplate.getProperties().entrySet()) {
      AbstractPropertyValue pValue=propertyEntry.getValue();
      if (pValue instanceof FunctionPropertyValue && ((FunctionPropertyValue)pValue).getFunction().equals(ToscaFunctionConstants.GET_INPUT)) {
        String inputName=((FunctionPropertyValue)pValue).getTemplateName();
        propertyEntry.setValue(proxyNodeTemplate.getProperties().get(inputName));
      }
    }
    for (    Entry<String,Capability> capabilityEntry : childNodeTemplate.getCapabilities().entrySet()) {
      if (capabilityEntry.getValue().getProperties() != null) {
        for (        Entry<String,AbstractPropertyValue> propertyEntry : capabilityEntry.getValue().getProperties().entrySet()) {
          AbstractPropertyValue pValue=propertyEntry.getValue();
          if (pValue instanceof FunctionPropertyValue && ((FunctionPropertyValue)pValue).getFunction().equals(ToscaFunctionConstants.GET_INPUT)) {
            String inputName=((FunctionPropertyValue)pValue).getTemplateName();
            propertyEntry.setValue(proxyNodeTemplate.getProperties().get(inputName));
          }
        }
      }
    }
  }
  if (proxyNodeTemplate.getRelationships() != null) {
    for (    Entry<String,RelationshipTemplate> e : proxyNodeTemplate.getRelationships().entrySet()) {
      String relationShipKey=e.getKey();
      RelationshipTemplate proxyRelationShip=e.getValue();
      String requirementName=proxyRelationShip.getRequirementName();
      SubstitutionTarget substitutionTarget=compositionCouple.child.getSubstitutionMapping().getRequirements().get(requirementName);
      NodeTemplate nodeTemplate=compositionCouple.child.getNodeTemplates().get(substitutionTarget.getNodeTemplateName());
      if (nodeTemplate.getRelationships() == null) {
        Map<String,RelationshipTemplate> relationships=Maps.newHashMap();
        nodeTemplate.setRelationships(relationships);
      }
      nodeTemplate.getRelationships().put(relationShipKey,proxyRelationShip);
      proxyRelationShip.setRequirementName(substitutionTarget.getTargetId());
    }
  }
  for (  NodeTemplate otherNodes : compositionCouple.parent.getNodeTemplates().values()) {
    if (otherNodes.getRelationships() != null) {
      for (      RelationshipTemplate relationshipTemplate : otherNodes.getRelationships().values()) {
        if (relationshipTemplate.getTarget().equals(compositionCouple.nodeName)) {
          SubstitutionTarget st=compositionCouple.child.getSubstitutionMapping().getCapabilities().get(relationshipTemplate.getTargetedCapabilityName());
          relationshipTemplate.setTarget(st.getNodeTemplateName());
          relationshipTemplate.setTargetedCapabilityName(st.getTargetId());
        }
      }
    }
  }
  if (compositionCouple.parent.getOutputAttributes() != null) {
    Set<String> outputAttributes=compositionCouple.parent.getOutputAttributes().remove(compositionCouple.nodeName);
    if (outputAttributes != null) {
      for (      String proxyAttributeName : outputAttributes) {
        sustituteGetAttribute(compositionCouple.child,compositionCouple.parent,proxyAttributeName);
      }
    }
  }
  if (compositionCouple.parent.getSubstitutionMapping() != null) {
    if (compositionCouple.parent.getSubstitutionMapping().getCapabilities() != null) {
      for (      Entry<String,SubstitutionTarget> substitutionCapabilityEntry : compositionCouple.parent.getSubstitutionMapping().getCapabilities().entrySet()) {
        if (substitutionCapabilityEntry.getValue().getNodeTemplateName().equals(compositionCouple.nodeName)) {
          String targetCapability=substitutionCapabilityEntry.getValue().getTargetId();
          substitutionCapabilityEntry.setValue(compositionCouple.child.getSubstitutionMapping().getCapabilities().get(targetCapability));
        }
      }
    }
    if (compositionCouple.parent.getSubstitutionMapping().getRequirements() != null) {
      for (      Entry<String,SubstitutionTarget> e : compositionCouple.parent.getSubstitutionMapping().getRequirements().entrySet()) {
        if (e.getValue().getNodeTemplateName().equals(compositionCouple.nodeName)) {
          String targetCapability=e.getValue().getTargetId();
          e.setValue(compositionCouple.child.getSubstitutionMapping().getRequirements().get(targetCapability));
        }
      }
    }
  }
  compositionCouple.parent.getNodeTemplates().putAll(compositionCouple.child.getNodeTemplates());
}