private long latestEdition;
/** The current latest known version. */
- private Version currentLatestVersion = SonePlugin.VERSION;
+ private Version currentLatestVersion;
+ private final Version currentRunningVersion;
/** The release date of the latest version. */
private long latestVersionDate;
* The freenet interface to use
*/
@Inject
- public UpdateChecker(EventBus eventBus, FreenetInterface freenetInterface) {
+ public UpdateChecker(EventBus eventBus, FreenetInterface freenetInterface, Version currentVersion) {
this.eventBus = eventBus;
this.freenetInterface = freenetInterface;
+ this.currentRunningVersion = currentVersion;
+ this.currentLatestVersion = currentVersion;
}
//
* @return {@code true} if a new version was found
*/
public boolean hasLatestVersion() {
- return currentLatestVersion.compareTo(SonePlugin.VERSION) > 0;
+ return currentLatestVersion.compareTo(currentRunningVersion) > 0;
}
/**
bind(Context.class).toInstance(context);
bind(getOptionalContextTypeLiteral()).toInstance(of(context));
bind(SonePlugin.class).toInstance(SonePlugin.this);
+ bind(Version.class).toInstance(VERSION);
if (startConfiguration.getBooleanValue("Developer.LoadFromFilesystem").getValue(false)) {
String path = startConfiguration.getStringValue("Developer.FilesystemPath").getValue(null);
if (path != null) {
private final EventBus eventBus = mock(EventBus.class);
private final FreenetInterface freenetInterface = mock(FreenetInterface.class);
- private final UpdateChecker updateChecker = new UpdateChecker(eventBus, freenetInterface);
+ private final Version currentVersion = new Version(1, 0, 0);
+ private final UpdateChecker updateChecker = new UpdateChecker(eventBus, freenetInterface, currentVersion);
@Before
public void startUpdateChecker() {
@Test
public void newUpdateCheckerDoesNotHaveALatestVersion() {
assertThat(updateChecker.hasLatestVersion(), is(false));
- assertThat(updateChecker.getLatestVersion(), is(VERSION));
+ assertThat(updateChecker.getLatestVersion(), is(currentVersion));
}
@Test