Program: 71047
Project: 71047
Buggy source:
/** 
 * Get test ReportQueryDefn
 * @return ReportQueryDefn
 * @throws BirtException
 */
private IQueryDefinition getReportQueryDefn(int testUnit,String dsetName) throws BirtException {
  QueryDefinition rqDefn=new QueryDefinition();
  rqDefn.setDataSetName(dsetName == null ? dataSetName : dsetName);
  for (int i=0; i < this.scriptExprs.length; i++) {
    rqDefn.addResultSetExpression("String_Node_Str" + scriptColumnNames[i],scriptExprs[i]);
  }
  if (this.ADD_ALIAS) {
    for (int i=0; i < this.aliasScriptExprs.length; i++) {
      rqDefn.addResultSetExpression("String_Node_Str" + scriptColumnAliasNames[i],aliasScriptExprs[i]);
    }
  }
  rqDefn.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
  rqDefn.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
  String[] filterStr=new String[]{"String_Node_Str"};
  rqDefn.addResultSetExpression("String_Node_Str",new ScriptExpression(filterStr[0]));
  for (int i=0; i < filterStr.length; i++) {
    rqDefn.addFilter(new FilterDefinition(new ScriptExpression("String_Node_Str")));
  }
  if (testUnit == TEST_SORT) {
    SortDefinition sort=new SortDefinition();
    sort.setExpression("String_Node_Str");
    sort.setSortDirection(ISortDefinition.SORT_ASC);
    rqDefn.addSort(sort);
  }
  if (testUnit == TEST_GROUP) {
    SortDefinition sort=new SortDefinition();
    sort.setExpression("String_Node_Str");
    sort.setSortDirection(ISortDefinition.SORT_ASC);
    rqDefn.addSort(sort);
    GroupDefinition group=new GroupDefinition("String_Node_Str");
    group.setKeyExpression("String_Node_Str");
    group.setInterval(IGroupDefinition.NUMERIC_INTERVAL);
    group.setIntervalStart(new Double(3.0));
    group.setIntervalRange(3.0);
    group.setIntervalStart(new Integer(3));
    group.setSortDirection(IGroupDefinition.SORT_ASC);
    groupExpr.setGroupName("String_Node_Str");
    rqDefn.addResultSetExpression(groupName,groupExpr);
    rqDefn.addGroup(group);
  }
  if (testUnit == TEST_MAXROW) {
    IQueryDefinition queryDefinition=getReportQueryDefn(TEST_NONE);
    IPreparedQuery pq=dataEngine.prepare(queryDefinition);
    IQueryResults qr=pq.execute(jsScope);
    IResultIterator resultIterator=qr.getResultIterator();
    int realRows=0;
    while (resultIterator.next()) {
      realRows++;
    }
    rqDefn.setMaxRows(realRows / 2);
  }
  if (testUnit == TEST_TOPN_FILTER) {
    ConditionalExpression conditionExpr=new ConditionalExpression("String_Node_Str",ConditionalExpression.OP_TOP_N,"String_Node_Str");
    FilterDefinition exprFilter=new FilterDefinition(conditionExpr);
    rqDefn.addFilter(exprFilter);
  }
  rqDefn.addResultSetExpression(queryName,queryExpr);
  return rqDefn;
}

Fixed version (ground truth):
/** 
 * Get test ReportQueryDefn
 * @return ReportQueryDefn
 * @throws BirtException
 */
private IQueryDefinition getReportQueryDefn(int testUnit,String dsetName) throws BirtException {
  QueryDefinition rqDefn=new QueryDefinition();
  rqDefn.setDataSetName(dsetName == null ? dataSetName : dsetName);
  for (int i=0; i < this.scriptExprs.length; i++) {
    ((ScriptExpression)scriptExprs[i]).setDataType(scriptColumnTypes[i]);
    rqDefn.addResultSetExpression("String_Node_Str" + scriptColumnNames[i],scriptExprs[i]);
  }
  if (this.ADD_ALIAS) {
    for (int i=0; i < this.aliasScriptExprs.length; i++) {
      rqDefn.addResultSetExpression("String_Node_Str" + scriptColumnAliasNames[i],aliasScriptExprs[i]);
    }
  }
  rqDefn.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
  rqDefn.addResultSetExpression("String_Node_Str",new ScriptExpression("String_Node_Str"));
  String[] filterStr=new String[]{"String_Node_Str"};
  rqDefn.addResultSetExpression("String_Node_Str",new ScriptExpression(filterStr[0]));
  for (int i=0; i < filterStr.length; i++) {
    rqDefn.addFilter(new FilterDefinition(new ScriptExpression("String_Node_Str")));
  }
  if (testUnit == TEST_SORT) {
    SortDefinition sort=new SortDefinition();
    sort.setExpression("String_Node_Str");
    sort.setSortDirection(ISortDefinition.SORT_ASC);
    rqDefn.addSort(sort);
  }
  if (testUnit == TEST_GROUP) {
    SortDefinition sort=new SortDefinition();
    sort.setExpression("String_Node_Str");
    sort.setSortDirection(ISortDefinition.SORT_ASC);
    rqDefn.addSort(sort);
    GroupDefinition group=new GroupDefinition("String_Node_Str");
    group.setKeyExpression("String_Node_Str");
    group.setInterval(IGroupDefinition.NUMERIC_INTERVAL);
    group.setIntervalStart(new Double(3.0));
    group.setIntervalRange(3.0);
    group.setIntervalStart(new Integer(3));
    group.setSortDirection(IGroupDefinition.SORT_ASC);
    groupExpr.setGroupName("String_Node_Str");
    rqDefn.addResultSetExpression(groupName,groupExpr);
    rqDefn.addGroup(group);
  }
  if (testUnit == TEST_MAXROW) {
    IQueryDefinition queryDefinition=getReportQueryDefn(TEST_NONE);
    IPreparedQuery pq=dataEngine.prepare(queryDefinition);
    IQueryResults qr=pq.execute(jsScope);
    IResultIterator resultIterator=qr.getResultIterator();
    int realRows=0;
    while (resultIterator.next()) {
      realRows++;
    }
    rqDefn.setMaxRows(realRows / 2);
  }
  if (testUnit == TEST_TOPN_FILTER) {
    ConditionalExpression conditionExpr=new ConditionalExpression("String_Node_Str",ConditionalExpression.OP_TOP_N,"String_Node_Str");
    FilterDefinition exprFilter=new FilterDefinition(conditionExpr);
    rqDefn.addFilter(exprFilter);
  }
  rqDefn.addResultSetExpression(queryName,queryExpr);
  return rqDefn;
}