Program: 62121
Project: 62121
Buggy source:
@Override public void process(Csar csar,Topology topology,ReplaceNodeOperation operation){
  Map<String,NodeTemplate> nodeTemplates=TopologyUtils.getNodeTemplates(topology);
  NodeTemplate oldNodeTemplate=TopologyUtils.getNodeTemplate(topology.getId(),operation.getNodeName(),nodeTemplates);
  String[] splittedId=operation.getNewTypeId().split("String_Node_Str");
  topologyService.unloadType(topology,oldNodeTemplate.getType());
  nodeTemplates.remove(oldNodeTemplate.getName());
  workflowBuilderService.removeNode(topology,csar,oldNodeTemplate.getName());
  NodeType newType=toscaTypeSearchService.find(NodeType.class,splittedId[0],splittedId[1]);
  newType=topologyService.loadType(topology,newType);
  NodeTemplate newNodeTemplate=TemplateBuilder.buildNodeTemplate(newType,oldNodeTemplate,false);
  newNodeTemplate.setName(operation.getNodeName());
  newNodeTemplate.setTags(oldNodeTemplate.getTags());
  newNodeTemplate.setName(oldNodeTemplate.getName());
  newNodeTemplate.setRelationships(oldNodeTemplate.getRelationships());
  nodeTemplates.put(oldNodeTemplate.getName(),newNodeTemplate);
  updateRelationshipsCapabilitiesRelationships(topology,newNodeTemplate);
  if (topology.getSubstitutionMapping() != null) {
    removeNodeTemplateSubstitutionTargetMapEntry(oldNodeTemplate.getName(),topology.getSubstitutionMapping().getCapabilities());
    removeNodeTemplateSubstitutionTargetMapEntry(oldNodeTemplate.getName(),topology.getSubstitutionMapping().getRequirements());
  }
  log.debug("String_Node_Str",oldNodeTemplate.getName(),oldNodeTemplate.getName(),operation.getNewTypeId(),topology.getId());
  TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology,csar);
  workflowBuilderService.addNode(topologyContext,oldNodeTemplate.getName());
  safe(newNodeTemplate.getRelationships()).forEach((relationshipId,relationshipTemplate) -> workflowBuilderService.addRelationship(topologyContext,newNodeTemplate.getName(),relationshipId));
  TopologyUtils.getTargetRelationships(oldNodeTemplate.getName(),nodeTemplates).forEach(relationshipEntry -> workflowBuilderService.addRelationship(topologyContext,relationshipEntry.getSource().getName(),relationshipEntry.getRelationshipId()));
  if (!operation.isSkipAutoCompletion()) {
    danglingRequirementService.addDanglingRequirements(topology,topologyContext,newNodeTemplate,null);
  }
}

Fixed version (ground truth):
@Override public void process(Csar csar,Topology topology,ReplaceNodeOperation operation){
  Map<String,NodeTemplate> nodeTemplates=TopologyUtils.getNodeTemplates(topology);
  NodeTemplate oldNodeTemplate=TopologyUtils.getNodeTemplate(topology.getId(),operation.getNodeName(),nodeTemplates);
  String[] splittedId=operation.getNewTypeId().split("String_Node_Str");
  topologyService.unloadType(topology,oldNodeTemplate.getType());
  nodeTemplates.remove(oldNodeTemplate.getName());
  workflowBuilderService.removeNode(topology,csar,oldNodeTemplate.getName());
  NodeType newType=toscaTypeSearchService.findOrFail(NodeType.class,splittedId[0],splittedId[1]);
  newType=topologyService.loadType(topology,newType);
  NodeTemplate newNodeTemplate=TemplateBuilder.buildNodeTemplate(newType,oldNodeTemplate,false);
  newNodeTemplate.setName(operation.getNodeName());
  newNodeTemplate.setTags(oldNodeTemplate.getTags());
  newNodeTemplate.setName(oldNodeTemplate.getName());
  newNodeTemplate.setRelationships(oldNodeTemplate.getRelationships());
  nodeTemplates.put(oldNodeTemplate.getName(),newNodeTemplate);
  updateRelationshipsCapabilitiesRelationships(topology,newNodeTemplate);
  if (topology.getSubstitutionMapping() != null) {
    removeNodeTemplateSubstitutionTargetMapEntry(oldNodeTemplate.getName(),topology.getSubstitutionMapping().getCapabilities());
    removeNodeTemplateSubstitutionTargetMapEntry(oldNodeTemplate.getName(),topology.getSubstitutionMapping().getRequirements());
  }
  log.debug("String_Node_Str",oldNodeTemplate.getName(),oldNodeTemplate.getName(),operation.getNewTypeId(),topology.getId());
  TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology,csar);
  workflowBuilderService.addNode(topologyContext,oldNodeTemplate.getName());
  safe(newNodeTemplate.getRelationships()).forEach((relationshipId,relationshipTemplate) -> workflowBuilderService.addRelationship(topologyContext,newNodeTemplate.getName(),relationshipId));
  TopologyUtils.getTargetRelationships(oldNodeTemplate.getName(),nodeTemplates).forEach(relationshipEntry -> workflowBuilderService.addRelationship(topologyContext,relationshipEntry.getSource().getName(),relationshipEntry.getRelationshipId()));
  if (!operation.isSkipAutoCompletion()) {
    danglingRequirementService.addDanglingRequirements(topology,topologyContext,newNodeTemplate,null);
  }
}