Program: 76069
Project: 76069
Buggy source:
private void testDimensionCreate2(IDocumentManager documentManager) throws IOException, BirtException, DataException {
  ILevelDefn[] levelDefs=new ILevelDefn[3];
  String[] attrs={"String_Node_Str"};
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},attrs);
  IDimension dimension=DimensionFactory.createDimension("String_Node_Str",documentManager,new ThreeLevelDataset(),levelDefs,false);
  IHierarchy hierarchy=dimension.getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  ILevel[] level=hierarchy.getLevels();
  assertEquals(level[0].getName(),"String_Node_Str");
  assertEquals(level[0].getKeyDataType("String_Node_Str"),DataType.STRING_TYPE);
  assertEquals(level[1].getName(),"String_Node_Str");
  assertEquals(level[1].getKeyDataType("String_Node_Str"),DataType.STRING_TYPE);
  assertEquals(level[2].getName(),"String_Node_Str");
  assertEquals(level[2].getKeyDataType("String_Node_Str"),DataType.STRING_TYPE);
  Dimension realDimension=(Dimension)dimension;
  for (int i=0; i < ThreeLevelDataset.Level1Col.length; i++) {
    System.out.println(i);
    IndexKey indexKey=realDimension.findFirst((Level)level[0],new Object[]{ThreeLevelDataset.Level1Col[i]});
    assertEquals(indexKey.key[0],ThreeLevelDataset.Level1Col[i]);
    if (i < 5)     assertEquals(indexKey.dimensionPos,0);
    if (i >= 5 && i < 12)     assertEquals(indexKey.dimensionPos,5);
    if (i >= 12)     assertEquals(indexKey.dimensionPos,12);
    Member levelMember=realDimension.getRowByPosition(indexKey.dimensionPos).members[0];
    assertEquals(levelMember.keyValues[0],ThreeLevelDataset.Level1Col[i]);
    assertTrue(levelMember.attributes == null);
    levelMember=realDimension.getDimensionRowByOffset(indexKey.offset).members[0];
    assertEquals(levelMember.keyValues[0],ThreeLevelDataset.Level1Col[i]);
    assertTrue(levelMember.attributes == null);
    indexKey=realDimension.findFirst((Level)level[1],new Object[]{ThreeLevelDataset.Level2Col[i]});
    assertEquals(indexKey.key[0],ThreeLevelDataset.Level2Col[i]);
    levelMember=realDimension.getRowByPosition(indexKey.dimensionPos).members[1];
    assertEquals(levelMember.keyValues[0],ThreeLevelDataset.Level2Col[i]);
    assertTrue(levelMember.attributes == null);
    levelMember=realDimension.getDimensionRowByOffset(indexKey.offset).members[1];
    assertEquals(levelMember.keyValues[0],ThreeLevelDataset.Level2Col[i]);
    assertTrue(levelMember.attributes == null);
    indexKey=realDimension.findFirst((Level)level[2],new Object[]{ThreeLevelDataset.Level3Col[i]});
    assertEquals(indexKey.key[0],ThreeLevelDataset.Level3Col[i]);
    assertEquals(indexKey.dimensionPos,i);
    levelMember=realDimension.getRowByPosition(indexKey.dimensionPos).members[2];
    assertEquals(levelMember.keyValues[0],ThreeLevelDataset.Level3Col[i]);
    levelMember=realDimension.getDimensionRowByOffset(indexKey.offset).members[2];
    assertEquals(levelMember.keyValues[0],ThreeLevelDataset.Level3Col[i]);
  }
}

Fixed version (ground truth):
private void testDimensionCreate2(IDocumentManager documentManager) throws IOException, BirtException, DataException {
  ILevelDefn[] levelDefs=new ILevelDefn[3];
  String[] attrs={"String_Node_Str"};
  levelDefs[0]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[1]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},null);
  levelDefs[2]=new LevelDefinition("String_Node_Str",new String[]{"String_Node_Str"},attrs);
  IDimension dimension=DimensionFactory.createDimension("String_Node_Str",documentManager,new ThreeLevelDataset(),levelDefs,false);
  IHierarchy hierarchy=dimension.getHierarchy();
  assertEquals(hierarchy.getName(),"String_Node_Str");
  ILevel[] level=hierarchy.getLevels();
  assertEquals(level[0].getName(),"String_Node_Str");
  assertEquals(level[0].getKeyDataType("String_Node_Str"),DataType.STRING_TYPE);
  assertEquals(level[1].getName(),"String_Node_Str");
  assertEquals(level[1].getKeyDataType("String_Node_Str"),DataType.STRING_TYPE);
  assertEquals(level[2].getName(),"String_Node_Str");
  assertEquals(level[2].getKeyDataType("String_Node_Str"),DataType.STRING_TYPE);
  Dimension realDimension=(Dimension)dimension;
  for (int i=0; i < ThreeLevelDataset.Level1Col.length; i++) {
    System.out.println(i);
    IndexKey indexKey=realDimension.findFirst((Level)level[0],new Object[]{ThreeLevelDataset.Level1Col[i]});
    assertEquals(indexKey.key[0],ThreeLevelDataset.Level1Col[i]);
    if (i < 5)     assertEquals(indexKey.dimensionPos,0);
    if (i >= 5 && i < 12)     assertEquals(indexKey.dimensionPos,5);
    if (i >= 12)     assertEquals(indexKey.dimensionPos,12);
    Member levelMember=realDimension.getRowByPosition(indexKey.dimensionPos).getMembers()[0];
    assertEquals(levelMember.getKeyValues()[0],ThreeLevelDataset.Level1Col[i]);
    assertTrue(levelMember.getAttributes() == null);
    levelMember=realDimension.getDimensionRowByOffset(indexKey.offset).getMembers()[0];
    assertEquals(levelMember.getKeyValues()[0],ThreeLevelDataset.Level1Col[i]);
    assertTrue(levelMember.getAttributes() == null);
    indexKey=realDimension.findFirst((Level)level[1],new Object[]{ThreeLevelDataset.Level2Col[i]});
    assertEquals(indexKey.key[0],ThreeLevelDataset.Level2Col[i]);
    levelMember=realDimension.getRowByPosition(indexKey.dimensionPos).getMembers()[1];
    assertEquals(levelMember.getKeyValues()[0],ThreeLevelDataset.Level2Col[i]);
    assertTrue(levelMember.getAttributes() == null);
    levelMember=realDimension.getDimensionRowByOffset(indexKey.offset).getMembers()[1];
    assertEquals(levelMember.getKeyValues()[0],ThreeLevelDataset.Level2Col[i]);
    assertTrue(levelMember.getAttributes() == null);
    indexKey=realDimension.findFirst((Level)level[2],new Object[]{ThreeLevelDataset.Level3Col[i]});
    assertEquals(indexKey.key[0],ThreeLevelDataset.Level3Col[i]);
    assertEquals(indexKey.dimensionPos,i);
    levelMember=realDimension.getRowByPosition(indexKey.dimensionPos).getMembers()[2];
    assertEquals(levelMember.getKeyValues()[0],ThreeLevelDataset.Level3Col[i]);
    levelMember=realDimension.getDimensionRowByOffset(indexKey.offset).getMembers()[2];
    assertEquals(levelMember.getKeyValues()[0],ThreeLevelDataset.Level3Col[i]);
  }
}