Program: 84833
Project: 84833
Buggy source:
@Test public void shouldMapTreatmentAdvicesToPillRegimenRequest(){
  PillRegimenRequestMapper pillRegimenRequestMapper=new PillRegimenRequestMapper(allDrugs,properties);
  TreatmentAdvice treatmentAdvice=new TreatmentAdvice();
  treatmentAdvice.setPatientId("String_Node_Str");
  List<DrugDosage> drugDosages=new ArrayList<DrugDosage>();
  LocalDate startDateForDrug1=DateUtil.newDate(2010,10,10);
  LocalDate endDateForDrug1=DateUtil.newDate(2010,12,10);
  LocalDate startDateForDrug2=DateUtil.newDate(2011,02,10);
  LocalDate endDateForDrug2=DateUtil.newDate(2011,06,10);
  when(allDrugs.get("String_Node_Str")).thenReturn(DrugBuilder.startRecording().withDefaults().withName("String_Node_Str").build());
  when(allDrugs.get("String_Node_Str")).thenReturn(DrugBuilder.startRecording().withDefaults().withName("String_Node_Str").build());
  String reminderTimeLag="String_Node_Str";
  propertiesExpectations(reminderTimeLag);
  drugDosages.add(drugDosage("String_Node_Str",startDateForDrug1,endDateForDrug1,Arrays.asList("String_Node_Str","String_Node_Str")));
  drugDosages.add(drugDosage("String_Node_Str",startDateForDrug2,endDateForDrug2,Arrays.asList("String_Node_Str","String_Node_Str")));
  treatmentAdvice.setDrugDosages(drugDosages);
  PillRegimenRequest pillRegimenRequest=pillRegimenRequestMapper.map(treatmentAdvice);
  Assert.assertEquals(treatmentAdvice.getPatientId(),pillRegimenRequest.getExternalId());
  Assert.assertNotNull(pillRegimenRequest.getReminderRepeatIntervalInMinutes());
  Assert.assertNotNull(pillRegimenRequest.getReminderRepeatWindowInHours());
  Assert.assertEquals(3,pillRegimenRequest.getDosageRequests().size());
  DosageRequest dosageRequest1=getByStartHour(17,pillRegimenRequest.getDosageRequests());
  assertDosageRequestWithReminderTimeLag(dosageRequest1,17,50);
  Assert.assertEquals(1,dosageRequest1.getMedicineRequests().size());
  assertMedicineRequest(dosageRequest1.getMedicineRequests().get(0),"String_Node_Str",startDateForDrug2,endDateForDrug2);
  DosageRequest dosageRequest2=getByStartHour(20,pillRegimenRequest.getDosageRequests());
  assertDosageRequestWithReminderTimeLag(dosageRequest2,20,35);
  Assert.assertEquals(1,dosageRequest2.getMedicineRequests().size());
  assertMedicineRequest(dosageRequest2.getMedicineRequests().get(0),"String_Node_Str",startDateForDrug1,endDateForDrug1);
  DosageRequest dosageRequest3=getByStartHour(9,pillRegimenRequest.getDosageRequests());
  assertDosageRequestWithReminderTimeLag(dosageRequest3,9,5);
  Assert.assertEquals(2,dosageRequest3.getMedicineRequests().size());
  assertMedicineRequest(dosageRequest3.getMedicineRequests().get(0),"String_Node_Str",startDateForDrug1,endDateForDrug1);
  assertMedicineRequest(dosageRequest3.getMedicineRequests().get(1),"String_Node_Str",startDateForDrug2,endDateForDrug2);
}

Fixed version (ground truth):
@Test public void shouldMapTreatmentAdvicesToPillRegimenRequest(){
  PillRegimenRequestMapper pillRegimenRequestMapper=new PillRegimenRequestMapper(allDrugs,properties);
  TreatmentAdvice treatmentAdvice=new TreatmentAdvice();
  treatmentAdvice.setPatientId("String_Node_Str");
  List<DrugDosage> drugDosages=new ArrayList<DrugDosage>();
  LocalDate startDateForDrug1=DateUtil.newDate(2010,10,10);
  LocalDate endDateForDrug1=DateUtil.newDate(2010,12,10);
  LocalDate startDateForDrug2=DateUtil.newDate(2011,02,10);
  LocalDate endDateForDrug2=DateUtil.newDate(2011,06,10);
  when(allDrugs.get("String_Node_Str")).thenReturn(DrugBuilder.startRecording().withDefaults().withName("String_Node_Str").build());
  when(allDrugs.get("String_Node_Str")).thenReturn(DrugBuilder.startRecording().withDefaults().withName("String_Node_Str").build());
  String reminderTimeLag="String_Node_Str";
  propertiesExpectations(reminderTimeLag);
  drugDosages.add(drugDosage("String_Node_Str",startDateForDrug1,endDateForDrug1,Arrays.asList("String_Node_Str","String_Node_Str")));
  drugDosages.add(drugDosage("String_Node_Str",startDateForDrug2,endDateForDrug2,Arrays.asList("String_Node_Str","String_Node_Str")));
  treatmentAdvice.setDrugDosages(drugDosages);
  DailyPillRegimenRequest pillRegimenRequest=pillRegimenRequestMapper.map(treatmentAdvice);
  Assert.assertEquals(treatmentAdvice.getPatientId(),pillRegimenRequest.getExternalId());
  Assert.assertNotNull(pillRegimenRequest.getReminderRepeatIntervalInMinutes());
  Assert.assertNotNull(pillRegimenRequest.getPillWindowInHours());
  Assert.assertEquals(3,pillRegimenRequest.getDosageRequests().size());
  DosageRequest dosageRequest1=getByStartHour(17,pillRegimenRequest.getDosageRequests());
  assertDosageRequestWithReminderTimeLag(dosageRequest1,17,50);
  Assert.assertEquals(1,dosageRequest1.getMedicineRequests().size());
  assertMedicineRequest(dosageRequest1.getMedicineRequests().get(0),"String_Node_Str",startDateForDrug2,endDateForDrug2);
  DosageRequest dosageRequest2=getByStartHour(20,pillRegimenRequest.getDosageRequests());
  assertDosageRequestWithReminderTimeLag(dosageRequest2,20,35);
  Assert.assertEquals(1,dosageRequest2.getMedicineRequests().size());
  assertMedicineRequest(dosageRequest2.getMedicineRequests().get(0),"String_Node_Str",startDateForDrug1,endDateForDrug1);
  DosageRequest dosageRequest3=getByStartHour(9,pillRegimenRequest.getDosageRequests());
  assertDosageRequestWithReminderTimeLag(dosageRequest3,9,5);
  Assert.assertEquals(2,dosageRequest3.getMedicineRequests().size());
  assertMedicineRequest(dosageRequest3.getMedicineRequests().get(0),"String_Node_Str",startDateForDrug1,endDateForDrug1);
  assertMedicineRequest(dosageRequest3.getMedicineRequests().get(1),"String_Node_Str",startDateForDrug2,endDateForDrug2);
}