Program: 62230
Project: 62230
Buggy source:
public void process(NodeType nodeTemplateType,Map.Entry<String,RelationshipTemplate> instance){
  RelationshipTemplate relationshipTemplate=instance.getValue();
  if (relationshipTemplate.getTarget() == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(instance);
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_TARGET_NODE_TEMPLATE_NAME_REQUIRED,null,node.getStartMark(),null,node.getEndMark(),null));
  }
  RelationshipType relationshipType=ToscaContext.get(RelationshipType.class,relationshipTemplate.getType());
  propertyValueChecker.checkProperties(relationshipType,relationshipTemplate.getProperties(),instance.getKey());
  RequirementDefinition rd=getRequirementDefinitionByName(nodeTemplateType,relationshipTemplate.getRequirementName());
  if (rd == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(relationshipTemplate.getRequirementName());
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_NOT_FOUND,null,node.getStartMark(),null,node.getEndMark(),relationshipTemplate.getRequirementName()));
    return;
  }
  if (relationshipTemplate.getType() == null) {
    relationshipTemplate.setType(rd.getRelationshipType());
  }
  referencePostProcessor.process(new ReferencePostProcessor.TypeReference(relationshipTemplate.getType(),RelationshipType.class));
  relationshipTemplate.setRequirementType(rd.getType());
  ArchiveRoot archiveRoot=(ArchiveRoot)ParsingContextExecution.getRoot().getWrappedInstance();
  NodeTemplate targetNodeTemplate=archiveRoot.getTopology().getNodeTemplates().get(relationshipTemplate.getTarget());
  if (targetNodeTemplate == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(relationshipTemplate.getTarget());
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_TARGET_NOT_FOUND,null,node.getStartMark(),null,node.getEndMark(),relationshipTemplate.getTarget()));
    return;
  }
  String capabilityType=relationshipTemplate.getTargetedCapabilityName();
  Capability capability=null;
  if (capabilityType == null) {
    if (targetNodeTemplate.getCapabilities() != null) {
      capability=targetNodeTemplate.getCapabilities().get(relationshipTemplate.getRequirementName());
      if (capability != null) {
        relationshipTemplate.setTargetedCapabilityName(rd.getId());
      }
    }
  }
 else {
    Map.Entry<String,Capability> capabilityEntry=getCapabilityByType(targetNodeTemplate,capabilityType);
    if (capabilityEntry != null) {
      capability=capabilityEntry.getValue();
      relationshipTemplate.setTargetedCapabilityName(capabilityEntry.getKey());
    }
  }
  if (capability == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(relationshipTemplate);
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_CAPABILITY_NOT_FOUND,null,node.getStartMark(),null,node.getEndMark(),relationshipTemplate.getRequirementName()));
    return;
  }
  RelationshipType indexedRelationshipType=ToscaContext.get(RelationshipType.class,relationshipTemplate.getType());
  if (indexedRelationshipType == null) {
    return;
  }
  Map<String,AbstractPropertyValue> properties=Maps.newLinkedHashMap();
  NodeTemplateBuilder.fillProperties(properties,indexedRelationshipType.getProperties(),relationshipTemplate.getProperties(),false);
  relationshipTemplate.setProperties(properties);
  relationshipTemplate.setAttributes(indexedRelationshipType.getAttributes());
  safe(instance.getValue().getArtifacts()).values().forEach(artifactPostProcessor);
  Map<String,DeploymentArtifact> mergedArtifacts=instance.getValue().getArtifacts();
  if (mergedArtifacts == null) {
    mergedArtifacts=new HashMap<>();
  }
  mergedArtifacts.putAll(safe(indexedRelationshipType.getArtifacts()));
  relationshipTemplate.setArtifacts(mergedArtifacts);
  for (  Interface anInterface : safe(instance.getValue().getInterfaces()).values()) {
    safe(anInterface.getOperations()).values().stream().map(Operation::getImplementationArtifact).filter(Objects::nonNull).forEach(artifactPostProcessor);
  }
}

