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));
}
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"));
}
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()));
}
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()));
}
Aggregations