nus-yam/ex-repair huggingface dataset:
Program: 86763
Project: 86763
Buggy source:
/** 
 * @see ReportService#saveReport(Report,String)
 */
public Report saveReport(Report report,String description){
  String reportRequestUuid=report.getRequest().getUuid();
  CachedReportData cachedData=persistCachedReportDataToDisk(reportRequestUuid);
  if (cachedData.isPersisted()) {
    ReportRequest request=Context.getService(ReportService.class).getReportRequest(report.getRequest().getId());
    request.setStatus(Status.SAVED);
    request.setDescription(description);
    Context.getService(ReportService.class).saveReportRequest(request);
    logReportMessage(request,"String_Node_Str");
    report.setRequest(request);
    return report;
  }
 else {
    throw new ReportingException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * @see ReportService#saveReport(Report,String)
 */
public Report saveReport(Report report,String description){
  String reportRequestUuid=report.getRequest().getUuid();
  CachedReportData cachedData=persistCachedReportDataToDisk(reportRequestUuid);
  if (cachedData != null && !cachedData.isPersisted()) {
    throw new ReportingException("String_Node_Str");
  }
  ReportRequest request=Context.getService(ReportService.class).getReportRequest(report.getRequest().getId());
  request.setStatus(Status.SAVED);
  request.setDescription(description);
  Context.getService(ReportService.class).saveReportRequest(request);
  logReportMessage(request,"String_Node_Str");
  report.setRequest(request);
  return report;
}
Program: 86764
Project: 86764
Buggy source:
/** 
 * Saves the CachedReportData to disk
 */
protected CachedReportData persistCachedReportDataToDisk(String reportRequestUuid){
  CachedReportData cachedData=reportCache.get(reportRequestUuid);
  if (cachedData.isPersisted()) {
    log.debug("String_Node_Str");
  }
 else {
    ReportRequest request=getReportRequestByUuid(reportRequestUuid);
    BufferedOutputStream out=null;
    try {
      Timer timer=Timer.start();
      File reportDataFile=getReportDataFile(request);
      log.info(timer.logInterval("String_Node_Str" + reportDataFile.getPath()));
      out=new BufferedOutputStream(new FileOutputStream(reportDataFile));
      ReportingSerializer serializer=(ReportingSerializer)Context.getSerializationService().getSerializer(ReportingSerializer.class);
      serializer.serializeToStream(cachedData.getReportData(),out);
      log.info(timer.logInterval("String_Node_Str"));
      cachedData.setPersisted(true);
    }
 catch (    Exception e) {
      log.warn("String_Node_Str",e);
    }
 finally {
      IOUtils.closeQuietly(out);
    }
  }
  return cachedData;
}

Fixed version (ground truth):
/** 
 * Saves the CachedReportData to disk
 */
protected CachedReportData persistCachedReportDataToDisk(String reportRequestUuid){
  CachedReportData cachedData=reportCache.get(reportRequestUuid);
  if (cachedData != null) {
    if (cachedData.isPersisted()) {
      log.debug("String_Node_Str");
    }
 else {
      ReportRequest request=getReportRequestByUuid(reportRequestUuid);
      BufferedOutputStream out=null;
      try {
        Timer timer=Timer.start();
        File reportDataFile=getReportDataFile(request);
        log.info(timer.logInterval("String_Node_Str" + reportDataFile.getPath()));
        out=new BufferedOutputStream(new FileOutputStream(reportDataFile));
        ReportingSerializer serializer=(ReportingSerializer)Context.getSerializationService().getSerializer(ReportingSerializer.class);
        serializer.serializeToStream(cachedData.getReportData(),out);
        log.info(timer.logInterval("String_Node_Str"));
        cachedData.setPersisted(true);
      }
 catch (      Exception e) {
        log.warn("String_Node_Str",e);
      }
 finally {
        IOUtils.closeQuietly(out);
      }
    }
  }
  return cachedData;
}
Program: 86767
Project: 86767
Buggy source:
/** 
 * @see DataConverter#convert(Object)
 * @should convert a Date into a String with the passed format
 */
@SuppressWarnings("String_Node_Str") public Object convert(Object original){
  List l=(List)original;
  if (l != null) {
    if (specificItemIndex != null) {
      return (l.size() > specificItemIndex ? l.get(specificItemIndex) : null);
    }
    TimeQualifier which=ObjectUtil.nvl(whichItems,TimeQualifier.ANY);
    int max=(maxNumberOfItems == null || maxNumberOfItems > l.size() ? l.size() : maxNumberOfItems);
    if (which != TimeQualifier.FIRST) {
      Collections.reverse(l);
    }
    if (max == 1) {
      return l.get(0);
    }
 else {
      List<Object> ret=new ArrayList<Object>();
      for (int i=0; i < max; i++) {
        ret.add(l.get(i));
      }
      return ret;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @see DataConverter#convert(Object)
 * @should convert a Date into a String with the passed format
 */
@SuppressWarnings("String_Node_Str") public Object convert(Object original){
  List l=(List)original;
  if (l != null) {
    l=new ArrayList(l);
    if (specificItemIndex != null) {
      return (l.size() > specificItemIndex ? l.get(specificItemIndex) : null);
    }
    TimeQualifier which=ObjectUtil.nvl(whichItems,TimeQualifier.ANY);
    int max=(maxNumberOfItems == null || maxNumberOfItems > l.size() ? l.size() : maxNumberOfItems);
    if (which != TimeQualifier.FIRST) {
      Collections.reverse(l);
    }
    if (max == 1) {
      return l.get(0);
    }
 else {
      List<Object> ret=new ArrayList<Object>();
      for (int i=0; i < max; i++) {
        ret.add(l.get(i));
      }
      return ret;
    }
  }
  return null;
}
Program: 86768
Project: 86768
Buggy source:
/** 
 * @see org.openmrs.module.reporting.data.person.evaluator.PersonDataEvaluator#evaluate(org.openmrs.module.reporting.data.person.definition.PersonDataDefinition,org.openmrs.module.reporting.evaluation.EvaluationContext)
 * @should return the obs that match the passed definition configuration
 */
public EvaluatedPersonData evaluate(PersonDataDefinition definition,EvaluationContext context) throws EvaluationException {
  RelationshipsForPersonDataDefinition def=(RelationshipsForPersonDataDefinition)definition;
  EvaluatedPersonData pd=new EvaluatedPersonData(def,context);
  if (context.getBaseCohort() != null && context.getBaseCohort().isEmpty()) {
    return pd;
  }
  if (def.getRelationshipTypes() != null && def.getRelationshipTypes().isEmpty()) {
    return pd;
  }
  if (!def.getPersonAIncluded() && !def.getPersonBIncluded()) {
    return pd;
  }
  if (def.getPersonAIncluded()) {
    addRelationshipsForPerson(pd,"String_Node_Str");
  }
  if (def.getPersonBIncluded()) {
    addRelationshipsForPerson(pd,"String_Node_Str");
  }
  return pd;
}

Fixed version (ground truth):
/** 
 * @see org.openmrs.module.reporting.data.person.evaluator.PersonDataEvaluator#evaluate(org.openmrs.module.reporting.data.person.definition.PersonDataDefinition,org.openmrs.module.reporting.evaluation.EvaluationContext)
 * @should return the obs that match the passed definition configuration
 */
public EvaluatedPersonData evaluate(PersonDataDefinition definition,EvaluationContext context) throws EvaluationException {
  RelationshipsForPersonDataDefinition def=(RelationshipsForPersonDataDefinition)definition;
  EvaluatedPersonData pd=new EvaluatedPersonData(def,context);
  if (context.getBaseCohort() != null && context.getBaseCohort().isEmpty()) {
    return pd;
  }
  if (def.getRelationshipTypes() != null && def.getRelationshipTypes().isEmpty()) {
    return pd;
  }
  if (!def.getValuesArePersonA() && !def.getValuesArePersonB()) {
    return pd;
  }
  if (def.getValuesArePersonA()) {
    addRelationshipsForPerson(pd,"String_Node_Str");
  }
  if (def.getValuesArePersonB()) {
    addRelationshipsForPerson(pd,"String_Node_Str");
  }
  return pd;
}
Program: 86769
Project: 86769
Buggy source:
@Test public void evaluate_shouldReturnRelationshipsByAorB() throws Exception {
  EvaluationContext context=new EvaluationContext();
  context.setBaseCohort(new Cohort("String_Node_Str"));
  RelationshipsForPersonDataDefinition d=new RelationshipsForPersonDataDefinition();
  d.setRelationshipTypes(Arrays.asList(getDoctorPatientType()));
  d.setPersonBIncluded(Boolean.FALSE);
  EvaluatedPersonData pd=Context.getService(PersonDataService.class).evaluate(d,context);
  Assert.assertNull(getRelationships(pd,7));
  d.setPersonBIncluded(Boolean.TRUE);
  pd=Context.getService(PersonDataService.class).evaluate(d,context);
  Assert.assertEquals(1,getRelationships(pd,7).size());
}

Fixed version (ground truth):
@Test public void evaluate_shouldReturnRelationshipsByAorB() throws Exception {
  EvaluationContext context=new EvaluationContext();
  context.setBaseCohort(new Cohort("String_Node_Str"));
  RelationshipsForPersonDataDefinition d=new RelationshipsForPersonDataDefinition();
  d.setRelationshipTypes(Arrays.asList(getDoctorPatientType()));
  d.setValuesArePersonA(Boolean.FALSE);
  EvaluatedPersonData pd=Context.getService(PersonDataService.class).evaluate(d,context);
  Assert.assertNull(getRelationships(pd,7));
  d.setValuesArePersonB(Boolean.TRUE);
  pd=Context.getService(PersonDataService.class).evaluate(d,context);
  Assert.assertEquals(1,getRelationships(pd,7).size());
}
Program: 86770
Project: 86770
Buggy source:
public List<Map<String,Object>> getIterations(){
  List<Map<String,Object>> newIterations=new ArrayList<Map<String,Object>>();
  for (  Map<String,Object> iteration : iterations) {
    newIterations.add(new HashMap<String,Object>(iteration));
  }
  iterations=newIterations;
  return iterations;
}

Fixed version (ground truth):
public List<Map<String,Object>> getIterations(){
  return iterations;
}
Program: 86771
Project: 86771
Buggy source:
public void setIterations(List<Map<String,Object>> iterations){
  this.iterations=iterations;
}

Fixed version (ground truth):
public void setIterations(List<Map<String,Object>> iterations){
  List<Map<String,Object>> newIterations=new ArrayList<Map<String,Object>>();
  for (  Map<String,Object> iteration : iterations) {
    newIterations.add(new HashMap<String,Object>(iteration));
  }
  this.iterations=newIterations;
}
Program: 86774
Project: 86774
Buggy source:
@RequestMapping("String_Node_Str") public void showForm(ModelMap model,@RequestParam(value="String_Node_Str",required=false) String uuid){
  model.addAttribute("String_Node_Str",Context.getService(DataSetDefinitionService.class).getAllDefinitions(false));
  if (uuid == null) {
    model.addAttribute("String_Node_Str",new MultiParameterDataSetDefinition());
  }
 else {
    DataSetDefinition def=Context.getService(DataSetDefinitionService.class).getDefinitionByUuid(uuid);
    if (def instanceof MultiParameterDataSetDefinition) {
      model.addAttribute("String_Node_Str",def);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@RequestMapping("String_Node_Str") public void showForm(ModelMap model,@RequestParam(value="String_Node_Str",required=false) String uuid){
  List<DataSetDefinition> allDefinitions=Context.getService(DataSetDefinitionService.class).getAllDefinitions(false);
  if (uuid == null) {
    model.addAttribute("String_Node_Str",new MultiParameterDataSetDefinition());
  }
 else {
    DataSetDefinition def=Context.getService(DataSetDefinitionService.class).getDefinitionByUuid(uuid);
    allDefinitions.remove(def);
    if (def instanceof MultiParameterDataSetDefinition) {
      model.addAttribute("String_Node_Str",def);
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
  model.addAttribute("String_Node_Str",allDefinitions);
}
Program: 86775
Project: 86775
Buggy source:
@Override public DataSet evaluate(DataSetDefinition dataSetDefinition,EvaluationContext evalContext) throws EvaluationException {
  RepeatPerTimePeriodDataSetDefinition dsd=(RepeatPerTimePeriodDataSetDefinition)dataSetDefinition;
  MultiParameterDataSetDefinition delegate=new MultiParameterDataSetDefinition(dsd.getBaseDefinition());
  for (  Parameter parameter : dsd.getParameters()) {
    delegate.addParameter(parameter);
  }
  TimePeriod period=dsd.getRepeatPerTimePeriod();
  if (period == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DateTime thisPeriodStart=new DateTime(((Date)evalContext.getParameterValue("String_Node_Str")).getTime());
  DateTime end=new DateTime(((Date)evalContext.getParameterValue("String_Node_Str")).getTime());
  while (thisPeriodStart.isBefore(end)) {
    DateTime nextPeriodStart=thisPeriodStart.plus(period.getJodaPeriod());
    if (nextPeriodStart.isAfter(end)) {
      nextPeriodStart=end;
    }
    DateTime thisPeriodEnd=nextPeriodStart.minus(Duration.millis(1));
    Map<String,Object> iteration=new HashMap<String,Object>();
    iteration.put("String_Node_Str",thisPeriodStart.toDate());
    iteration.put("String_Node_Str",thisPeriodEnd.toDate());
    delegate.addIteration(iteration);
    thisPeriodStart=nextPeriodStart;
  }
  return dataSetDefinitionService.evaluate(delegate,evalContext);
}

Fixed version (ground truth):
@Override public DataSet evaluate(DataSetDefinition dataSetDefinition,EvaluationContext evalContext) throws EvaluationException {
  RepeatPerTimePeriodDataSetDefinition dsd=(RepeatPerTimePeriodDataSetDefinition)dataSetDefinition;
  MultiParameterDataSetDefinition delegate=new MultiParameterDataSetDefinition(dsd.getBaseDefinition());
  for (  Parameter parameter : dsd.getParameters()) {
    delegate.addParameter(parameter);
  }
  TimePeriod period=dsd.getRepeatPerTimePeriod();
  if (period == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DateTime thisPeriodStart=new DateTime(((Date)evalContext.getParameterValue("String_Node_Str")).getTime());
  DateTime end=new DateTime(((Date)evalContext.getParameterValue("String_Node_Str")).getTime());
  while (thisPeriodStart.isBefore(end)) {
    DateTime nextPeriodStart=thisPeriodStart.plus(period.getJodaPeriod());
    boolean lastIteration=!nextPeriodStart.isBefore(end);
    DateTime thisPeriodEnd;
    if (lastIteration) {
      thisPeriodEnd=end;
    }
 else {
      thisPeriodEnd=nextPeriodStart.minus(Duration.millis(1));
    }
    Map<String,Object> iteration=new HashMap<String,Object>();
    iteration.put("String_Node_Str",thisPeriodStart.toDate());
    iteration.put("String_Node_Str",thisPeriodEnd.toDate());
    delegate.addIteration(iteration);
    thisPeriodStart=nextPeriodStart;
  }
  return dataSetDefinitionService.evaluate(delegate,evalContext);
}
Program: 86778
Project: 86778
Buggy source:
/** 
 * @return a Composition Cohort Definition with a primary cohort which has 1 to n cohorts subtracted from it
 */
public static CohortDefinition minus(CohortDefinition base,CohortDefinition... toSubtract){
  CompositionCohortDefinition d=new CompositionCohortDefinition();
  d.addSearch("String_Node_Str",base,null);
  StringBuilder s=new StringBuilder("String_Node_Str");
  int i=1;
  for (  CohortDefinition cd : toSubtract) {
    d.addSearch("String_Node_Str" + i,cd,null);
    if (i > 1) {
      s.append("String_Node_Str");
    }
    s.append(i++);
  }
  s.append("String_Node_Str");
  d.setCompositionString(s.toString());
  return d;
}

Fixed version (ground truth):
/** 
 * @return a Composition Cohort Definition with a primary cohort which has 1 to n cohorts subtracted from it
 */
public static CohortDefinition minus(CohortDefinition base,CohortDefinition... toSubtract){
  CompositionCohortDefinition d=new CompositionCohortDefinition();
  d.addSearch("String_Node_Str",base,(Map<String,Object>)null);
  StringBuilder s=new StringBuilder("String_Node_Str");
  int i=1;
  for (  CohortDefinition cd : toSubtract) {
    d.addSearch("String_Node_Str" + i,cd,(Map<String,Object>)null);
    if (i > 1) {
      s.append("String_Node_Str");
    }
    s.append(i++);
  }
  s.append("String_Node_Str");
  d.setCompositionString(s.toString());
  return d;
}
Program: 86779
Project: 86779
Buggy source:
/** 
 * @return a Composition Cohort Definition with each definition composed with a single type of operator
 */
public static CohortDefinition getCompositionCohort(String operator,CohortDefinition... definitions){
  if (definitions.length == 1) {
    return definitions[0];
  }
  CompositionCohortDefinition d=new CompositionCohortDefinition();
  StringBuilder s=new StringBuilder();
  int i=1;
  for (  CohortDefinition cd : definitions) {
    if (cd != null) {
      d.addSearch("String_Node_Str" + i,cd,null);
      if (s.length() > 0) {
        s.append("String_Node_Str" + operator + "String_Node_Str");
      }
      s.append(i++);
    }
  }
  d.setCompositionString(s.toString());
  return d;
}

Fixed version (ground truth):
/** 
 * @return a Composition Cohort Definition with each definition composed with a single type of operator
 */
public static CohortDefinition getCompositionCohort(String operator,CohortDefinition... definitions){
  if (definitions.length == 1) {
    return definitions[0];
  }
  CompositionCohortDefinition d=new CompositionCohortDefinition();
  StringBuilder s=new StringBuilder();
  int i=1;
  for (  CohortDefinition cd : definitions) {
    if (cd != null) {
      d.addSearch("String_Node_Str" + i,cd,(Map<String,Object>)null);
      if (s.length() > 0) {
        s.append("String_Node_Str" + operator + "String_Node_Str");
      }
      s.append(i++);
    }
  }
  d.setCompositionString(s.toString());
  return d;
}
Program: 86781
Project: 86781
Buggy source:
/** 
 * @see SerializedDefinitionService#saveDefinition(Definition)
 */
public <T extends Definition>T saveDefinition(T definition){
  if (definition.getId() != null) {
    if (definition.getChangedBy() == null) {
      definition.setChangedBy(Context.getAuthenticatedUser());
    }
    if (definition.getDateChanged() == null) {
      definition.setDateChanged(new Date());
    }
  }
 else {
    if (definition.getCreator() == null) {
      definition.setCreator(Context.getAuthenticatedUser());
    }
    if (definition.getDateCreated() == null) {
      definition.setDateCreated(new Date());
    }
  }
  return dao.saveObject(definition,serializer);
}

Fixed version (ground truth):
/** 
 * @see SerializedDefinitionService#saveDefinition(Definition)
 */
public <T extends Definition>T saveDefinition(T definition){
  if (definition.getId() != null) {
    definition.setChangedBy(Context.getAuthenticatedUser());
    definition.setDateChanged(new Date());
  }
 else {
    if (definition.getCreator() == null) {
      definition.setCreator(Context.getAuthenticatedUser());
    }
    if (definition.getDateCreated() == null) {
      definition.setDateCreated(new Date());
    }
  }
  return dao.saveObject(definition,serializer);
}
Program: 86783
Project: 86783
Buggy source:
public CommandObject(){
  userEnteredParams=new LinkedHashMap<String,Object>();
}

Fixed version (ground truth):
public CommandObject(){
  userEnteredParams=new LinkedHashMap<String,Object>();
  expressions=new HashMap<String,String>();
}
Program: 86784
Project: 86784
Buggy source:
public int compare(ReportRequest r1,ReportRequest r2){
  if (r1 == null && r2 == null) {
    return 0;
  }
  if (r1 == null) {
    return -1;
  }
  if (r2 == null) {
    return 1;
  }
  int ret=OpenmrsUtil.compareWithNullAsLatest(r1.getEvaluateCompleteDatetime(),r2.getEvaluateCompleteDatetime());
  if (ret == 0) {
    ret=OpenmrsUtil.compareWithNullAsLatest(r1.getEvaluateStartDatetime(),r2.getEvaluateStartDatetime());
  }
  if (ret == 0) {
    ret=r1.getPriority().compareTo(r2.getPriority());
  }
  if (ret == 0) {
    ret=OpenmrsUtil.compareWithNullAsLatest(r1.getRequestDate(),r2.getRequestDate());
  }
  if (ret == 0) {
    ret=OpenmrsUtil.compareWithNullAsGreatest(r1.getUuid(),r2.getUuid());
  }
  return ret;
}

Fixed version (ground truth):
public int compare(ReportRequest r1,ReportRequest r2){
  if (r1 == null && r2 == null) {
    return 0;
  }
  if (r1 == null) {
    return -1;
  }
  if (r2 == null) {
    return 1;
  }
  Date d1=ObjectUtil.nvl(r1.getEvaluateCompleteDatetime(),r1.getEvaluateStartDatetime());
  Date d2=ObjectUtil.nvl(r2.getEvaluateCompleteDatetime(),r2.getEvaluateStartDatetime());
  int ret=OpenmrsUtil.compareWithNullAsLatest(d1,d2);
  if (ret == 0) {
    ret=r1.getPriority().compareTo(r2.getPriority());
  }
  if (ret == 0) {
    ret=OpenmrsUtil.compareWithNullAsLatest(r1.getRequestDate(),r2.getRequestDate());
  }
  if (ret == 0) {
    ret=OpenmrsUtil.compareWithNullAsGreatest(r1.getUuid(),r2.getUuid());
  }
  return ret;
}
Program: 86785
Project: 86785
Buggy source:
/** 
 * Utility method that extracts the position of a queued report request from its log file contents
 * @param reportRequest the {@link ReportRequest} object
 * @param rs {@link ReportService} object
 * @return the position of the report in the queue
 */
private Integer getQueuePosition(ReportRequest reportRequest,ReportService rs){
  List<String> logs=rs.loadReportLog(reportRequest);
  Integer position=null;
  for (  String log : logs) {
    log=log.trim();
    if (log.indexOf("String_Node_Str") > -1) {
      String[] tokens=log.split("String_Node_Str");
      try {
        position=Integer.valueOf(tokens[tokens.length - 1]);
      }
 catch (      NumberFormatException e) {
      }
      break;
    }
  }
  return position;
}

Fixed version (ground truth):
/** 
 * Utility method that extracts the position of a queued report request from its log file contents
 * @param reportRequest the {@link ReportRequest} object
 * @param rs {@link ReportService} object
 * @return the position of the report in the queue
 */
private Integer getQueuePosition(ReportRequest reportRequest,ReportService rs){
  List<String> logs=rs.loadReportLog(reportRequest);
  Integer position=null;
  for (  String log : logs) {
    log=log.trim();
    if (log.indexOf("String_Node_Str") > -1) {
      String[] tokens=log.split("String_Node_Str");
      try {
        position=Integer.valueOf(tokens[tokens.length - 1]);
      }
 catch (      NumberFormatException e) {
      }
    }
  }
  return position;
}
Program: 86786
Project: 86786
Buggy source:
/** 
 * Formats anything and prints it to sb. (Delegates to other methods here
 * @param sb
 * @param o
 */
private void printObject(StringBuilder sb,Object o){
  if (o instanceof Result) {
    printResult(sb,(Result)o);
  }
 else   if (o instanceof Collection) {
    for (Iterator<?> i=((Collection)o).iterator(); i.hasNext(); ) {
      printObject(sb,i.next());
      if (i.hasNext())       sb.append("String_Node_Str");
    }
  }
 else   if (o instanceof Date) {
    printDate(sb,(Date)o);
  }
 else   if (o instanceof Concept) {
    printConcept(sb,(Concept)o);
  }
 else   if (o instanceof Obs) {
    printObsValue(sb,(Obs)o);
  }
 else   if (o instanceof User) {
    printUser(sb,(User)o);
  }
 else   if (o instanceof Encounter) {
    printEncounter(sb,(Encounter)o);
  }
 else   if (o instanceof EncounterType) {
    printEncounterType(sb,(EncounterType)o);
  }
 else   if (o instanceof Location) {
    printLocation(sb,(Location)o);
  }
 else   if (o instanceof ReportData) {
    printReportData(sb,(ReportData)o);
  }
 else   if (o instanceof DataSet) {
    printDataSet(sb,null,(DataSet)o);
  }
 else   if (o instanceof Cohort) {
    printCohort(sb,(Cohort)o);
  }
 else   if (o instanceof CohortDimensionResult) {
    printCohortDimensionResult(sb,(CohortDimensionResult)o);
  }
 else   if (o instanceof BaseData) {
    printMap(sb,((BaseData)o).getData());
  }
 else   if (o instanceof OpenmrsMetadata) {
    sb.append(ObjectUtil.format(o));
  }
}

Fixed version (ground truth):
/** 
 * Formats anything and prints it to sb. (Delegates to other methods here
 * @param sb
 * @param o
 */
private void printObject(StringBuilder sb,Object o){
  if (o instanceof Result) {
    printResult(sb,(Result)o);
  }
 else   if (o instanceof Collection) {
    for (Iterator<?> i=((Collection)o).iterator(); i.hasNext(); ) {
      printObject(sb,i.next());
      if (i.hasNext())       sb.append("String_Node_Str");
    }
  }
 else   if (o instanceof Date) {
    printDate(sb,(Date)o);
  }
 else   if (o instanceof Concept) {
    printConcept(sb,(Concept)o);
  }
 else   if (o instanceof Obs) {
    printObsValue(sb,(Obs)o);
  }
 else   if (o instanceof User) {
    printUser(sb,(User)o);
  }
 else   if (o instanceof Encounter) {
    printEncounter(sb,(Encounter)o);
  }
 else   if (o instanceof EncounterType) {
    printEncounterType(sb,(EncounterType)o);
  }
 else   if (o instanceof Location) {
    printLocation(sb,(Location)o);
  }
 else   if (o instanceof ReportData) {
    printReportData(sb,(ReportData)o);
  }
 else   if (o instanceof DataSet) {
    printDataSet(sb,null,(DataSet)o);
  }
 else   if (o instanceof Cohort) {
    printCohort(sb,(Cohort)o);
  }
 else   if (o instanceof CohortDimensionResult) {
    printCohortDimensionResult(sb,(CohortDimensionResult)o);
  }
 else   if (o instanceof BaseData) {
    printMap(sb,((BaseData)o).getData());
  }
 else {
    sb.append(ObjectUtil.format(o));
  }
}
Program: 86787
Project: 86787
Buggy source:
/** 
 * @see ReportService#saveReport(Report,String)
 */
public Report saveReport(Report report,String description){
  boolean isPersisted=persistReportToDisk(report);
  if (isPersisted) {
    ReportRequest request=report.getRequest();
    request.setStatus(Status.SAVED);
    request.setDescription(description);
    Context.getService(ReportService.class).saveReportRequest(request);
    logReportMessage(request,"String_Node_Str");
    return report;
  }
 else {
    throw new ReportingException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * @see ReportService#saveReport(Report,String)
 */
public Report saveReport(Report report,String description){
  boolean isPersisted=persistReportToDisk(report);
  if (isPersisted) {
    ReportRequest request=Context.getService(ReportService.class).getReportRequest(report.getRequest().getId());
    request.setStatus(Status.SAVED);
    request.setDescription(description);
    Context.getService(ReportService.class).saveReportRequest(request);
    logReportMessage(request,"String_Node_Str");
    report.setRequest(request);
    return report;
  }
 else {
    throw new ReportingException("String_Node_Str");
  }
}
Program: 86788
Project: 86788
Buggy source:
@ModelAttribute("String_Node_Str") public Definition getDefinition(@RequestParam(required=false,value="String_Node_Str") String uuid,@RequestParam(required=false,value="String_Node_Str") Class<? extends Definition> type){
  if (ObjectUtil.isNull(uuid)) {
    try {
      Definition d=type.newInstance();
      return d;
    }
 catch (    Exception e) {
      throw new IllegalArgumentException("String_Node_Str" + type);
    }
  }
  return DefinitionContext.getDefinitionByUuid(type,uuid);
}

Fixed version (ground truth):
@ModelAttribute("String_Node_Str") public Definition getDefinition(@RequestParam(required=false,value="String_Node_Str") String uuid,@RequestParam(required=false,value="String_Node_Str") Class<? extends Definition> type){
  Definition d=null;
  if (ObjectUtil.isNull(uuid)) {
    d=DefinitionContext.getDefinitionByUuid(type,uuid);
  }
  if (d == null) {
    try {
      d=type.newInstance();
    }
 catch (    Exception e) {
      throw new IllegalArgumentException("String_Node_Str" + type);
    }
  }
  return d;
}
Program: 86794
Project: 86794
Buggy source:
@InitBinder public void initBinder(WebDataBinder binder){
  binder.registerCustomEditor(Location.class,new LocationEditor());
  binder.registerCustomEditor(Indicator.class,new IndicatorEditor());
}

Fixed version (ground truth):
@InitBinder public void initBinder(WebDataBinder binder){
  binder.registerCustomEditor(Location.class,new LocationEditor());
  binder.registerCustomEditor(Indicator.class,new IndicatorEditor());
  binder.registerCustomEditor(Integer.class,new CustomNumberEditor(Integer.class,true));
}
Program: 86795
Project: 86795
Buggy source:
/** 
 * Computes the list of patients who currently meet the given definition<br/>
 * @param cohortDefinition CohortDefinition to evaluate
 * @param context context to use during evaluation
 * @return the cohort of all patients who meet the definition now
 */
public Cohort evaluate(CohortDefinition cohortDefinition,EvaluationContext context);

Fixed version (ground truth):
/** 
 * Computes the list of patients who currently meet the given definition<br/>
 * @param cohortDefinition CohortDefinition to evaluate
 * @param context context to use during evaluation
 * @return the cohort of all patients who meet the definition now
 */
public Cohort evaluate(CohortDefinition cohortDefinition,EvaluationContext context) throws EvaluationException ;
Program: 86796
Project: 86796
Buggy source:
/** 
 * @see CohortDefinitionEvaluator#evaluateCohort(CohortDefinition,EvaluationContext)
 */
public Cohort evaluate(CohortDefinition cohortDefinition,EvaluationContext context){
  CompositionCohortDefinition composition=(CompositionCohortDefinition)cohortDefinition;
  return CohortExpressionParser.evaluate(composition,context);
}

Fixed version (ground truth):
/** 
 * @throws EvaluationException 
 * @see CohortDefinitionEvaluator#evaluateCohort(CohortDefinition,EvaluationContext)
 */
public Cohort evaluate(CohortDefinition cohortDefinition,EvaluationContext context) throws EvaluationException {
  CompositionCohortDefinition composition=(CompositionCohortDefinition)cohortDefinition;
  try {
    return CohortExpressionParser.evaluate(composition,context);
  }
 catch (  MissingDependencyException ex) {
    String name=composition.getName() != null ? composition.getName() : composition.getCompositionString();
    throw new EvaluationException("String_Node_Str" + ex.getPropertyThatFailed() + "String_Node_Str"+ name+ "String_Node_Str",ex);
  }
}
Program: 86797
Project: 86797
Buggy source:
/** 
 * @see CohortDefinitionEvaluator#evaluateCohort(CohortDefinition,EvaluationContext)
 * @should return all patients who are not in the inner cohort definition
 * @should successfully use the context base cohort
 */
public Cohort evaluate(CohortDefinition cohortDefinition,EvaluationContext context){
  InverseCohortDefinition icd=(InverseCohortDefinition)cohortDefinition;
  context=ObjectUtil.nvl(context,new EvaluationContext());
  Cohort allPatients=ObjectUtil.nvl(context.getBaseCohort(),Context.getPatientSetService().getAllPatients());
  Cohort baseCohort=Context.getService(CohortDefinitionService.class).evaluate(icd.getBaseDefinition(),context);
  return Cohort.subtract(allPatients,baseCohort);
}

Fixed version (ground truth):
/** 
 * @throws EvaluationException 
 * @see CohortDefinitionEvaluator#evaluateCohort(CohortDefinition,EvaluationContext)
 * @should return all patients who are not in the inner cohort definition
 * @should successfully use the context base cohort
 */
public Cohort evaluate(CohortDefinition cohortDefinition,EvaluationContext context) throws EvaluationException {
  InverseCohortDefinition icd=(InverseCohortDefinition)cohortDefinition;
  context=ObjectUtil.nvl(context,new EvaluationContext());
  Cohort allPatients=ObjectUtil.nvl(context.getBaseCohort(),Context.getPatientSetService().getAllPatients());
  Cohort baseCohort;
  try {
    baseCohort=Context.getService(CohortDefinitionService.class).evaluate(icd.getBaseDefinition(),context);
  }
 catch (  EvaluationException ex) {
    throw new EvaluationException("String_Node_Str");
  }
  return Cohort.subtract(allPatients,baseCohort);
}
Program: 86798
Project: 86798
Buggy source:
/** 
 * @see DefinitionService#evaluate(Mapped<Definition>, EvaluationContext)
 */
public EvaluatedCohort evaluate(Mapped<? extends CohortDefinition> definition,EvaluationContext context) throws APIException ;

Fixed version (ground truth):
/** 
 * @see DefinitionService#evaluate(Mapped<Definition>, EvaluationContext)
 */
public EvaluatedCohort evaluate(Mapped<? extends CohortDefinition> definition,EvaluationContext context) throws EvaluationException ;
Program: 86799
Project: 86799
Buggy source:
/** 
 * @see BaseDefinitionService#evaluate(Mapped,EvaluationContext)
 */
@Override public EvaluatedCohort evaluate(Mapped<? extends CohortDefinition> definition,EvaluationContext context) throws APIException {
  return (EvaluatedCohort)super.evaluate(definition,context);
}

Fixed version (ground truth):
/** 
 * @see BaseDefinitionService#evaluate(Mapped,EvaluationContext)
 */
@Override public EvaluatedCohort evaluate(Mapped<? extends CohortDefinition> definition,EvaluationContext context) throws EvaluationException {
  return (EvaluatedCohort)super.evaluate(definition,context);
}
Program: 86801
Project: 86801
Buggy source:
/** 
 * Returns the intersection of all passed CohortDefinitions
 * @param context - The EvaluationContext to utilize
 * @param definitions - The CohortDefinitions to evaluate
 * @return - The intersection of the Cohorts produced by each evaluated CohortDefinitions
 */
public static Cohort filter(EvaluationContext context,Mapped<CohortDefinition>... definitions){
  Cohort ret=context.getBaseCohort();
  if (definitions != null) {
    for (    Mapped<CohortDefinition> d : definitions) {
      if (d != null) {
        Cohort c=Context.getService(CohortDefinitionService.class).evaluate(d,context);
        if (ret == null) {
          ret=c;
        }
 else {
          ret=Cohort.intersect(ret,c);
        }
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Returns the intersection of all passed CohortDefinitions
 * @param context - The EvaluationContext to utilize
 * @param definitions - The CohortDefinitions to evaluate
 * @return - The intersection of the Cohorts produced by each evaluated CohortDefinitions
 * @throws EvaluationException if any of the passed definitions could not be evaluated
 */
public static Cohort filter(EvaluationContext context,Mapped<CohortDefinition>... definitions) throws EvaluationException {
  Cohort ret=context.getBaseCohort();
  if (definitions != null) {
    for (    Mapped<CohortDefinition> d : definitions) {
      if (d != null) {
        Cohort c=Context.getService(CohortDefinitionService.class).evaluate(d,context);
        if (ret == null) {
          ret=c;
        }
 else {
          ret=Cohort.intersect(ret,c);
        }
      }
    }
  }
  return ret;
}
Program: 86802
Project: 86802
Buggy source:
/** 
 * @see DataSetEvaluator#evaluate(DataSetDefinition,EvaluationContext)
 */
public DataSet evaluate(DataSetDefinition dataSetDefinition,EvaluationContext context){
  context=ObjectUtil.nvl(context,new EvaluationContext());
  if (context.getBaseCohort() == null) {
    context.setBaseCohort(Context.getPatientSetService().getAllPatients());
  }
  MapDataSet data=new MapDataSet(dataSetDefinition,context);
  CohortCrossTabDataSetDefinition dsd=(CohortCrossTabDataSetDefinition)dataSetDefinition;
  CohortDefinitionService cds=Context.getService(CohortDefinitionService.class);
  for (  CohortDataSetColumn col : dsd.getDataSetColumns()) {
    Cohort rowCohort=(col.getRowDefinition() == null ? context.getBaseCohort() : cds.evaluate(col.getRowDefinition(),context));
    Cohort colCohort=(col.getColumnDefinition() == null ? context.getBaseCohort() : cds.evaluate(col.getColumnDefinition(),context));
    Cohort c=Cohort.intersect(rowCohort,colCohort);
    data.addData(col,c);
  }
  return data;
}

Fixed version (ground truth):
/** 
 * @throws EvaluationException 
 * @see DataSetEvaluator#evaluate(DataSetDefinition,EvaluationContext)
 */
public DataSet evaluate(DataSetDefinition dataSetDefinition,EvaluationContext context) throws EvaluationException {
  context=ObjectUtil.nvl(context,new EvaluationContext());
  if (context.getBaseCohort() == null) {
    context.setBaseCohort(Context.getPatientSetService().getAllPatients());
  }
  MapDataSet data=new MapDataSet(dataSetDefinition,context);
  CohortCrossTabDataSetDefinition dsd=(CohortCrossTabDataSetDefinition)dataSetDefinition;
  CohortDefinitionService cds=Context.getService(CohortDefinitionService.class);
  for (  CohortDataSetColumn col : dsd.getDataSetColumns()) {
    Cohort rowCohort;
    try {
      rowCohort=(col.getRowDefinition() == null ? context.getBaseCohort() : cds.evaluate(col.getRowDefinition(),context));
    }
 catch (    EvaluationException ex) {
      throw new EvaluationException("String_Node_Str" + col.getRowName() + "String_Node_Str"+ col.getColumnName());
    }
    Cohort colCohort;
    try {
      colCohort=(col.getColumnDefinition() == null ? context.getBaseCohort() : cds.evaluate(col.getColumnDefinition(),context));
    }
 catch (    EvaluationException ex) {
      throw new EvaluationException("String_Node_Str" + col.getRowName() + "String_Node_Str"+ col.getColumnName());
    }
    Cohort c=Cohort.intersect(rowCohort,colCohort);
    data.addData(col,c);
  }
  return data;
}
Program: 86805
Project: 86805
Buggy source:
/** 
 * Get patients having ranged (i.e. Numeric or Date/Time) obs that match a complicated query.
 * @param timeModifier
 * @param question
 * @param groupingConcept
 * @param onOrAfter
 * @param onOrBefore
 * @param locationList
 * @param encounterTypeList
 * @param operator1
 * @param value1 if non-null this value controls whether the query looks at value_numeric or value_datetime
 * @param operator2
 * @param value2
 * @return cohort of patients with matching obs
 * @should get patients with any obs of a specified concept
 * @should get patients whose first obs of a specified concept is in a range
 * @should get patients whose maximum obs of a specified concept is equal to a specified value
 * @should get patients with any obs of a specified concept in a specified encounter type
 * @should get patients whose first obs of a specified concept in a specified encounter type is in a range
 * @should get patients whose maximum obs of a specified concept in a specified encounter type is equals to a specified value
 */
public Cohort getPatientsHavingRangedObs(TimeModifier timeModifier,Concept question,Concept groupingConcept,Date onOrAfter,Date onOrBefore,List<Location> locationList,List<EncounterType> encounterTypeList,RangeComparator operator1,Object value1,RangeComparator operator2,Object value2);

Fixed version (ground truth):
/** 
 * Get patients having ranged (i.e. Numeric or Date/Time) obs that match a complicated query.
 * @param timeModifier
 * @param question
 * @param groupingConcept
 * @param onOrAfter
 * @param onOrBefore
 * @param locationList
 * @param encounterTypeList
 * @param operator1
 * @param value1 if non-null this value controls whether the query looks at value_numeric or value_datetime
 * @param operator2
 * @param value2
 * @return cohort of patients with matching obs
 * @should get patients with any obs of a specified concept
 * @should get patients whose first obs of a specified concept is in a range
 * @should get patients whose maximum obs of a specified concept is equal to a specified value
 * @should get patients with any obs of a specified concept in a specified encounter type
 * @should get patients whose first obs of a specified concept in a specified encounter type is in a range
 * @should get patients whose maximum obs of a specified concept in a specified encounter type is equals to a specified value
 * @should get patients with a query with all parameters
 */
public Cohort getPatientsHavingRangedObs(TimeModifier timeModifier,Concept question,Concept groupingConcept,Date onOrAfter,Date onOrBefore,List<Location> locationList,List<EncounterType> encounterTypeList,RangeComparator operator1,Object value1,RangeComparator operator2,Object value2);
Program: 86806
Project: 86806
Buggy source:
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,Date,Date,List<Location>,List<EncounterType>,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseFirstObsOfASpecifiedConceptInASpecifiedEncounterTypeIsInARange() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  List<EncounterType> encTypeList=Collections.singletonList(new EncounterType(1));
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.FIRST,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.GREATER_THAN,54d,RangeComparator.LESS_EQUAL,56d);
  Assert.assertEquals(1,cohort.size());
  Assert.assertTrue(cohort.contains(7));
  encTypeList=Collections.singletonList(new EncounterType(2));
  cohort=service.getPatientsHavingRangedObs(TimeModifier.FIRST,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.GREATER_THAN,49d,RangeComparator.LESS_EQUAL,51d);
  Assert.assertEquals(1,cohort.size());
  Assert.assertTrue(cohort.contains(7));
}

Fixed version (ground truth):
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,Date,Date,List<Location>,List<EncounterType>,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseFirstObsOfASpecifiedConceptInASpecifiedEncounterTypeIsInARange() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  List<EncounterType> encTypeList=Collections.singletonList(new EncounterType(1));
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.FIRST,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.GREATER_THAN,54d,RangeComparator.LESS_EQUAL,56d);
  assertCohort(cohort,7);
  encTypeList=Collections.singletonList(new EncounterType(2));
  cohort=service.getPatientsHavingRangedObs(TimeModifier.FIRST,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.GREATER_THAN,49d,RangeComparator.LESS_EQUAL,51d);
  assertCohort(cohort,7);
}
Program: 86807
Project: 86807
Buggy source:
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,java.util.Date,java.util.Date,java.util.List,java.util.List,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseFirstObsOfASpecifiedConceptIsInARange() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.FIRST,new Concept(5089),null,null,null,null,null,RangeComparator.GREATER_THAN,50d,RangeComparator.LESS_EQUAL,80d);
  Assert.assertEquals(1,cohort.size());
  Assert.assertTrue(cohort.contains(21));
}

Fixed version (ground truth):
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,java.util.Date,java.util.Date,java.util.List,java.util.List,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseFirstObsOfASpecifiedConceptIsInARange() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.FIRST,new Concept(5089),null,null,null,null,null,RangeComparator.GREATER_THAN,50d,RangeComparator.LESS_EQUAL,80d);
  assertCohort(cohort,21);
}
Program: 86808
Project: 86808
Buggy source:
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,java.util.Date,java.util.Date,java.util.List,java.util.List,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseMaximumObsOfASpecifiedConceptIsEqualToASpecifiedValue() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.MAX,new Concept(5089),null,null,null,null,null,RangeComparator.EQUAL,180d,null,null);
  Assert.assertEquals(1,cohort.size());
  Assert.assertTrue(cohort.contains(20));
}

Fixed version (ground truth):
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,java.util.Date,java.util.Date,java.util.List,java.util.List,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseMaximumObsOfASpecifiedConceptIsEqualToASpecifiedValue() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.MAX,new Concept(5089),null,null,null,null,null,RangeComparator.EQUAL,180d,null,null);
  assertCohort(cohort,20);
}
Program: 86809
Project: 86809
Buggy source:
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,java.util.Date,java.util.Date,java.util.List,java.util.List,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWithAnyObsOfASpecifiedConcept() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.ANY,new Concept(5089),null,null,null,null,null,null,null,null,null);
  Assert.assertEquals(4,cohort.size());
  Assert.assertTrue(cohort.contains(7));
  Assert.assertTrue(cohort.contains(20));
  Assert.assertTrue(cohort.contains(21));
  Assert.assertTrue(cohort.contains(22));
}

Fixed version (ground truth):
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,java.util.Date,java.util.Date,java.util.List,java.util.List,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWithAnyObsOfASpecifiedConcept() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.ANY,new Concept(5089),null,null,null,null,null,null,null,null,null);
  assertCohort(cohort,7,20,21,22);
}
Program: 86810
Project: 86810
Buggy source:
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,Date,Date,List<Location>,List<EncounterType>,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseMaximumObsOfASpecifiedConceptInASpecifiedEncounterTypeIsEqualsToASpecifiedValue() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  List<EncounterType> encTypeList=Collections.singletonList(new EncounterType(1));
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.MAX,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.EQUAL,61d,null,null);
  Assert.assertEquals(1,cohort.size());
  Assert.assertTrue(cohort.contains(7));
  encTypeList=Collections.singletonList(new EncounterType(2));
  cohort=service.getPatientsHavingRangedObs(TimeModifier.MAX,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.EQUAL,50d,null,null);
  Assert.assertEquals(1,cohort.size());
  Assert.assertTrue(cohort.contains(7));
}

Fixed version (ground truth):
/** 
 * @see {@link CohortQueryService#getPatientsHavingRangedObs(TimeModifier,Concept,Concept,Date,Date,List<Location>,List<EncounterType>,RangeComparator,Object,RangeComparator,Object)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void getPatientsHavingRangedObs_shouldGetPatientsWhoseMaximumObsOfASpecifiedConceptInASpecifiedEncounterTypeIsEqualsToASpecifiedValue() throws Exception {
  CohortQueryService service=Context.getService(CohortQueryService.class);
  List<EncounterType> encTypeList=Collections.singletonList(new EncounterType(1));
  Cohort cohort=service.getPatientsHavingRangedObs(TimeModifier.MAX,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.EQUAL,61d,null,null);
  assertCohort(cohort,7);
  encTypeList=Collections.singletonList(new EncounterType(2));
  cohort=service.getPatientsHavingRangedObs(TimeModifier.MAX,new Concept(5089),null,null,null,null,encTypeList,RangeComparator.EQUAL,50d,null,null);
  assertCohort(cohort,7);
}