Search in sources :

Example 6 with VersionInfo

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

the class ServerVersionInfoManagerTest method shouldBeFalseIfVersionCheckIsDisabled.

@Test
public void shouldBeFalseIfVersionCheckIsDisabled() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
    when(systemEnvironment.isProductionMode()).thenReturn(true);
    when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(false);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
    manager.initialize();
    assertFalse(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)

Example 7 with VersionInfo

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

the class ServerVersionInfoManagerTest method shouldUseServerVersionInfoBuilderToGetServerVersionInfo.

@Test
public void shouldUseServerVersionInfoBuilderToGetServerVersionInfo() {
    when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
    manager.initialize();
    verify(builder).getServerVersionInfo();
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) Test(org.junit.Test)

Example 8 with VersionInfo

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

the class ServerVersionInfoManagerTest method shouldNotGetVersionInfoIfLatestVersionIsBeingUpdated.

@Test
public void shouldNotGetVersionInfoIfLatestVersionIsBeingUpdated() {
    Date yesterday = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);
    VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-2"), yesterday);
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    manager.initialize();
    VersionInfo serverVersionInfo1 = manager.versionInfoForUpdate();
    VersionInfo serverVersionInfo2 = manager.versionInfoForUpdate();
    assertNotNull(serverVersionInfo1);
    assertNull(serverVersionInfo2);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) Test(org.junit.Test)

Example 9 with VersionInfo

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

the class ServerVersionInfoManagerTest method shouldGetVersionInfoIflatestVersionIsBeingUpdatedForMoreThanHalfAnHour.

@Test
public void shouldGetVersionInfoIflatestVersionIsBeingUpdatedForMoreThanHalfAnHour() {
    SystemTimeClock systemTimeClock = mock(SystemTimeClock.class);
    Date yesterday = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);
    DateTime halfAnHourFromNow = new DateTime(System.currentTimeMillis() - 35 * 60 * 1000);
    VersionInfo versionInfo = new VersionInfo("go_server", new GoVersion("1.2.3-1"), new GoVersion("2.3.4-2"), yesterday);
    when(builder.getServerVersionInfo()).thenReturn(versionInfo);
    when(systemTimeClock.currentDateTime()).thenReturn(halfAnHourFromNow);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, systemTimeClock, goCache, systemEnvironment);
    manager.initialize();
    VersionInfo serverVersionInfo1 = manager.versionInfoForUpdate();
    VersionInfo serverVersionInfo2 = manager.versionInfoForUpdate();
    assertNotNull(serverVersionInfo1);
    assertNotNull(serverVersionInfo2);
}
Also used : VersionInfo(com.thoughtworks.go.domain.VersionInfo) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) GoVersion(com.thoughtworks.go.domain.GoVersion) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 10 with VersionInfo

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

the class ServerVersionInfoManagerTest method updateCheckShouldBeDisabledForADevelopmentServer.

@Test
public void updateCheckShouldBeDisabledForADevelopmentServer() {
    SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
    when(builder.getServerVersionInfo()).thenReturn(new VersionInfo());
    when(systemEnvironment.isProductionMode()).thenReturn(false);
    when(systemEnvironment.isGOUpdateCheckEnabled()).thenReturn(true);
    manager = new ServerVersionInfoManager(builder, versionInfoDao, new SystemTimeClock(), goCache, systemEnvironment);
    manager.initialize();
    assertFalse(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

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