Search in sources :

Example 1 with State

use of com.google.bigtable.admin.v2.Backup.State in project java-bigtable by googleapis.

the class BigtableTableAdminClientTest method testGetBackup.

@Test
public void testGetBackup() {
    // Setup
    Mockito.when(mockStub.getBackupCallable()).thenReturn(mockGetBackupCallable);
    Timestamp expireTime = Timestamp.newBuilder().setSeconds(123456789).build();
    Timestamp startTime = Timestamp.newBuilder().setSeconds(1234).build();
    Timestamp endTime = Timestamp.newBuilder().setSeconds(5678).build();
    com.google.bigtable.admin.v2.Backup.State state = State.CREATING;
    long sizeBytes = 12345L;
    GetBackupRequest testRequest = GetBackupRequest.newBuilder().setName(NameUtil.formatBackupName(PROJECT_ID, INSTANCE_ID, CLUSTER_ID, BACKUP_ID)).build();
    Mockito.when(mockGetBackupCallable.futureCall(testRequest)).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).setStartTime(startTime).setEndTime(endTime).setSizeBytes(sizeBytes).setState(state).build()));
    // Execute
    Backup actualResult = adminClient.getBackup(CLUSTER_ID, BACKUP_ID);
    // Verify
    assertThat(actualResult.getId()).isEqualTo(BACKUP_ID);
    assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID);
    assertThat(actualResult.getExpireTime()).isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime)));
    assertThat(actualResult.getStartTime()).isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(startTime)));
    assertThat(actualResult.getEndTime()).isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime)));
    assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes);
    assertThat(actualResult.getState()).isEqualTo(Backup.State.fromProto(state));
}
Also used : GetBackupRequest(com.google.bigtable.admin.v2.GetBackupRequest) Backup(com.google.cloud.bigtable.admin.v2.models.Backup) State(com.google.bigtable.admin.v2.Backup.State) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Aggregations

State (com.google.bigtable.admin.v2.Backup.State)1 GetBackupRequest (com.google.bigtable.admin.v2.GetBackupRequest)1 Backup (com.google.cloud.bigtable.admin.v2.models.Backup)1 Timestamp (com.google.protobuf.Timestamp)1 Test (org.junit.Test)1