Program: 11139
Project: 11139
Buggy source:
@Test public void testComplexQuery(){
  String cql="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  ExpressionDef let=(ExpressionDef)visitData(cql);
  Query query=(Query)let.getExpression();
  AliasedQuerySource source=query.getSource();
  assertThat(source.getAlias(),is("String_Node_Str"));
  ClinicalRequest request=(ClinicalRequest)source.getExpression();
  assertThat(request.getDataType(),quickDataType("String_Node_Str"));
  assertThat(request.getCodeProperty(),is("String_Node_Str"));
  ValueSetRef code=(ValueSetRef)request.getCodes();
  assertThat(code.getName(),is("String_Node_Str"));
  assertThat(code.getLibraryName(),is(nullValue()));
  assertThat(code.getDescription(),is(nullValue()));
  assertThat(request.getDateProperty(),is(nullValue()));
  assertThat(request.getDateRange(),is(nullValue()));
  assertThat(request.getDescription(),is(nullValue()));
  assertThat(request.getScope(),is(nullValue()));
  assertThat(request.getSubjectProperty(),is(nullValue()));
  assertThat(request.getSubject(),is(nullValue()));
  assertThat(request.getCardinality(),is(nullValue()));
  assertThat(request.getIdProperty(),is(nullValue()));
  assertThat(request.getTemplateId(),is(nullValue()));
  assertThat(query.getRelationship(),hasSize(1));
  RelationshipClause relationship=query.getRelationship().get(0);
  assertThat(relationship,instanceOf(With.class));
  assertThat(relationship.getAlias(),is("String_Node_Str"));
  ClinicalRequest withRequest=(ClinicalRequest)relationship.getExpression();
  assertThat(withRequest.getDataType(),quickDataType("String_Node_Str"));
  assertThat(withRequest.getCodeProperty(),is("String_Node_Str"));
  ValueSetRef withCode=(ValueSetRef)withRequest.getCodes();
  assertThat(withCode.getName(),is("String_Node_Str"));
  assertThat(withCode.getLibraryName(),is(nullValue()));
  assertThat(withCode.getDescription(),is(nullValue()));
  assertThat(withRequest.getDateProperty(),is(nullValue()));
  assertThat(withRequest.getDateRange(),is(nullValue()));
  assertThat(withRequest.getDescription(),is(nullValue()));
  assertThat(withRequest.getScope(),is(nullValue()));
  assertThat(withRequest.getSubjectProperty(),is(nullValue()));
  assertThat(withRequest.getSubject(),is(nullValue()));
  assertThat(withRequest.getCardinality(),is(nullValue()));
  assertThat(withRequest.getIdProperty(),is(nullValue()));
  assertThat(withRequest.getTemplateId(),is(nullValue()));
  OverlapsAfter withWhere=(OverlapsAfter)relationship.getWhere();
  assertThat(withWhere.getDescription(),is(nullValue()));
  assertThat(withWhere.getOperand(),hasSize(2));
  GreaterOrEqual where=(GreaterOrEqual)query.getWhere();
  assertThat(where.getDescription(),is(nullValue()));
  assertThat(where.getOperand(),hasSize(2));
  DaysBetween whereLHS=(DaysBetween)where.getOperand().get(0);
  assertThat(whereLHS.getDescription(),is(nullValue()));
  assertThat(whereLHS.getOperand(),hasSize(2));
  Begin whereLHSBegin=(Begin)whereLHS.getOperand().get(0);
  assertThat(whereLHSBegin.getDescription(),is(nullValue()));
  End whereLHSEnd=(End)whereLHS.getOperand().get(1);
  assertThat(whereLHSEnd.getDescription(),is(nullValue()));
  assertThat(where.getOperand().get(1),literalFor(120));
  ObjectExpression rtn=(ObjectExpression)query.getReturn();
  assertThat(rtn.getDescription(),is(nullValue()));
  assertThat(rtn.getProperty(),hasSize(2));
  PropertyExpression rtnP1=rtn.getProperty().get(0);
  assertThat(rtnP1.getName(),is("String_Node_Str"));
  PropertyExpression rtnP2=rtn.getProperty().get(1);
  assertThat(rtnP2.getName(),is("String_Node_Str"));
  DaysBetween rtnP2Val=(DaysBetween)rtnP2.getValue();
  assertThat(rtnP2Val.getDescription(),is(nullValue()));
  assertThat(rtnP2Val.getOperand(),hasSize(2));
  Begin rtnP2ValBegin=(Begin)rtnP2Val.getOperand().get(0);
  assertThat(rtnP2ValBegin.getDescription(),is(nullValue()));
  End rtnP2ValEnd=(End)rtnP2Val.getOperand().get(1);
  assertThat(rtnP2ValEnd.getDescription(),is(nullValue()));
  SortClause sort=query.getSort();
  assertThat(sort.getBy(),hasSize(1));
  ByExpression sortBy=(ByExpression)sort.getBy().get(0);
  Identifier id=(Identifier)sortBy.getExpression();
  assertThat(id.getIdentifier(),is("String_Node_Str"));
  assertThat(id.getLibraryName(),is(nullValue()));
  assertThat(sortBy.getDirection(),is(SortDirection.DESC));
}

