Search in sources :

Example 11 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class ServerVersionInfoManagerTest method shouldAddNewVersionInfoToCacheIfLatestVersionIsGreaterThanInstalledVersion.

@Test
public void shouldAddNewVersionInfoToCacheIfLatestVersionIsGreaterThanInstalledVersion() {
    GoVersion currentVersion = new GoVersion("1.2.3-1");
    GoVersion latestVersion = new GoVersion("2.3.4-2");
    VersionInfo versionInfo = new VersionInfo("go_server", currentVersion, latestVersion, null);
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    manager.initialize();
    verify(builder).getServerVersionInfo();
    verify(goCache).put("GOUpdate", latestVersion.toString());
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Test(org.junit.Test)

Example 12 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class ServerVersionInfoBuilder method createVersionInfo.

private VersionInfo createVersionInfo() {
    VersionInfo versionInfo = null;
    GoVersion installedVersion = installedVersion();
    if (installedVersion == null)
        return versionInfo;
    versionInfo = new VersionInfo(GO_SERVER, installedVersion);
    versionInfoDao.saveOrUpdate(versionInfo);
    return versionInfo;
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion)

Example 13 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class VersionInfoSqlMapDaoIntegrationTest method shouldSaveVersionInfo.

@Test
public void shouldSaveVersionInfo() {
    GoVersion installedVersion = new GoVersion("14.1.0-123");
    GoVersion latestVersion = new GoVersion("15.1.0-876");
    Date now = new Date();
    VersionInfo versionInfo = new VersionInfo("GOServer", installedVersion, latestVersion, now);
    versionInfoSqlMapDao.saveOrUpdate(versionInfo);
    VersionInfo info = versionInfoSqlMapDao.findByComponentName(versionInfo.getComponentName());
    assertThat(info.getInstalledVersion().toString(), is(installedVersion.toString()));
    assertThat(info.getLatestVersion().toString(), is(latestVersion.toString()));
    assertThat(info.getLatestVersionUpdatedAt().compareTo(now), is(0));
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Example 14 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class VersionInfoServiceTest method shouldFetchVersionInfoWhichNeedsUpdate.

@Test
public void shouldFetchVersionInfoWhichNeedsUpdate() {
    ServerVersionInfoManager versionInfoManager = mock(ServerVersionInfoManager.class);
    VersionInfo versionInfo = mock(VersionInfo.class);
    when(versionInfoManager.versionInfoForUpdate()).thenReturn(versionInfo);
    when(versionInfoManager.isUpdateCheckEnabled()).thenReturn(true);
    VersionInfoService versionInfoService = new VersionInfoService(versionInfoManager);
    VersionInfo info = versionInfoService.getStaleVersionInfo();
    assertThat(info, is(versionInfo));
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) Test(org.junit.Test)

Example 15 with VersionInfo

use of com.thoughtworks.go.domain.VersionInfo in project gocd by gocd.

the class VersionInfoServiceTest method shouldReturnNullIfVersionUpdateIsDisabled.

@Test
public void shouldReturnNullIfVersionUpdateIsDisabled() {
    ServerVersionInfoManager versionInfoManager = mock(ServerVersionInfoManager.class);
    when(versionInfoManager.isUpdateCheckEnabled()).thenReturn(true);
    VersionInfoService versionInfoService = new VersionInfoService(versionInfoManager);
    VersionInfo info = versionInfoService.getStaleVersionInfo();
    assertNull(info);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) Test(org.junit.Test)

Aggregations

VersionInfo (com.thoughtworks.go.domain.VersionInfo)22 Test (org.junit.Test)21 GoVersion (com.thoughtworks.go.domain.GoVersion)14 Date (java.util.Date)8 SystemTimeClock (com.thoughtworks.go.util.SystemTimeClock)6 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 DateTime (org.joda.time.DateTime)1