Skip to content

Commit

Permalink
Use org.threeten.bp.Duration for ReadChangeStreamQuery::heartbeatDura…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Teng Zhong committed Feb 28, 2023
1 parent 9e11106 commit 4ada0af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public ReadChangeStreamQuery continuationTokens(
}

/** Sets the heartbeat duration for the change stream. */
public ReadChangeStreamQuery heartbeatDuration(java.time.Duration duration) {
public ReadChangeStreamQuery heartbeatDuration(org.threeten.bp.Duration duration) {
builder.setHeartbeatDuration(
Duration.newBuilder()
.setSeconds(duration.getSeconds())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ public void endTimeTest() {
@Test
public void heartbeatDurationTest() {
ReadChangeStreamQuery query =
ReadChangeStreamQuery.create(TABLE_ID).heartbeatDuration(java.time.Duration.ofSeconds(5));
ReadChangeStreamQuery.create(TABLE_ID)
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5));

Builder expectedProto =
expectedProtoBuilder()
.setHeartbeatDuration(com.google.protobuf.Duration.newBuilder().setSeconds(5).build());
expectedProtoBuilder().setHeartbeatDuration(Duration.newBuilder().setSeconds(5).build());

ReadChangeStreamRequest actualProto = query.toProto(requestContext);
assertThat(actualProto).isEqualTo(expectedProto.build());
Expand Down Expand Up @@ -232,7 +232,7 @@ public void serializationTest() throws IOException, ClassNotFoundException {
.streamPartition("simple-begin", "simple-end")
.continuationTokens(Collections.singletonList(token))
.endTime(FAKE_END_TIME)
.heartbeatDuration(java.time.Duration.ofSeconds(5));
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5));

ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
Expand Down Expand Up @@ -302,7 +302,7 @@ public void testEquality() {
.streamPartition("simple-begin", "simple-end")
.startTime(FAKE_START_TIME)
.endTime(FAKE_END_TIME)
.heartbeatDuration(java.time.Duration.ofSeconds(5));
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5));

// ReadChangeStreamQuery#toProto should not change the ReadChangeStreamQuery instance state
request.toProto(requestContext);
Expand All @@ -312,7 +312,7 @@ public void testEquality() {
.streamPartition("simple-begin", "simple-end")
.startTime(FAKE_START_TIME)
.endTime(FAKE_END_TIME)
.heartbeatDuration(java.time.Duration.ofSeconds(5)));
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5)));

assertThat(ReadChangeStreamQuery.create(TABLE_ID).streamPartition("begin-1", "end-1"))
.isNotEqualTo(ReadChangeStreamQuery.create(TABLE_ID).streamPartition("begin-2", "end-1"));
Expand All @@ -324,10 +324,10 @@ public void testEquality() {
ReadChangeStreamQuery.create(TABLE_ID).endTime(Instant.ofEpochSecond(1L, 1001L)));
assertThat(
ReadChangeStreamQuery.create(TABLE_ID)
.heartbeatDuration(java.time.Duration.ofSeconds(5)))
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5)))
.isNotEqualTo(
ReadChangeStreamQuery.create(TABLE_ID)
.heartbeatDuration(java.time.Duration.ofSeconds(6)));
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(6)));
}

@Test
Expand All @@ -350,7 +350,7 @@ public void testClone() {
.streamPartition("begin", "end")
.continuationTokens(Collections.singletonList(token))
.endTime(FAKE_END_TIME)
.heartbeatDuration(java.time.Duration.ofSeconds(5));
.heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5));
ReadChangeStreamRequest request =
ReadChangeStreamRequest.newBuilder()
.setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import com.google.cloud.bigtable.data.v2.models.ReadChangeStreamQuery;
import com.google.cloud.bigtable.gaxx.testing.FakeStreamingApi.ServerStreamingStashCallable;
import com.google.common.truth.Truth;
import java.time.Duration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.threeten.bp.Duration;
import org.threeten.bp.Instant;

@RunWith(JUnit4.class)
Expand Down

0 comments on commit 4ada0af

Please sign in to comment.