Fixed version (ground truth):
@Test public void testComplexQuery(){
  String cql="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  ExpressionDef let=(ExpressionDef)visitData(cql);
  Query query=(Query)let.getExpression();
  AliasedQuerySource source=query.getSource();
  assertThat(source.getAlias(),is("String_Node_Str"));
  ClinicalRequest request=(ClinicalRequest)source.getExpression();
  assertThat(request.getDataType(),quickDataType("String_Node_Str"));
  assertThat(request.getCodeProperty(),is("String_Node_Str"));
  ValueSetRef code=(ValueSetRef)request.getCodes();
  assertThat(code.getName(),is("String_Node_Str"));
  assertThat(code.getLibraryName(),is(nullValue()));
  assertThat(code.getDescription(),is(nullValue()));
  assertThat(request.getDateProperty(),is(nullValue()));
  assertThat(request.getDateRange(),is(nullValue()));
  assertThat(request.getDescription(),is(nullValue()));
  assertThat(request.getScope(),is(nullValue()));
  assertThat(request.getSubjectProperty(),is(nullValue()));
  assertThat(request.getSubject(),is(nullValue()));
  assertThat(request.getCardinality(),is(nullValue()));
  assertThat(request.getIdProperty(),is(nullValue()));
  assertThat(request.getTemplateId(),is(nullValue()));
  assertThat(query.getRelationship(),hasSize(1));
  RelationshipClause relationship=query.getRelationship().get(0);
  assertThat(relationship,instanceOf(With.class));
  assertThat(relationship.getAlias(),is("String_Node_Str"));
  ClinicalRequest withRequest=(ClinicalRequest)relationship.getExpression();
  assertThat(withRequest.getDataType(),quickDataType("String_Node_Str"));
  assertThat(withRequest.getCodeProperty(),is("String_Node_Str"));
  ValueSetRef withCode=(ValueSetRef)withRequest.getCodes();
  assertThat(withCode.getName(),is("String_Node_Str"));
  assertThat(withCode.getLibraryName(),is(nullValue()));
  assertThat(withCode.getDescription(),is(nullValue()));
  assertThat(withRequest.getDateProperty(),is(nullValue()));
  assertThat(withRequest.getDateRange(),is(nullValue()));
  assertThat(withRequest.getDescription(),is(nullValue()));
  assertThat(withRequest.getScope(),is(nullValue()));
  assertThat(withRequest.getSubjectProperty(),is(nullValue()));
  assertThat(withRequest.getSubject(),is(nullValue()));
  assertThat(withRequest.getCardinality(),is(nullValue()));
  assertThat(withRequest.getIdProperty(),is(nullValue()));
  assertThat(withRequest.getTemplateId(),is(nullValue()));
  OverlapsAfter withWhere=(OverlapsAfter)relationship.getWhere();
  assertThat(withWhere.getDescription(),is(nullValue()));
  assertThat(withWhere.getOperand(),hasSize(2));
  Property overlapsLHS=(Property)withWhere.getOperand().get(0);
  assertThat(overlapsLHS.getScope(),is("String_Node_Str"));
  assertThat(overlapsLHS.getPath(),is("String_Node_Str"));
  assertThat(overlapsLHS.getSource(),is(nullValue()));
  assertThat(overlapsLHS.getDescription(),is(nullValue()));
  Property overlapsRHS=(Property)withWhere.getOperand().get(1);
  assertThat(overlapsRHS.getScope(),is("String_Node_Str"));
  assertThat(overlapsRHS.getPath(),is("String_Node_Str"));
  assertThat(overlapsRHS.getSource(),is(nullValue()));
  assertThat(overlapsRHS.getDescription(),is(nullValue()));
  GreaterOrEqual where=(GreaterOrEqual)query.getWhere();
  assertThat(where.getDescription(),is(nullValue()));
  assertThat(where.getOperand(),hasSize(2));
  DaysBetween whereLHS=(DaysBetween)where.getOperand().get(0);
  assertThat(whereLHS.getDescription(),is(nullValue()));
  assertThat(whereLHS.getOperand(),hasSize(2));
  Begin whereLHSBegin=(Begin)whereLHS.getOperand().get(0);
  assertThat(whereLHSBegin.getDescription(),is(nullValue()));
  Property whereLHSBeginProp=(Property)whereLHSBegin.getOperand();
  assertThat(whereLHSBeginProp.getScope(),is("String_Node_Str"));
  assertThat(whereLHSBeginProp.getPath(),is("String_Node_Str"));
  assertThat(whereLHSBeginProp.getSource(),is(nullValue()));
  assertThat(whereLHSBeginProp.getDescription(),is(nullValue()));
  End whereLHSEnd=(End)whereLHS.getOperand().get(1);
  assertThat(whereLHSEnd.getDescription(),is(nullValue()));
  Property whereLHSEndProp=(Property)whereLHSEnd.getOperand();
  assertThat(whereLHSEndProp.getScope(),is("String_Node_Str"));
  assertThat(whereLHSEndProp.getPath(),is("String_Node_Str"));
  assertThat(whereLHSEndProp.getSource(),is(nullValue()));
  assertThat(whereLHSEndProp.getDescription(),is(nullValue()));
  assertThat(where.getOperand().get(1),literalFor(120));
  ObjectExpression rtn=(ObjectExpression)query.getReturn();
  assertThat(rtn.getDescription(),is(nullValue()));
  assertThat(rtn.getProperty(),hasSize(2));
  PropertyExpression rtnP1=rtn.getProperty().get(0);
  assertThat(rtnP1.getName(),is("String_Node_Str"));
  Property rtnP1Val=(Property)rtnP1.getValue();
  assertThat(rtnP1Val.getScope(),is("String_Node_Str"));
  assertThat(rtnP1Val.getPath(),is("String_Node_Str"));
  assertThat(rtnP1Val.getSource(),is(nullValue()));
  assertThat(rtnP1Val.getDescription(),is(nullValue()));
  PropertyExpression rtnP2=rtn.getProperty().get(1);
  assertThat(rtnP2.getName(),is("String_Node_Str"));
  DaysBetween rtnP2Val=(DaysBetween)rtnP2.getValue();
  assertThat(rtnP2Val.getDescription(),is(nullValue()));
  assertThat(rtnP2Val.getOperand(),hasSize(2));
  Begin rtnP2ValBegin=(Begin)rtnP2Val.getOperand().get(0);
  assertThat(rtnP2ValBegin.getDescription(),is(nullValue()));
  Property rtnP2ValBeginProp=(Property)rtnP2ValBegin.getOperand();
  assertThat(rtnP2ValBeginProp.getScope(),is("String_Node_Str"));
  assertThat(rtnP2ValBeginProp.getPath(),is("String_Node_Str"));
  assertThat(rtnP2ValBeginProp.getSource(),is(nullValue()));
  assertThat(rtnP2ValBeginProp.getDescription(),is(nullValue()));
  End rtnP2ValEnd=(End)rtnP2Val.getOperand().get(1);
  assertThat(rtnP2ValEnd.getDescription(),is(nullValue()));
  Property rtnP2ValEndProp=(Property)rtnP2ValEnd.getOperand();
  assertThat(rtnP2ValEndProp.getScope(),is("String_Node_Str"));
  assertThat(rtnP2ValEndProp.getPath(),is("String_Node_Str"));
  assertThat(rtnP2ValEndProp.getSource(),is(nullValue()));
  assertThat(rtnP2ValEndProp.getDescription(),is(nullValue()));
  SortClause sort=query.getSort();
  assertThat(sort.getBy(),hasSize(1));
  ByExpression sortBy=(ByExpression)sort.getBy().get(0);
  Identifier id=(Identifier)sortBy.getExpression();
  assertThat(id.getIdentifier(),is("String_Node_Str"));
  assertThat(id.getLibraryName(),is(nullValue()));
  assertThat(sortBy.getDirection(),is(SortDirection.DESC));
}