### Question:
FileVersionSelector implements IVersionSelector { public void selectVersion(IFileVersion selectedVersion, Path fileToRecover) { this.fileToRecover = fileToRecover; try { if(hasSelected.get()) { throw new IllegalStateException("Calling selectVersion multiple times is not allowed."); } hasSelected.set(true); if(!gotAvailableVersions.get()) { throw new IllegalStateException("Cannot select version before retrieving available versions."); } if(selectedVersion == null) { cancel(); } this.selectedVersion = selectedVersion; } finally { 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(expected=IllegalStateException.class) public void testSelectBeforeOnAvailableVersions() { FileVersionSelectorListener versionSelectorListener = new FileVersionSelectorListener(file.toPath(), 0); versionSelectorListener.getFileVersionSelector().selectVersion((IFileVersion)null, file.toPath()); }
@Test(expected=IllegalStateException.class) public void testSelectTwice() throws FileNotFoundException, NoSessionException, NoPeerConnectionException, InterruptedException, InvalidProcessStateException { FileVersionSelectorListener versionSelectorListener = new FileVersionSelectorListener(file.toPath(), 0); List<IFileVersion> versions = new ArrayList<IFileVersion>(); for(int i = 0; i < NUM_VERSIONS; ++i) { versions.add(null); } versionSelectorListener.getFileVersionSelector().selectVersion(versions); versionSelectorListener.getFileVersionSelector().selectVersion((IFileVersion)null, file.toPath()); }