Search in sources :

Example 1 with ServerBackupRepository

use of com.thoughtworks.go.server.persistence.ServerBackupRepository in project gocd by gocd.

the class BackupServiceTest method shouldReturnTheLatestBackupTime.

@Test
public void shouldReturnTheLatestBackupTime() {
    ServerBackupRepository repo = mock(ServerBackupRepository.class);
    Date serverBackupTime = new Date();
    when(repo.lastBackup()).thenReturn(new ServerBackup("file_path", serverBackupTime, "user"));
    BackupService backupService = new BackupService(null, null, mock(GoConfigService.class), null, repo, systemEnvironment, serverVersion, configRepo, databaseStrategy);
    backupService.initialize();
    Date date = backupService.lastBackupTime();
    assertThat(date, is(serverBackupTime));
}
Also used : ServerBackup(com.thoughtworks.go.server.domain.ServerBackup) Date(java.util.Date) ServerBackupRepository(com.thoughtworks.go.server.persistence.ServerBackupRepository) Test(org.junit.Test)

Example 2 with ServerBackupRepository

use of com.thoughtworks.go.server.persistence.ServerBackupRepository in project gocd by gocd.

the class BackupServiceTest method shouldReturnTheUserThatTriggeredTheLastBackup.

@Test
public void shouldReturnTheUserThatTriggeredTheLastBackup() {
    ServerBackupRepository repo = mock(ServerBackupRepository.class);
    when(repo.lastBackup()).thenReturn(new ServerBackup("file_path", new Date(), "loser"));
    BackupService backupService = new BackupService(null, null, mock(GoConfigService.class), null, repo, systemEnvironment, serverVersion, configRepo, databaseStrategy);
    backupService.initialize();
    String username = backupService.lastBackupUser();
    assertThat(username, is("loser"));
}
Also used : ServerBackup(com.thoughtworks.go.server.domain.ServerBackup) Date(java.util.Date) ServerBackupRepository(com.thoughtworks.go.server.persistence.ServerBackupRepository) Test(org.junit.Test)

Example 3 with ServerBackupRepository

use of com.thoughtworks.go.server.persistence.ServerBackupRepository in project gocd by gocd.

the class BackupServiceTest method shouldReturnNullWhenTheLatestBackupTimeIsNotAvailable.

@Test
public void shouldReturnNullWhenTheLatestBackupTimeIsNotAvailable() {
    ServerBackupRepository repo = mock(ServerBackupRepository.class);
    when(repo.lastBackup()).thenReturn(null);
    BackupService backupService = new BackupService(null, null, mock(GoConfigService.class), null, repo, systemEnvironment, serverVersion, configRepo, databaseStrategy);
    backupService.initialize();
    assertThat(backupService.lastBackupTime(), is(nullValue()));
}
Also used : ServerBackupRepository(com.thoughtworks.go.server.persistence.ServerBackupRepository) Test(org.junit.Test)

Example 4 with ServerBackupRepository

use of com.thoughtworks.go.server.persistence.ServerBackupRepository in project gocd by gocd.

the class BackupServiceTest method shouldReturnNullWhenTheLatestBackupUserIsNotAvailable.

@Test
public void shouldReturnNullWhenTheLatestBackupUserIsNotAvailable() {
    ServerBackupRepository repo = mock(ServerBackupRepository.class);
    when(repo.lastBackup()).thenReturn(null);
    BackupService backupService = new BackupService(null, null, mock(GoConfigService.class), null, repo, systemEnvironment, serverVersion, configRepo, databaseStrategy);
    backupService.initialize();
    assertThat(backupService.lastBackupUser(), is(nullValue()));
}
Also used : ServerBackupRepository(com.thoughtworks.go.server.persistence.ServerBackupRepository) Test(org.junit.Test)

Aggregations

ServerBackupRepository (com.thoughtworks.go.server.persistence.ServerBackupRepository)4 Test (org.junit.Test)4 ServerBackup (com.thoughtworks.go.server.domain.ServerBackup)2 Date (java.util.Date)2