From 62dd45f574c6cf151b1678060188c84826f5a461 Mon Sep 17 00:00:00 2001 From: diegomarquezp Date: Thu, 14 Nov 2024 16:51:49 +0000 Subject: [PATCH] fix tests i --- .../cloud/bigtable/admin/v2/models/Backup.java | 4 +++- .../bigtable/admin/v2/models/CopyBackupRequest.java | 9 +++++++-- .../v2/models/DefaultChangeStreamRecordAdapter.java | 12 ++++++++++++ .../admin/v2/BigtableTableAdminClientTests.java | 6 +++++- .../v2/stub/EnhancedBigtableStubSettingsTest.java | 2 +- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java index b0f093c7d..5c0763eb9 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java @@ -176,7 +176,9 @@ public org.threeten.bp.Instant getExpireTime() { /** Get the expire time of this backup. */ public java.time.Instant getExpireTimeInstant() { - return java.time.Instant.ofEpochMilli(Timestamps.toMillis(proto.getExpireTime())); + // return java.time.Instant.ofEpochMilli(Timestamps.toMillis(proto.getExpireTime())); + return java.time.Instant.ofEpochSecond( + proto.getExpireTime().getSeconds(), proto.getExpireTime().getNanos()); } /** This method is obsolete. Use {@link #getStartTimeInstant()} instead. */ diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java index c42ec5ffa..5f4d71c96 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java @@ -22,7 +22,7 @@ import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.common.base.Objects; import com.google.common.base.Preconditions; -import com.google.protobuf.util.Timestamps; +import com.google.protobuf.Timestamp; import javax.annotation.Nonnull; /** Build CopyBackupRequest for {@link com.google.bigtable.admin.v2.CopyBackupRequest}. */ @@ -85,7 +85,12 @@ public CopyBackupRequest setExpireTime(org.threeten.bp.Instant expireTime) { public CopyBackupRequest setExpireTimeInstant(java.time.Instant expireTime) { Preconditions.checkNotNull(expireTime); - requestBuilder.setExpireTime(Timestamps.fromMillis(expireTime.toEpochMilli())); + Timestamp value = + Timestamp.newBuilder() + .setSeconds(expireTime.getEpochSecond()) + .setNanos(expireTime.getNano()) + .build(); + requestBuilder.setExpireTime(value); return this; } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java index b8ef0a3b1..884ae606c 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java @@ -99,6 +99,18 @@ public ChangeStreamRecord onCloseStream(ReadChangeStreamResponse.CloseStream clo return CloseStream.fromProto(closeStream); } + /** {@inheritDoc} */ + @Override + public void startUserMutationInstant( + @Nonnull ByteString rowKey, + @Nonnull String sourceClusterId, + java.time.Instant commitTimestamp, + int tieBreaker) { + this.changeStreamMutationBuilder = + ChangeStreamMutation.createUserMutation( + rowKey, sourceClusterId, commitTimestamp, tieBreaker); + } + /** {@inheritDoc} */ @Override public void startUserMutation( diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java index a24222764..0e9946dfb 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java @@ -1003,7 +1003,11 @@ public void testCopyBackup() { .setSourceBackup(srcBackupName) .setStartTime(startTime) .setEndTime(endTime) - .setExpireTime(Timestamps.fromMillis(expireTime.toEpochMilli())) + .setExpireTime( + Timestamp.newBuilder() + .setSeconds(expireTime.getEpochSecond()) + .setNanos(expireTime.getNano()) + .build()) .setSizeBytes(sizeBytes) .build(), CopyBackupMetadata.newBuilder() diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java index d50175f52..51790a73d 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java @@ -184,7 +184,7 @@ private void verifySettings( assertThat(settings.getEndpoint()).isEqualTo(endpoint); assertThat(settings.getCredentialsProvider()).isEqualTo(credentialsProvider); assertThat(settings.getStreamWatchdogProvider()).isSameInstanceAs(watchdogProvider); - assertThat(settings.getStreamWatchdogCheckInterval()).isEqualTo(watchdogInterval); + assertThat(settings.getStreamWatchdogCheckIntervalDuration()).isEqualTo(watchdogInterval); assertThat(settings.getEnableRoutingCookie()).isEqualTo(enableRoutingCookie); assertThat(settings.getEnableRetryInfo()).isEqualTo(enableRetryInfo); assertThat(settings.getMetricsEndpoint()).isEqualTo(metricsEndpoint);