@Test
public void testGetAdministrationTaskForBarcodeMultipleTasksMultipleTherapies()
{

  Mockito
      .when(medicationsDao.getMedicationIdForBarcode("999"))
      .thenReturn(999L);
  Mockito
      .when(medicationsTasksProvider.findAdministrationTasks(
          Collections.singleton("1"),
          testTime.minusHours(1),
          testTime.plusHours(1)))
      .thenReturn(Lists.newArrayList(
          buildTaskDto("333", "uid1|Medication instruction"),
          buildTaskDto("334", "uid2|Medication instruction")));
  final Pair<MedicationOrderComposition, MedicationInstructionInstruction> instructionPair1 = buildInstructionPair(
      "uid1::1");
  final Pair<MedicationOrderComposition, MedicationInstructionInstruction> instructionPair2 = buildInstructionPair(
      "uid2::1");
  Mockito
      .when(medicationsOpenEhrDao.getTherapyInstructionPairs(Sets.newHashSet("uid1", "uid2")))
      .thenReturn(Lists.newArrayList(instructionPair1, instructionPair2));
  Mockito
      .when(medicationsBo.getMedicationIds(instructionPair1.getSecond().getOrder().get(0)))
      .thenReturn(Lists.newArrayList(999L));
  Mockito
      .when(medicationsBo.getMedicationIds(instructionPair2.getSecond().getOrder().get(0)))
      .thenReturn(Lists.newArrayList(888L));
  Mockito
      .when(medicationsFinder.findMedicationProducts(888L, Lists.newArrayList(444L), testTime))
      .thenReturn(Lists.newArrayList(buildMedicationDto(888L), buildMedicationDto(999L)));
  final BarcodeTaskSearchDto dto = barcodeTaskFinder.getAdministrationTaskForBarcode("1", "999", testTime);
  assertEquals(BarcodeSearchResult.MULTIPLE_TASKS, dto.getBarcodeSearchResult());
  assertNull(dto.getTaskId());
}