use of com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest in project java-bigtable by googleapis.
the class BigtableTableAdminClientTest method testUpdateBackup.
@Test
public void testUpdateBackup() {
// Setup
Mockito.when(mockStub.updateBackupCallable()).thenReturn(mockUpdateBackupCallable);
Timestamp expireTime = Timestamp.newBuilder().setSeconds(123456789).build();
long sizeBytes = 12345L;
UpdateBackupRequest req = UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID);
Mockito.when(mockUpdateBackupCallable.futureCall(req.toProto(PROJECT_ID, INSTANCE_ID))).thenReturn(ApiFutures.immediateFuture(com.google.bigtable.admin.v2.Backup.newBuilder().setName(NameUtil.formatBackupName(PROJECT_ID, INSTANCE_ID, CLUSTER_ID, BACKUP_ID)).setSourceTable(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)).setExpireTime(expireTime).setSizeBytes(sizeBytes).build()));
// Execute
Backup actualResult = adminClient.updateBackup(req);
// Verify
assertThat(actualResult.getId()).isEqualTo(BACKUP_ID);
assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID);
assertThat(actualResult.getExpireTime()).isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime)));
assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes);
}
use of com.google.cloud.bigtable.admin.v2.models.UpdateBackupRequest in project java-bigtable by googleapis.
the class BigtableBackupIT method updateBackupTest.
@Test
public void updateBackupTest() {
String backupId = prefixGenerator.newPrefix();
tableAdmin.createBackup(createBackupRequest(backupId));
Instant expireTime = Instant.now().plus(Duration.ofDays(20));
UpdateBackupRequest req = UpdateBackupRequest.of(targetCluster, backupId).setExpireTime(expireTime);
try {
Backup backup = tableAdmin.updateBackup(req);
assertWithMessage("Incorrect expire time").that(backup.getExpireTime()).isEqualTo(expireTime);
} finally {
tableAdmin.deleteBackup(targetCluster, backupId);
}
}
Aggregations