### Question:
MultipleFilesDropController { @EventListener public void request(MultipleFilesDroppedEvent event) { if (event.files.size() == 1 && !event.files.get(0).isDirectory() && (FileType.TXT.matches(event.files.get(0).getName()) || FileType.CSV.matches(event.files.get(0).getName()))) { eventStudio().broadcast(new PdfFilesListLoadRequest(event.getOwnerModule(), event.files.get(0).toPath())); } else { final PdfLoadRequestEvent loadEvent = new PdfLoadRequestEvent(event.getOwnerModule()); getFiles(event.files).filter(f -> FileType.PDF.matches(f.getName())) .map(PdfDocumentDescriptor::newDescriptorNoPassword).forEach(loadEvent::add); if (!loadEvent.getDocuments().isEmpty()) { eventStudio().broadcast(loadEvent, event.getOwnerModule()); } else { eventStudio().broadcast(new AddNotificationRequestEvent(NotificationType.WARN, DefaultI18nContext.getInstance() .i18n("Drag and drop PDF files or directories containing PDF files"), DefaultI18nContext.getInstance().i18n("No PDF found"))); } } } @Inject  MultipleFilesDropController(Provider<AddSubdirectoriesConfirmationDialog> dialog); @EventListener void request(MultipleFilesDroppedEvent event);  }### Answer:
@Test public void noPdf() throws IOException { victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(folder.newFile()))); assertFalse(listener.isHit()); }
@Test public void directoryNoPdf() throws IOException { File dir = folder.newFolder(); Files.createTempFile(dir.toPath(), null, ".bla"); victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(dir))); assertFalse(listener.isHit()); }
@Test public void directoryYesPdf() throws IOException { File dir = folder.newFolder(); Files.createTempFile(dir.toPath(), null, ".pdf"); victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(dir))); assertTrue(listener.isHit()); }
@Test public void subdirectoryDialogFalseYesPdf() throws IOException { File dir = folder.newFolder(); Path subdir = Files.createTempDirectory(dir.toPath(), null); Files.createTempFile(subdir, null, ".pdf"); when(dialog.response()).thenReturn(Boolean.FALSE); victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(dir))); assertFalse(listener.isHit()); }
@Test public void subdirectoryDialogTrueYesPdf() throws IOException { File dir = folder.newFolder(); Path subdir = Files.createTempDirectory(dir.toPath(), null); Files.createTempFile(subdir, null, ".pdf"); when(dialog.response()).thenReturn(Boolean.TRUE); victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(dir))); assertTrue(listener.isHit()); }
@Test public void subdirectoryDialogTrueNoPdf() throws IOException { File dir = folder.newFolder(); Path subdir = Files.createTempDirectory(dir.toPath(), null); Files.createTempFile(subdir, null, ".bla"); when(dialog.response()).thenReturn(Boolean.TRUE); victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(dir))); assertFalse(listener.isHit()); }
@Test public void onePdf() throws IOException { victim.request( new MultipleFilesDroppedEvent(MODULE, Arrays.asList(folder.newFile(), folder.newFile("test.pdf")))); assertTrue(listener.isHit()); }
@Test public void oneCsv() throws IOException { victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(folder.newFile("test.csv")))); assertTrue(listListener.isHit()); }
@Test public void oneTxt() throws IOException { victim.request(new MultipleFilesDroppedEvent(MODULE, Arrays.asList(folder.newFile("test.txt")))); assertTrue(listListener.isHit()); }