Search in sources :

Example 6 with SystemTimeClock

use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.

the class ServerVersionInfoManagerTest method shouldBeAbleToUpdateTheLatestGOVersion.

@Test
public void shouldBeAbleToUpdateTheLatestGOVersion() {
    SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
    VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-1"), null);
    Date now = new Date();
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    when(systemTimeClock.currentTime()).thenReturn(now);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
    manager.initialize();
    VersionInfo info = manager.updateLatestVersion("15.0.1-123");
    assertThat(info.getLatestVersion().toString(), is("15.0.1-123"));
    assertThat(info.getLatestVersionUpdatedAt(), is(now));
    verify(versionInfoDao).saveOrUpdate(versionInfo);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Example 7 with SystemTimeClock

use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.

the class ServerVersionInfoManagerTest method shouldUpdateCacheWithNewVersionIfLatestVersionIsGreaterThanInstalledVersion.

@Test
public void shouldUpdateCacheWithNewVersionIfLatestVersionIsGreaterThanInstalledVersion() {
    SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
    VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("1.2.3-1"), null);
    Date now = new Date();
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    when(systemTimeClock.currentTime()).thenReturn(now);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
    manager.initialize();
    manager.updateLatestVersion("15.0.1-123");
    verify(goCache).put("GOUpdate", "15.0.1-123");
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Example 8 with SystemTimeClock

use of com.thoughtworks.go.util.SystemTimeClock in project gocd by gocd.

the class ServerVersionInfoManagerTest method shouldBeTrueIfVersionCheckEnabledOnProductionServer.

@Test
public void shouldBeTrueIfVersionCheckEnabledOnProductionServer() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
    when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(true);
    when(systemEnvironment.isProductionMode()).thenReturn(true);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
    manager.initialize();
    assertTrue(manager.isUpdateCheckEnabled());
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) Test(org.junit.Test)

Aggregations

SystemTimeClock (com.thoughtworks.go.util.SystemTimeClock)8 Test (org.junit.Test)8 VersionInfo (com.thoughtworks.go.domain.VersionInfo)6 GoVersion (com.thoughtworks.go.domain.GoVersion)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 Date (java.util.Date)3 CachedGoPartials (com.thoughtworks.go.config.CachedGoPartials)1 GoConfigMigration (com.thoughtworks.go.config.GoConfigMigration)1 GoCache (com.thoughtworks.go.server.cache.GoCache)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 InstanceFactory (com.thoughtworks.go.server.service.InstanceFactory)1 DateTime (org.joda.time.DateTime)1