### Question:
PdfLoadController { @EventListener public void request(PdfLoadRequestEvent event) { LOG.trace("PDF load request received"); event.getDocuments().forEach(i -> i.moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED)); executor.execute(() -> loadService.load(event.getDocuments(), requiredLoadData.get(event.getOwnerModule()))); } @Inject  PdfLoadController(List<Module> modules, PdfLoadService loadService); @EventListener void request(PdfLoadRequestEvent event); @EventListener void request(PdfFilesListLoadRequest event); @EventListener void onShutdown(ShutdownEvent event);  }### Answer:
@Test public void request() { PdfLoadRequestEvent event = new PdfLoadRequestEvent(DefaultPriorityTestModule.ID); PdfDocumentDescriptor first = mock(PdfDocumentDescriptor.class); PdfDocumentDescriptor second = mock(PdfDocumentDescriptor.class); event.add(first); event.add(second); victim.request(event); verify(first).moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); verify(second).moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); verify(loadService, timeout(1000).times(1)).load(anyCollection(), eq(RequiredPdfData.DEFAULT)); }
@Test public void emptyList() throws IOException { Path list = tmp.newFile().toPath(); List<String> lines = new ArrayList<>(); lines.add("I don't exist"); Files.write(list, lines); PdfFilesListLoadRequest event = new PdfFilesListLoadRequest(DefaultPriorityTestModule.ID, list); Listener<PdfLoadRequestEvent> listener = mock(Listener.class); eventStudio().add(PdfLoadRequestEvent.class, listener, DefaultPriorityTestModule.ID); victim.request(event); verify(listener, after(1000).never()).onEvent(any()); }
@Test public void validList() throws IOException { File file1 = tmp.newFile("apdf.pdf"); Path list = tmp.newFile().toPath(); List<String> lines = new ArrayList<>(); lines.add(file1.getAbsolutePath()); Files.write(list, lines); PdfFilesListLoadRequest event = new PdfFilesListLoadRequest(DefaultPriorityTestModule.ID, list); Listener<PdfLoadRequestEvent> listener = mock(Listener.class); eventStudio().add(PdfLoadRequestEvent.class, listener, DefaultPriorityTestModule.ID); victim.request(event); ArgumentCaptor<PdfLoadRequestEvent> captor = ArgumentCaptor.forClass(PdfLoadRequestEvent.class); verify(listener, timeout(60000).times(1)).onEvent(captor.capture()); assertEquals(1, captor.getValue().getDocuments().size()); }