### Question:
FileVersionSelector implements IVersionSelector { public void cancel() { isCancelled.set(true); selectedVersion = null; doneSignal.countDown(); } FileVersionSelector(final IFileVersionSelectorListener listener); void cancel(); boolean isCancelled(); void selectVersion(IFileVersion selectedVersion, Path fileToRecover); @Override IFileVersion selectVersion(List<IFileVersion> availableVersions); String getRecoveredFileName(); @Override String getRecoveredFileName(String fullName, String name, String extension);  }### Answer:
@Test public void testCancel() throws NoSessionException, NoPeerConnectionException, InvalidProcessStateException, ProcessExecutionException { int numElementsBefore = root.list().length; FileVersionSelectorListener versionSelectorListener = new FileVersionSelectorListener(file.toPath(), -1); try { client.getFileManager().createRecoverProcess(file, versionSelectorListener.getFileVersionSelector()).execute(); fail("Expected exception was not thrown."); } catch(ProcessExecutionException pex) { logger.info("Exception: {}", pex.getMessage()); } int numElementsAfter = root.list().length; assertEquals(numElementsBefore, numElementsAfter); }
@Test public void testCancelBeforeSelect() throws NoSessionException, NoPeerConnectionException, InvalidProcessStateException, ProcessExecutionException { FileVersionSelectorListener versionSelectorListener = new FileVersionSelectorListener(file.toPath(), 0); versionSelectorListener.getFileVersionSelector().cancel(); IProcessComponent<Void> p = client.getFileManager().createRecoverProcess(file, versionSelectorListener.getFileVersionSelector()); TestProcessComponentListener plistener = new TestProcessComponentListener(); p.attachListener(plistener); try { p.execute(); fail("Expected exception was not thrown."); } catch (ProcessExecutionException pex) { logger.info("Exception: {}", pex.getMessage()); } assertTrue(plistener.hasExecutionFailed()); assertFalse(plistener.hasExecutionSucceeded()); }