Program: 171080
Project: 171080
Buggy source:
public CreateUpdateEntitiesResult toCreateUpdateEntitiesResult(EntityMutationResponse reponse){
  CreateUpdateEntitiesResult ret=null;
  if (reponse != null) {
    Map<EntityOperation,List<AtlasEntityHeader>> mutatedEntities=reponse.getMutatedEntities();
    Map<String,String> guidAssignments=reponse.getGuidAssignments();
    ret=new CreateUpdateEntitiesResult();
    if (MapUtils.isNotEmpty(guidAssignments)) {
      ret.setGuidMapping(new GuidMapping(guidAssignments));
    }
    if (MapUtils.isNotEmpty(mutatedEntities)) {
      EntityResult entityResult=new EntityResult();
      for (      Map.Entry<EntityOperation,List<AtlasEntityHeader>> e : mutatedEntities.entrySet()) {
switch (e.getKey()) {
case CREATE:
          List<AtlasEntityHeader> createdEntities=mutatedEntities.get(EntityOperation.CREATE);
        if (CollectionUtils.isNotEmpty(createdEntities)) {
          entityResult.set(EntityResult.OP_CREATED,getGuids(createdEntities));
        }
      break;
case UPDATE:
    List<AtlasEntityHeader> updatedEntities=mutatedEntities.get(EntityOperation.UPDATE);
  if (CollectionUtils.isNotEmpty(updatedEntities)) {
    entityResult.set(EntityResult.OP_UPDATED,getGuids(updatedEntities));
  }
break;
case PARTIAL_UPDATE:
List<AtlasEntityHeader> partialUpdatedEntities=mutatedEntities.get(EntityOperation.PARTIAL_UPDATE);
if (CollectionUtils.isNotEmpty(partialUpdatedEntities)) {
entityResult.set(EntityResult.OP_UPDATED,getGuids(partialUpdatedEntities));
}
break;
case DELETE:
List<AtlasEntityHeader> deletedEntities=mutatedEntities.get(EntityOperation.DELETE);
if (CollectionUtils.isNotEmpty(deletedEntities)) {
entityResult.set(EntityResult.OP_DELETED,getGuids(deletedEntities));
}
break;
}
}
ret.setEntityResult(entityResult);
}
}
return ret;
}

Fixed version (ground truth):
public CreateUpdateEntitiesResult toCreateUpdateEntitiesResult(EntityMutationResponse reponse){
  CreateUpdateEntitiesResult ret=null;
  if (reponse != null) {
    Map<EntityOperation,List<AtlasEntityHeader>> mutatedEntities=reponse.getMutatedEntities();
    Map<String,String> guidAssignments=reponse.getGuidAssignments();
    ret=new CreateUpdateEntitiesResult();
    if (MapUtils.isNotEmpty(guidAssignments)) {
      ret.setGuidMapping(new GuidMapping(guidAssignments));
    }
    if (MapUtils.isNotEmpty(mutatedEntities)) {
      EntityResult entityResult=new EntityResult();
      for (      Map.Entry<EntityOperation,List<AtlasEntityHeader>> e : mutatedEntities.entrySet()) {
switch (e.getKey()) {
case CREATE:
          List<AtlasEntityHeader> createdEntities=mutatedEntities.get(EntityOperation.CREATE);
        if (CollectionUtils.isNotEmpty(createdEntities)) {
          Collections.reverse(createdEntities);
          entityResult.set(EntityResult.OP_CREATED,getGuids(createdEntities));
        }
      break;
case UPDATE:
    List<AtlasEntityHeader> updatedEntities=mutatedEntities.get(EntityOperation.UPDATE);
  if (CollectionUtils.isNotEmpty(updatedEntities)) {
    Collections.reverse(updatedEntities);
    entityResult.set(EntityResult.OP_UPDATED,getGuids(updatedEntities));
  }
break;
case PARTIAL_UPDATE:
List<AtlasEntityHeader> partialUpdatedEntities=mutatedEntities.get(EntityOperation.PARTIAL_UPDATE);
if (CollectionUtils.isNotEmpty(partialUpdatedEntities)) {
Collections.reverse(partialUpdatedEntities);
entityResult.set(EntityResult.OP_UPDATED,getGuids(partialUpdatedEntities));
}
break;
case DELETE:
List<AtlasEntityHeader> deletedEntities=mutatedEntities.get(EntityOperation.DELETE);
if (CollectionUtils.isNotEmpty(deletedEntities)) {
Collections.reverse(deletedEntities);
entityResult.set(EntityResult.OP_DELETED,getGuids(deletedEntities));
}
break;
}
}
ret.setEntityResult(entityResult);
}
}
return ret;
}