@Test
public void testBuildWarningSearchDto()
{

  //problems with date conversion
  final DateTime start =
      DataValueUtils.getDateTime(DataValueUtils.getDateTime(new DateTime(2013, 3, 25, 12, 0, DateTimeZone.UTC)));
  final Map<Long, MedicationHolderDto> medicationHolderMap = new HashMap<>();
  final MedicationHolderDto medicationDto = new MedicationHolderDto();
  medicationDto.setId(1L);
  medicationDto.setName("Lekadol 20x500mg");
  medicationHolderMap.put(1L, medicationDto);
  final MedicationsValueHolder medicationsValueHolder = mock(MedicationsValueHolder.class);
  when(medicationsValueHolder.getValue()).thenReturn(medicationHolderMap);
  medicationsBo.setMedicationsValueHolder(medicationsValueHolder);
  //end not set
  final DateTime stop1 = null;
  final MedicationTimingCluster medicationTimingCluster1 =
      MedicationsTestUtils.buildMedicationTimingCluster(4L, null, null, null, start, stop1, null);
  final MedicationForWarningsSearchDto warningsSearchDto1 =
      medicationsBo.buildWarningSearchDto(medicationTimingCluster1, 1L, "ORAL", 500.0, "mg");
  assertEquals(4L, (long)warningsSearchDto1.getFrequency());
  assertEquals("ORAL", warningsSearchDto1.getRouteCode());
  assertEquals(Double.valueOf(500.0), warningsSearchDto1.getDoseAmount());
  assertEquals("mg", warningsSearchDto1.getDoseUnit());
  assertEquals("Lekadol 20x500mg", warningsSearchDto1.getName());
  assertEquals(1L, warningsSearchDto1.getId());
  assertEquals(
      new DateTime(2013, 3, 25, 12, 0, DateTimeZone.UTC).getMillis(),
      warningsSearchDto1.getEffective().getStart().getMillis());
  assertEquals(Intervals.INFINITE.getEnd().getMillis(), warningsSearchDto1.getEffective().getEnd().getMillis());
  //end set
  final DateTime stop2 = new DateTime(2013, 3, 30, 12, 0);
  final MedicationTimingCluster medicationTimingCluster2 =
      MedicationsTestUtils.buildMedicationTimingCluster(4L, null, null, null, start, stop2, null);
  final MedicationForWarningsSearchDto warningsSearchDto2 =
      medicationsBo.buildWarningSearchDto(medicationTimingCluster2, 1L, "ORAL", 500.0, "mg");
  assertEquals(4L, (long)warningsSearchDto2.getFrequency());
  assertEquals("ORAL", warningsSearchDto2.getRouteCode());
  assertEquals(Double.valueOf(500.0), warningsSearchDto2.getDoseAmount());
  assertEquals("mg", warningsSearchDto2.getDoseUnit());
  assertEquals("Lekadol 20x500mg", warningsSearchDto2.getName());
  assertEquals(1L, warningsSearchDto2.getId());
  assertEquals(start, warningsSearchDto2.getEffective().getStart());
  assertEquals(stop2.getMillis(), warningsSearchDto2.getEffective().getEnd().getMillis());
}