Program: 57795
Project: 57795
Buggy source:
/** 
 * <p> Converts a   {@link RecordPerspective} with an IDType that is not the {@link #recordIDType} to a newRecordPerspective with the recordIDType. </p> <p> Grouping, and naming is preserved, sample elements and trees are not. </p>
 */
public RecordPerspective convertForeignRecordPerspective(RecordPerspective foreignPerspective){
  if (foreignPerspective.getIdType().getIDCategory() != recordIDCategory) {
    throw new IllegalArgumentException("String_Node_Str" + foreignPerspective.getIdType() + "String_Node_Str"+ recordIDType);
  }
  if (foreignPerspective.getIdType() == recordIDType)   return foreignPerspective;
  RecordVirtualArray foreignRecordVA=foreignPerspective.getVirtualArray();
  RecordGroupList recordGroupList=foreignRecordVA.getGroupList();
  PerspectiveInitializationData data=new PerspectiveInitializationData();
  ArrayList<Integer> indices=new ArrayList<Integer>(foreignRecordVA.size());
  ArrayList<Integer> groupSizes=new ArrayList<Integer>(recordGroupList.size());
  ArrayList<Integer> sampleElements=new ArrayList<Integer>(recordGroupList.size());
  ArrayList<String> groupNames=new ArrayList<String>(recordGroupList.size());
  for (  Group foreignGroup : recordGroupList) {
    groupSizes.add(0);
    sampleElements.add(0);
    groupNames.add(foreignGroup.getClusterNode().getLabel());
  }
  for (  Integer foreignVAID : foreignRecordVA) {
    Integer localVAID=recordIDMappingManager.getID(foreignRecordVA.getIdType(),recordIDType,foreignVAID);
    if (localVAID == null)     continue;
    indices.add(localVAID);
    int groupIndex=recordGroupList.getGroupOfVAIndex(foreignRecordVA.indexOf(foreignVAID)).getGroupID();
    groupSizes.set(groupIndex,sampleElements.get(groupIndex) + 1);
    sampleElements.set(groupIndex,localVAID);
  }
  data.setData(indices,groupSizes,sampleElements,groupNames);
  RecordPerspective localRecordPerspective=new RecordPerspective(this);
  localRecordPerspective.setIDType(recordIDType);
  localRecordPerspective.init(data);
  return localRecordPerspective;
}

Fixed version (ground truth):
/** 
 * <p> Converts a   {@link RecordPerspective} with an IDType that is not the {@link #recordIDType} to a newRecordPerspective with the recordIDType. </p> <p> Grouping, and naming is preserved, sample elements and trees are not. </p>
 */
public RecordPerspective convertForeignRecordPerspective(RecordPerspective foreignPerspective){
  if (foreignPerspective.getIdType().getIDCategory() != recordIDCategory) {
    throw new IllegalArgumentException("String_Node_Str" + foreignPerspective.getIdType() + "String_Node_Str"+ recordIDType);
  }
  if (foreignPerspective.getIdType() == recordIDType)   return foreignPerspective;
  RecordVirtualArray foreignRecordVA=foreignPerspective.getVirtualArray();
  RecordGroupList recordGroupList=foreignRecordVA.getGroupList();
  PerspectiveInitializationData data=new PerspectiveInitializationData();
  ArrayList<Integer> indices=new ArrayList<Integer>(foreignRecordVA.size());
  ArrayList<Integer> groupSizes=new ArrayList<Integer>(recordGroupList.size());
  ArrayList<Integer> sampleElements=new ArrayList<Integer>(recordGroupList.size());
  ArrayList<String> groupNames=new ArrayList<String>(recordGroupList.size());
  for (  Group foreignGroup : recordGroupList) {
    groupSizes.add(0);
    sampleElements.add(0);
    groupNames.add(foreignGroup.getClusterNode().getLabel());
  }
  int count=0;
  for (  Integer foreignVAID : foreignRecordVA) {
    Integer localVAID=recordIDMappingManager.getID(foreignRecordVA.getIdType(),recordIDType,foreignVAID);
    if (localVAID == null)     continue;
    indices.add(localVAID);
    int groupIndex=recordGroupList.getGroupOfVAIndex(foreignRecordVA.indexOf(foreignVAID)).getGroupID();
    groupSizes.set(groupIndex,groupSizes.get(groupIndex) + 1);
    sampleElements.set(groupIndex,count);
    count++;
  }
  data.setData(indices,groupSizes,sampleElements,groupNames);
  RecordPerspective localRecordPerspective=new RecordPerspective(this);
  localRecordPerspective.setIDType(recordIDType);
  localRecordPerspective.init(data);
  return localRecordPerspective;
}