### Question:
SingleSelectionPane extends VBox implements ModuleOwned, PdfDocumentDescriptorProvider, RestorableView { @Override public PdfDocumentDescriptor getPdfDocumentDescriptor() { return descriptor; } SingleSelectionPane(String ownerModule); @Override PdfDocumentDescriptor getPdfDocumentDescriptor(); @Override void saveStateTo(Map<String, String> data); @Override void restoreStateFrom(Map<String, String> data); void addOnLoaded(Consumer<PdfDocumentDescriptor> onDescriptorLoaded); @EventListener void onClearSelected(ClearModuleEvent event); @EventListener void onLoadDocumentsRequest(PdfLoadRequestEvent loadEvent); @Override @EventStation String getOwnerModule(); void setPromptText(String text);  }### Answer:
@Test @Category(NoHeadless.class) public void openFileMenuItem() throws Exception { var listener = new HitTestListener<OpenFileRequest>() { @Override public void onEvent(OpenFileRequest event) { super.onEvent(event); assertEquals(victim.getPdfDocumentDescriptor().getFile(), event.getFile()); } }; eventStudio().add(OpenFileRequest.class, listener); typePathAndValidate(); rightClickOn(".validable-container-field"); clickOn(DefaultI18nContext.getInstance().i18n("Open")); assertTrue(listener.isHit()); }
@Test @Category(NoHeadless.class) public void openFolderMenuItem() throws Exception { var listener = new HitTestListener<OpenFileRequest>() { @Override public void onEvent(OpenFileRequest event) { super.onEvent(event); assertEquals(victim.getPdfDocumentDescriptor().getFile().getParentFile(), event.getFile()); } }; eventStudio().add(OpenFileRequest.class, listener); typePathAndValidate(); rightClickOn(".validable-container-field"); clickOn(DefaultI18nContext.getInstance().i18n("Open Folder")); assertTrue(listener.isHit()); }
@Test public void loadingStateDetails() throws Exception { typePathAndValidate(); WaitForAsyncUtils.waitForAsyncFx(2000, () -> { victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADING); }); assertTrue(lookup(DefaultI18nContext.getInstance().i18n("Loading...")).tryQuery().isPresent()); }
@Test public void clickWithErrorsShowsLogStage() throws Exception { typePathAndValidate(); WaitForAsyncUtils.waitForAsyncFx(2000, () -> { victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADING); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.WITH_ERRORS); }); Listener<ShowStageRequest> listener = mock(Listener.class); eventStudio().add(ShowStageRequest.class, listener, "LogStage"); clickOn(FontAwesomeIcon.WARNING.unicode()); verify(listener).onEvent(any()); }
@Test public void invalidatedDescriptorDoesntTriggerAnything() throws Exception { typePathAndValidate(); typePathAndValidate("/this/doesnt/exists"); WaitForAsyncUtils.waitForAsyncFx(2000, () -> { victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADING); victim.getPdfDocumentDescriptor().moveStatusTo(PdfDescriptorLoadingStatus.LOADED); }); Labeled details = lookup(".-pdfsam-selection-details").queryLabeled(); assertTrue(isEmpty(details.getText())); Labeled encStatus = lookup(".encryption-status").queryLabeled(); assertTrue(isEmpty(encStatus.getText())); var field = lookup(".validable-container-field").queryAs(ValidableTextField.class); field.getContextMenu().getItems().parallelStream().filter(i -> !(i instanceof SeparatorMenuItem)) .filter(i -> !i.getText().equals(DefaultI18nContext.getInstance().i18n("Remove"))) .forEach(i -> assertTrue(i.isDisable())); }