### Question:
OpenButton extends SplitMenuButton implements TaskOutputDispatcher { @Override public void dispatch(FileTaskOutput output) { destination = output.getDestination(); setGraphic(FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.FILE_PDF_ALT, "1.6em")); } OpenButton(String ownerModule, ModuleInputOutputType outputType); void initModules(Collection<Module> modules); @EventStation String getOwnerModule(); @EventListener(priority = -10) void onTaskCompleted(TaskExecutionCompletedEvent event); @Override void dispatch(FileTaskOutput output); @Override void dispatch(DirectoryTaskOutput output); @Override void dispatch(FileOrDirectoryTaskOutput output);  }### Answer:
@Test public void openFileClick() throws Exception { File file = temp.newFile(); FileTaskOutput output = new FileTaskOutput(file); TestListener listener = new TestListener(file); eventStudio().add(listener); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.dispatch(output)); clickOn(victim); assertTrue(listener.isHit()); assertTrue(listener.equal); }
@Test public void openDirectoryClick() throws Exception { File dir = temp.newFolder(); DirectoryTaskOutput output = new DirectoryTaskOutput(dir); TestListener listener = new TestListener(dir); eventStudio().add(listener); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.dispatch(output)); clickOn(victim); assertTrue(listener.isHit()); assertTrue(listener.equal); }
@Test public void openSingleFileDirectoryDestinationClick() throws Exception { File file = temp.newFile(); DirectoryTaskOutput output = new DirectoryTaskOutput(file.getParentFile()); TestListener listener = new TestListener(file); eventStudio().add(listener); NotifiableTaskMetadata taskMetadata = new NotifiableTaskMetadata(mock(Task.class)); taskMetadata.addTaskOutput(file); eventStudio().broadcast(new TaskExecutionCompletedEvent(12, taskMetadata), "moduleId"); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.dispatch(output)); clickOn(victim); assertTrue(listener.isHit()); assertTrue(listener.equal); }
@Test public void fileDestination() { FileTaskOutput output = mock(FileTaskOutput.class); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.dispatch(output)); verify(output).getDestination(); Text icon = lookup(".glyph-icon").queryAs(Text.class); assertEquals(FontAwesomeIcon.FILE_PDF_ALT.unicode(), icon.getText()); }
@Test public void directoryDestination() { DirectoryTaskOutput output = mock(DirectoryTaskOutput.class); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.dispatch(output)); verify(output).getDestination(); Text icon = lookup(".glyph-icon").queryAs(Text.class); assertEquals(MaterialDesignIcon.FOLDER_OUTLINE.unicode(), icon.getText()); }
@Test public void fileOrDirDestination() { DirectoryTaskOutput output = mock(DirectoryTaskOutput.class); WaitForAsyncUtils.waitForAsyncFx(2000, () -> victim.dispatch(output)); verify(output).getDestination(); Text icon = lookup(".glyph-icon").queryAs(Text.class); assertEquals(MaterialDesignIcon.FOLDER_OUTLINE.unicode(), icon.getText()); }