VersionRecordManager { public void onVersionSelectedEvent(final @Observes VersionSelectedEvent event) { if (event.getPathToFile().equals(getPathToLatest()) && selectionCallback != null) { selectionCallback.callback(event.getVersionRecord()); } } @Inject  VersionRecordManager(final VersionMenuDropDownButton versionMenuDropDownButton,
                                final SaveButton saveButton,
                                final RestorePopUpPresenter restorePopUpPresenter,
                                final RestoreUtil restoreUtil,
                                final Event<VersionSelectedEvent> versionSelectedEvent,
                                final Caller<VersionService> versionService,
                                @Customizable final CurrentBranch currentBranch); void init(final String version,
                     final ObservablePath path,
                     final Callback<VersionRecord> selectionCallback); MenuItem buildMenu(); void setVersions(final List<VersionRecord> versions); void setShowMoreCommand(final Command showMore); MenuItem newSaveMenuItem(final Command command); MenuItem newSaveMenuItem(final ParameterizedCommand<Boolean> command); boolean isLatest(final VersionRecord versionRecord); ObservablePath getPathToLatest(); void onVersionSelectedEvent(final @Observes VersionSelectedEvent event); String getVersion(); void setVersion(final String version); ObservablePath getCurrentPath(); boolean isCurrentLatest(); void restoreToCurrentVersion(boolean withComments); void reloadVersions(final Path path); void clear();  }
@Test public void saveButtonLabelChangeTest() throws Exception { verify(saveButton, times(1)).setTextToSave(); manager.onVersionSelectedEvent(new VersionSelectedEvent(pathTo333, getVersionRecord("111"))); verify(saveButton, times(1)).setTextToRestore(); manager.onVersionSelectedEvent(new VersionSelectedEvent(pathTo333, getVersionRecord("333"))); verify(saveButton, times(2)).setTextToSave(); manager.onVersionSelectedEvent(new VersionSelectedEvent(pathTo333, getVersionRecord("222"))); verify(saveButton, times(2)).setTextToRestore(); }