Program: 74804
Project: 74804
Buggy source:
public void testGetReferableBindings() throws AdapterException, DataException {
  IBinding binding1=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type1=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding2=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type2=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding3=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type3=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding4=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type4=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding5=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type5=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding6=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type6=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding7=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding7.addAggregateOn("String_Node_Str");
  binding7.addAggregateOn("String_Node_Str");
  binding7.addAggregateOn("String_Node_Str");
  int type7=IBindingMetaInfo.SUB_TOTAL_TYPE;
  IBinding binding71=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding71.addAggregateOn("String_Node_Str");
  binding71.addAggregateOn("String_Node_Str");
  binding71.addAggregateOn("String_Node_Str");
  int type71=IBindingMetaInfo.SUB_TOTAL_TYPE;
  IBinding binding8=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type8=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding9=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding9.addAggregateOn("String_Node_Str");
  binding9.addAggregateOn("String_Node_Str");
  int type9=IBindingMetaInfo.GRAND_TOTAL_TYPE;
  IBinding binding10=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type10=IBindingMetaInfo.MEASURE_TYPE;
  ICubeQueryDefinition query=new CubeQueryDefinition("String_Node_Str");
  query.addBinding(binding1);
  query.addBinding(binding2);
  query.addBinding(binding3);
  query.addBinding(binding4);
  query.addBinding(binding5);
  query.addBinding(binding6);
  query.addBinding(binding7);
  query.addBinding(binding71);
  query.addBinding(binding8);
  IEdgeDefinition columnEdge=query.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IDimensionDefinition dim1=columnEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier1=dim1.createHierarchy("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  IEdgeDefinition rowEdge=query.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IDimensionDefinition dim2=rowEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier2=dim2.createHierarchy("String_Node_Str");
  hier2.createLevel("String_Node_Str");
  String targetLevel1="String_Node_Str";
  List l1=this.session.getCubeQueryUtil().getReferableBindings(targetLevel1,query,true);
  assertTrue(l1.size() == 3);
  assertTrue(contains(l1,binding1,type1));
  assertTrue(contains(l1,binding4,type4));
  assertTrue(contains(l1,binding7,type7));
  String targetLevel2="String_Node_Str";
  List l2=this.session.getCubeQueryUtil().getReferableBindings(targetLevel2,query,false);
  assertTrue(l2.size() == 5);
  assertTrue(contains(l2,binding1,type1));
  assertTrue(contains(l2,binding4,type4));
  assertTrue(contains(l2,binding5,type5));
  assertTrue(contains(l2,binding6,type6));
  assertTrue(contains(l2,binding7,type7));
  String targetLevel3="String_Node_Str";
  List l3=this.session.getCubeQueryUtil().getReferableBindings(targetLevel3,query,false);
  assertTrue(l3.size() == 2);
  assertTrue(contains(l3,binding2,type2));
  assertTrue(contains(l3,binding71,type71));
  String targetLevel4="String_Node_Str";
  query.addBinding(binding9);
  List l4=this.session.getCubeQueryUtil().getReferableBindings(targetLevel4,query,false);
  assertTrue(l4.size() == 3);
  assertTrue(contains(l4,binding2,type2));
  assertTrue(contains(l4,binding71,type71));
  assertTrue(contains(l4,binding9,type9));
  String targetLevel5="String_Node_Str";
  query.addBinding(binding10);
  List l5=this.session.getCubeQueryUtil().getReferableBindings(targetLevel5,query,false);
  assertTrue(l5.size() == 4);
  assertTrue(contains(l5,binding7,type7));
  assertTrue(contains(l5,binding71,type71));
  assertTrue(contains(l5,binding8,type8));
  assertTrue(contains(l5,binding10,type10));
}

Fixed version (ground truth):
public void testGetReferableBindings() throws AdapterException, DataException {
  IBinding binding1=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type1=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding2=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type2=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding3=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type3=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding4=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type4=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding5=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type5=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding6=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type6=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding7=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding7.addAggregateOn("String_Node_Str");
  binding7.addAggregateOn("String_Node_Str");
  binding7.addAggregateOn("String_Node_Str");
  int type7=IBindingMetaInfo.SUB_TOTAL_TYPE;
  IBinding binding71=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding71.addAggregateOn("String_Node_Str");
  binding71.addAggregateOn("String_Node_Str");
  binding71.addAggregateOn("String_Node_Str");
  int type71=IBindingMetaInfo.SUB_TOTAL_TYPE;
  IBinding binding8=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type8=IBindingMetaInfo.DIMENSION_TYPE;
  IBinding binding9=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding9.addAggregateOn("String_Node_Str");
  binding9.addAggregateOn("String_Node_Str");
  int type9=IBindingMetaInfo.GRAND_TOTAL_TYPE;
  IBinding binding10=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  int type10=IBindingMetaInfo.MEASURE_TYPE;
  IBinding binding11=new Binding("String_Node_Str",new ScriptExpression("String_Node_Str"));
  binding11.setAggrFunction("String_Node_Str");
  int type11=IBindingMetaInfo.GRAND_TOTAL_TYPE;
  ICubeQueryDefinition query=new CubeQueryDefinition("String_Node_Str");
  query.addBinding(binding1);
  query.addBinding(binding2);
  query.addBinding(binding3);
  query.addBinding(binding4);
  query.addBinding(binding5);
  query.addBinding(binding6);
  query.addBinding(binding7);
  query.addBinding(binding71);
  query.addBinding(binding8);
  IEdgeDefinition columnEdge=query.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IDimensionDefinition dim1=columnEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier1=dim1.createHierarchy("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  hier1.createLevel("String_Node_Str");
  IEdgeDefinition rowEdge=query.createEdge(ICubeQueryDefinition.COLUMN_EDGE);
  IDimensionDefinition dim2=rowEdge.createDimension("String_Node_Str");
  IHierarchyDefinition hier2=dim2.createHierarchy("String_Node_Str");
  hier2.createLevel("String_Node_Str");
  String targetLevel1="String_Node_Str";
  List l1=this.session.getCubeQueryUtil().getReferableBindings(targetLevel1,query,true);
  assertTrue(l1.size() == 3);
  assertTrue(contains(l1,binding1,type1));
  assertTrue(contains(l1,binding4,type4));
  assertTrue(contains(l1,binding7,type7));
  String targetLevel2="String_Node_Str";
  List l2=this.session.getCubeQueryUtil().getReferableBindings(targetLevel2,query,false);
  assertTrue(l2.size() == 5);
  assertTrue(contains(l2,binding1,type1));
  assertTrue(contains(l2,binding4,type4));
  assertTrue(contains(l2,binding5,type5));
  assertTrue(contains(l2,binding6,type6));
  assertTrue(contains(l2,binding7,type7));
  String targetLevel3="String_Node_Str";
  List l3=this.session.getCubeQueryUtil().getReferableBindings(targetLevel3,query,false);
  assertTrue(l3.size() == 2);
  assertTrue(contains(l3,binding2,type2));
  assertTrue(contains(l3,binding71,type71));
  String targetLevel4="String_Node_Str";
  query.addBinding(binding9);
  List l4=this.session.getCubeQueryUtil().getReferableBindings(targetLevel4,query,false);
  assertTrue(l4.size() == 3);
  assertTrue(contains(l4,binding2,type2));
  assertTrue(contains(l4,binding71,type71));
  assertTrue(contains(l4,binding9,type9));
  String targetLevel5="String_Node_Str";
  query.addBinding(binding10);
  List l5=this.session.getCubeQueryUtil().getReferableBindings(targetLevel5,query,false);
  assertTrue(l5.size() == 4);
  assertTrue(contains(l5,binding7,type7));
  assertTrue(contains(l5,binding71,type71));
  assertTrue(contains(l5,binding8,type8));
  assertTrue(contains(l5,binding10,type10));
  String targetLevel6="String_Node_Str";
  query.addBinding(binding11);
  List l6=this.session.getCubeQueryUtil().getReferableBindings(targetLevel6,query,false);
  assertTrue(l6.size() == 4);
  assertTrue(contains(l6,binding2,type2));
  assertTrue(contains(l6,binding71,type71));
  assertTrue(contains(l6,binding9,type9));
  assertTrue(contains(l6,binding11,type11));
}