@Test
public void testExtractWarningsSearchDtos()
{

  //problems with date conversion
  final DateTime start =
      DataValueUtils.getDateTime(DataValueUtils.getDateTime(new DateTime(2013, 3, 25, 12, 0, DateTimeZone.UTC)));
  //mock
  final Map<Long, MedicationHolderDto> medicationHolderMap = new HashMap<>();
  final MedicationHolderDto medicationDto1 = new MedicationHolderDto();
  medicationDto1.setId(1L);
  medicationDto1.setName("Lekadol 20x500mg");
  medicationHolderMap.put(1L, medicationDto1);
  final MedicationHolderDto medicationDto2 = new MedicationHolderDto();
  medicationDto2.setId(2L);
  medicationDto2.setName("Primotren 20x500mg");
  medicationHolderMap.put(2L, medicationDto2);
  final MedicationsValueHolder medicationsValueHolder = mock(MedicationsValueHolder.class);
  when(medicationsValueHolder.getValue()).thenReturn(medicationHolderMap);
  medicationsBo.setMedicationsValueHolder(medicationsValueHolder);
  //simple therapy
  final MedicationOrderComposition composition1 =
      MedicationsTestUtils.buildTestMedicationOrderComposition("uid1::1", null, null);
  final MedicationInstructionInstruction instruction1 =
      MedicationsTestUtils.buildTestMedicationInstruction("MedicationInstructionInstruction 1");
  final MedicationTimingCluster medicationTimingCluster =
      MedicationsTestUtils.buildMedicationTimingCluster(4L, null, null, null, start, null, null);
  final OrderActivity orderActivity1 =
      MedicationsTestUtils.buildTestOrderActivity(
          "Lekadol", 1L, 500.0, "mg", null, null, null, null, 1L, "ORAL", "1", "TBL");
  instruction1.getOrder().add(orderActivity1);
  orderActivity1.setMedicationTiming(medicationTimingCluster);
  composition1.getMedicationDetail().getMedicationInstruction().add(instruction1);
  final List<MedicationOrderComposition> medicationInstructionsList1 = new ArrayList<>();
  medicationInstructionsList1.add(composition1);
  final List<MedicationForWarningsSearchDto> warningsSearchDtosList1 = medicationsBo.extractWarningsSearchDtos(
      medicationInstructionsList1);
  assertEquals((Double)500.0, warningsSearchDtosList1.get(0).getDoseAmount());
  assertEquals("mg", warningsSearchDtosList1.get(0).getDoseUnit());
  assertEquals("1", warningsSearchDtosList1.get(0).getRouteCode());
  //complex therapy
  final MedicationOrderComposition composition2 =
      MedicationsTestUtils.buildTestMedicationOrderComposition("uid1::1", null, null);
  final MedicationInstructionInstruction instruction2 =
      MedicationsTestUtils.buildTestMedicationInstruction("MedicationInstructionInstruction 1");
  final IngredientCluster ingredient =
      MedicationsTestUtils.buildTestActiveIngredient("Primotren", "0002", null, null, 10.0, "mg", 3.0, "mL");
  final OrderActivity orderActivity2 =
      MedicationsTestUtils.buildTestOrderActivity(null, null, null, null, null, null, null, null, 1L, "ORAL", "1", "TBL");
  instruction2.getOrder().add(orderActivity2);
  final IngredientsAndFormCluster ingredientsAndForm = new IngredientsAndFormCluster();
  orderActivity2.setIngredientsAndForm(ingredientsAndForm);
  ingredientsAndForm.getIngredient().add(ingredient);
  orderActivity2.setMedicationTiming(medicationTimingCluster);
  composition2.getMedicationDetail().getMedicationInstruction().add(instruction2);
  final List<MedicationOrderComposition> medicationInstructionsList2 = new ArrayList<>();
  medicationInstructionsList2.add(composition2);
  final List<MedicationForWarningsSearchDto> warningsSearchDtosList2 = medicationsBo.extractWarningsSearchDtos(
      medicationInstructionsList2);
  assertEquals((Double)10.0, warningsSearchDtosList2.get(0).getDoseAmount());
  assertEquals("mg", warningsSearchDtosList2.get(0).getDoseUnit());
  assertEquals("1", warningsSearchDtosList2.get(0).getRouteCode());
}