Program: 67281
Project: 67281
Buggy source:
private void testFactTableSaveAndLoad1(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[3];
  ILevelDefn[] levelDefs=new ILevelDefn[1];
  String[] levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension1Col));
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[0]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false,new StopSign());
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension2Col));
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[1]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false,new StopSign());
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension3Col));
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[2]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false,new StopSign());
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  IDatasetIterator factTableIterator=new LevelsAndFactTableDataset();
  String[] measureColumnName=new String[2];
  measureColumnName[0]="String_Node_Str";
  measureColumnName[1]="String_Node_Str";
  FactTableAccessor factTableConstructor=new FactTableAccessor(documentManager);
  FactTable factTable=factTableConstructor.saveFactTable(NamingUtil.getFactTableName("String_Node_Str"),CubeUtility.getKeyColNames(dimensions),CubeUtility.getKeyColNames(dimensions),factTableIterator,dimensions,measureColumnName,new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  assertEquals(factTable.getDimensionInfo()[0].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].getDimensionLength(),3);
  assertEquals(factTable.getDimensionInfo()[1].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].getDimensionLength(),7);
  assertEquals(factTable.getDimensionInfo()[2].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].getDimensionLength(),14);
  assertEquals(factTable.getMeasureInfo()[0].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[0].getDataType(),DataType.INTEGER_TYPE);
  assertEquals(factTable.getMeasureInfo()[1].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[1].getDataType(),DataType.DOUBLE_TYPE);
  String[] dimensionNames=new String[1];
  dimensionNames[0]="String_Node_Str";
  IDiskArray[] dimensionPosition=new IDiskArray[1];
  dimensionPosition[0]=new BufferedPrimitiveDiskArray();
  dimensionPosition[0].add(new Integer(1));
  dimensionPosition[0].add(new Integer(2));
  IFactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  facttableRowIterator=new FactTableRowIteratorWithFilter(dimensions,facttableRowIterator,new StopSign());
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(3,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(121),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(121),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(4,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(122),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(122),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(5,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(211),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(211),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(6,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(212),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(212),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
  facttableRowIterator.close();
}

Fixed version (ground truth):
private void testFactTableSaveAndLoad1(IDocumentManager documentManager) throws IOException, BirtException {
  Dimension[] dimensions=new Dimension[3];
  ILevelDefn[] levelDefs=new ILevelDefn[1];
  String[] levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  DimensionForTest iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension1Col));
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[0]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false,new StopSign());
  IHierarchy hierarchy=dimensions[0].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension2Col));
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[1]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false,new StopSign());
  hierarchy=dimensions[1].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  levelNames=new String[1];
  levelNames[0]="String_Node_Str";
  iterator=new DimensionForTest(levelNames);
  iterator.setLevelMember(0,distinct(LevelsAndFactTableDataset.dimension3Col));
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  dimensions[2]=(Dimension)DimensionFactory.createDimension("String_Node_Str",documentManager,iterator,levelDefs,false,new StopSign());
  hierarchy=dimensions[2].getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  IDatasetIterator factTableIterator=new LevelsAndFactTableDataset();
  String[] measureColumnName=new String[2];
  measureColumnName[0]="String_Node_Str";
  measureColumnName[1]="String_Node_Str";
  FactTableAccessor factTableConstructor=new FactTableAccessor(documentManager);
  FactTable factTable=factTableConstructor.saveFactTable(NamingUtil.getFactTableName("String_Node_Str"),CubeUtility.getKeyColNames(dimensions),CubeUtility.getKeyColNames(dimensions),factTableIterator,dimensions,measureColumnName,new StopSign(),false);
  assertEquals(factTable.getSegmentCount(),1);
  factTable=factTableConstructor.load(NamingUtil.getFactTableName("String_Node_Str"),new StopSign());
  assertEquals(factTable.getSegmentCount(),1);
  assertEquals(factTable.getDimensionInfo()[0].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[0].getDimensionLength(),3);
  assertEquals(factTable.getDimensionInfo()[1].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[1].getDimensionLength(),7);
  assertEquals(factTable.getDimensionInfo()[2].getDimensionName(),"String_Node_Str");
  assertEquals(factTable.getDimensionInfo()[2].getDimensionLength(),14);
  assertEquals(factTable.getMeasureInfo()[0].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[0].getDataType(),DataType.INTEGER_TYPE);
  assertEquals(factTable.getMeasureInfo()[1].getMeasureName(),"String_Node_Str");
  assertEquals(factTable.getMeasureInfo()[1].getDataType(),DataType.DOUBLE_TYPE);
  String[] dimensionNames=new String[1];
  dimensionNames[0]="String_Node_Str";
  IDiskArray[] dimensionPosition=new IDiskArray[1];
  dimensionPosition[0]=new BufferedPrimitiveDiskArray();
  dimensionPosition[0].add(new Integer(1));
  dimensionPosition[0].add(new Integer(2));
  IFactTableRowIterator facttableRowIterator=new FactTableRowIterator(factTable,dimensionNames,dimensionPosition,new StopSign());
  facttableRowIterator=new FactTableRowIteratorWithFilter(dimensions,facttableRowIterator,new StopSign());
  assertTrue(facttableRowIterator != null);
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(3,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(121),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(121),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(0,facttableRowIterator.getDimensionPosition(0));
  assertEquals(1,facttableRowIterator.getDimensionPosition(1));
  assertEquals(4,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(122),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(122),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(5,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(211),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(211),facttableRowIterator.getMeasure(1));
  assertTrue(facttableRowIterator.next());
  assertEquals(1,facttableRowIterator.getDimensionPosition(0));
  assertEquals(2,facttableRowIterator.getDimensionPosition(1));
  assertEquals(6,facttableRowIterator.getDimensionPosition(2));
  assertEquals(new Integer(212),facttableRowIterator.getMeasure(0));
  assertEquals(new Double(212),facttableRowIterator.getMeasure(1));
  assertFalse(facttableRowIterator.next());
  facttableRowIterator.close();
}