Fixed version (ground truth):
public void process(NodeType nodeTemplateType,Map.Entry<String,RelationshipTemplate> instance){
  RelationshipTemplate relationshipTemplate=instance.getValue();
  if (relationshipTemplate.getTarget() == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(instance);
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_TARGET_NODE_TEMPLATE_NAME_REQUIRED,null,node.getStartMark(),null,node.getEndMark(),null));
  }
  RelationshipType relationshipType=ToscaContext.get(RelationshipType.class,relationshipTemplate.getType());
  propertyValueChecker.checkProperties(relationshipType,relationshipTemplate.getProperties(),instance.getKey());
  RequirementDefinition rd=getRequirementDefinitionByName(nodeTemplateType,relationshipTemplate.getRequirementName());
  if (rd == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(relationshipTemplate.getRequirementName());
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_NOT_FOUND,null,node.getStartMark(),null,node.getEndMark(),relationshipTemplate.getRequirementName()));
    return;
  }
  if (relationshipTemplate.getType() == null) {
    relationshipTemplate.setType(rd.getRelationshipType());
  }
  referencePostProcessor.process(new ReferencePostProcessor.TypeReference(relationshipTemplate,relationshipTemplate.getType(),RelationshipType.class));
  relationshipTemplate.setRequirementType(rd.getType());
  ArchiveRoot archiveRoot=(ArchiveRoot)ParsingContextExecution.getRoot().getWrappedInstance();
  NodeTemplate targetNodeTemplate=archiveRoot.getTopology().getNodeTemplates().get(relationshipTemplate.getTarget());
  if (targetNodeTemplate == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(relationshipTemplate.getTarget());
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_TARGET_NOT_FOUND,null,node.getStartMark(),null,node.getEndMark(),relationshipTemplate.getTarget()));
    return;
  }
  String capabilityType=relationshipTemplate.getTargetedCapabilityName();
  Capability capability=null;
  if (capabilityType == null) {
    if (targetNodeTemplate.getCapabilities() != null) {
      capability=targetNodeTemplate.getCapabilities().get(relationshipTemplate.getRequirementName());
      if (capability != null) {
        relationshipTemplate.setTargetedCapabilityName(rd.getId());
      }
    }
  }
 else {
    Map.Entry<String,Capability> capabilityEntry=getCapabilityByType(targetNodeTemplate,capabilityType);
    if (capabilityEntry != null) {
      capability=capabilityEntry.getValue();
      relationshipTemplate.setTargetedCapabilityName(capabilityEntry.getKey());
    }
  }
  if (capability == null) {
    Node node=ParsingContextExecution.getObjectToNodeMap().get(relationshipTemplate);
    ParsingContextExecution.getParsingErrors().add(new ParsingError(ErrorCode.REQUIREMENT_CAPABILITY_NOT_FOUND,null,node.getStartMark(),null,node.getEndMark(),relationshipTemplate.getRequirementName()));
    return;
  }
  RelationshipType indexedRelationshipType=ToscaContext.get(RelationshipType.class,relationshipTemplate.getType());
  if (indexedRelationshipType == null) {
    return;
  }
  Map<String,AbstractPropertyValue> properties=Maps.newLinkedHashMap();
  NodeTemplateBuilder.fillProperties(properties,indexedRelationshipType.getProperties(),relationshipTemplate.getProperties(),false);
  relationshipTemplate.setProperties(properties);
  relationshipTemplate.setAttributes(indexedRelationshipType.getAttributes());
  safe(instance.getValue().getArtifacts()).values().forEach(artifactPostProcessor);
  Map<String,DeploymentArtifact> mergedArtifacts=instance.getValue().getArtifacts();
  if (mergedArtifacts == null) {
    mergedArtifacts=new HashMap<>();
  }
  mergedArtifacts.putAll(safe(indexedRelationshipType.getArtifacts()));
  relationshipTemplate.setArtifacts(mergedArtifacts);
  for (  Interface anInterface : safe(instance.getValue().getInterfaces()).values()) {
    safe(anInterface.getOperations()).values().stream().map(Operation::getImplementationArtifact).filter(Objects::nonNull).forEach(artifactPostProcessor);
  }
}