Search in sources :

Example 11 with GoVersion

use of com.thoughtworks.go.domain.GoVersion 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 12 with GoVersion

use of com.thoughtworks.go.domain.GoVersion 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 13 with GoVersion

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

the class ServerVersionInfoBuilderTest method shouldGetVersionInfoForGOServerIfExists.

@Test
public void shouldGetVersionInfoForGOServerIfExists() {
    VersionInfo goVersionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"));
    when(versionInfoDao.findByComponentName("go_server")).thenReturn(goVersionInfo);
    when(serverVersion.version()).thenReturn("1.2.3-1");
    VersionInfo versionInfo = builder.getServerVersionInfo();
    assertThat(versionInfo.getComponentName(), is(goVersionInfo.getComponentName()));
    assertThat(versionInfo.getInstalledVersion(), is(goVersionInfo.getInstalledVersion()));
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Test(org.junit.Test)

Example 14 with GoVersion

use of com.thoughtworks.go.domain.GoVersion 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 15 with GoVersion

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

the class ServerVersionInfoManagerTest method shouldNotReturnVersionInfoIfLatestVersionUpdatedToday.

@Test
public void shouldNotReturnVersionInfoIfLatestVersionUpdatedToday() {
    Date today = new Date();
    VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-2"), today);
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    manager.initialize();
    VersionInfo serverVersionInfo = manager.versionInfoForUpdate();
    assertNull(serverVersionInfo);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Aggregations

GoVersion (com.thoughtworks.go.domain.GoVersion)17 VersionInfo (com.thoughtworks.go.domain.VersionInfo)14 Test (org.junit.Test)13 Date (java.util.Date)9 SystemTimeClock (com.thoughtworks.go.util.SystemTimeClock)3 VersionFormatException (com.thoughtworks.go.domain.exception.VersionFormatException)1 DateTime (org.joda.time.DateTime)1