Program: 86773
Project: 86773
Buggy source:
/** 
 * @see {@link org.openmrs.module.reporting.dataset.definition.evaluator.MultiParameterDataSetEvaluator#evaluate(org.openmrs.module.reporting.dataset.definition.DataSetDefinition,org.openmrs.module.reporting.evaluation.EvaluationContext)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void evaluate_shouldEvaluateAMultiParameterDataSetDefinition() throws Exception {
  SqlDataSetDefinition sqlDataSetDefinition=new SqlDataSetDefinition();
  sqlDataSetDefinition.setSqlQuery("String_Node_Str");
  sqlDataSetDefinition.addParameter(new Parameter("String_Node_Str","String_Node_Str",Date.class));
  MultiParameterDataSetDefinition multiParameterDataSetDefinition=new MultiParameterDataSetDefinition();
  multiParameterDataSetDefinition.setBaseDefinition(sqlDataSetDefinition);
  List<Map<String,Object>> iterations=new ArrayList<Map<String,Object>>();
  Map<String,Object> iteration=new HashMap<String,Object>();
  iteration.put("String_Node_Str","String_Node_Str");
  iterations.add(iteration);
  iteration=new HashMap<String,Object>();
  iteration.put("String_Node_Str","String_Node_Str");
  iterations.add(iteration);
  multiParameterDataSetDefinition.setIterations(iterations);
  multiParameterDataSetDefinition.addParameter(new Parameter("String_Node_Str","String_Node_Str",Date.class));
  EvaluationContext evaluationContext=new EvaluationContext(new Date());
  evaluationContext.addParameterValue("String_Node_Str",new Date(2013,01,01));
  SimpleDataSet result=(SimpleDataSet)Context.getService(DataSetDefinitionService.class).evaluate(multiParameterDataSetDefinition,evaluationContext);
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",String.class)));
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",Integer.class)));
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",String.class)));
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",Date.class)));
}

Fixed version (ground truth):
/** 
 * @see {@link org.openmrs.module.reporting.dataset.definition.evaluator.MultiParameterDataSetEvaluator#evaluate(org.openmrs.module.reporting.dataset.definition.DataSetDefinition,org.openmrs.module.reporting.evaluation.EvaluationContext)}
 */
@Test @Verifies(value="String_Node_Str",method="String_Node_Str") public void evaluate_shouldEvaluateAMultiParameterDataSetDefinition() throws Exception {
  SqlDataSetDefinition sqlDataSetDefinition=new SqlDataSetDefinition();
  sqlDataSetDefinition.setSqlQuery("String_Node_Str");
  sqlDataSetDefinition.addParameter(new Parameter("String_Node_Str","String_Node_Str",Date.class));
  MultiParameterDataSetDefinition multiParameterDataSetDefinition=new MultiParameterDataSetDefinition();
  multiParameterDataSetDefinition.setBaseDefinition(sqlDataSetDefinition);
  List<Map<String,Object>> iterations=new ArrayList<Map<String,Object>>();
  Map<String,Object> iteration=new HashMap<String,Object>();
  iteration.put("String_Node_Str","String_Node_Str");
  iterations.add(iteration);
  iteration=new HashMap<String,Object>();
  iteration.put("String_Node_Str","String_Node_Str");
  iterations.add(iteration);
  multiParameterDataSetDefinition.setIterations(iterations);
  multiParameterDataSetDefinition.addParameter(new Parameter("String_Node_Str","String_Node_Str",Date.class));
  Calendar cal=Calendar.getInstance();
  cal.set(1976,Calendar.AUGUST,24,0,0);
  Date firstIterationParameter=cal.getTime();
  cal.add(Calendar.DATE,2);
  Date secondIterationParameter=cal.getTime();
  EvaluationContext evaluationContext=new EvaluationContext(new Date());
  evaluationContext.addParameterValue("String_Node_Str",firstIterationParameter);
  SimpleDataSet result=(SimpleDataSet)dataSetDefinitionService.evaluate(multiParameterDataSetDefinition,evaluationContext);
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",String.class)));
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",Integer.class)));
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",String.class)));
  Assert.assertTrue(result.getMetaData().getColumns().contains(new DataSetColumn("String_Node_Str","String_Node_Str",Date.class)));
  Assert.assertEquals(3,result.getRowMap().size());
  Assert.assertEquals(firstIterationParameter,result.getRowMap().get(1).getColumnValue("String_Node_Str"));
  Assert.assertEquals(secondIterationParameter,result.getRowMap().get(2).getColumnValue("String_Node_Str"));
  Assert.assertEquals(secondIterationParameter,result.getRowMap().get(3).getColumnValue("String_Node_Str"));
  Date firstDateResult=(Date)result.getRowMap().get(1).getColumnValue("String_Node_Str");
  Date secondDateResult=(Date)result.getRowMap().get(2).getColumnValue("String_Node_Str");
  Date thirdDateResult=(Date)result.getRowMap().get(3).getColumnValue("String_Node_Str");
  Assert.assertEquals(Timestamp.valueOf("String_Node_Str"),firstDateResult);
  Assert.assertEquals(Timestamp.valueOf("String_Node_Str"),secondDateResult);
  Assert.assertEquals(Timestamp.valueOf("String_Node_Str"),thirdDateResult);
  Assert.assertTrue(firstDateResult.before(firstIterationParameter));
  Assert.assertFalse(thirdDateResult.before(firstIterationParameter));
  Assert.assertTrue(secondDateResult.before(secondIterationParameter));
  Assert.assertTrue(thirdDateResult.before(secondIterationParameter));
}