File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
package com.google.cloud.spanner;
1818

19-
import static org.hamcrest.CoreMatchers.equalTo;
20-
import static org.hamcrest.CoreMatchers.is;
21-
import static org.hamcrest.MatcherAssert.assertThat;
19+
import static com.google.common.truth.Truth.assertThat;
2220
import static org.junit.Assert.fail;
2321

2422
import com.google.common.base.Stopwatch;
@@ -125,7 +123,7 @@ public Integer call() throws Exception {
125123
return 1 + 1;
126124
}
127125
};
128-
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable), is(equalTo(2)));
126+
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable)).isEqualTo(2);
129127
}
130128

131129
@Test(expected = IllegalStateException.class)
@@ -153,7 +151,7 @@ public Integer call() throws Exception {
153151
return 1 + 1;
154152
}
155153
};
156-
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable), is(equalTo(2)));
154+
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable)).isEqualTo(2);
157155
}
158156

159157
@Test
@@ -169,7 +167,7 @@ public Integer call() throws Exception {
169167
return 1 + 1;
170168
}
171169
};
172-
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable), is(equalTo(2)));
170+
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable)).isEqualTo(2);
173171
}
174172

175173
@Test(expected = IllegalStateException.class)
@@ -190,12 +188,13 @@ public Integer call() throws Exception {
190188

191189
@Test
192190
public void testExceptionWithRetryInfo() {
191+
final int RETRY_DELAY_NANOS = 100_000_000;
193192
Metadata.Key<RetryInfo> key = ProtoUtils.keyForProto(RetryInfo.getDefaultInstance());
194193
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
195194
Metadata trailers = new Metadata();
196195
RetryInfo retryInfo =
197196
RetryInfo.newBuilder()
198-
.setRetryDelay(Duration.newBuilder().setNanos(100000000).build())
197+
.setRetryDelay(Duration.newBuilder().setNanos(RETRY_DELAY_NANOS).build())
199198
.build();
200199
trailers.put(key, retryInfo);
201200
final SpannerException e =
@@ -214,9 +213,9 @@ public Integer call() throws Exception {
214213
// The following call should take at least 100ms, as that is the retry delay specified in the
215214
// retry info of the exception.
216215
Stopwatch watch = Stopwatch.createStarted();
217-
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable), is(equalTo(2)));
218-
long elapsed = watch.elapsed(TimeUnit.MILLISECONDS);
219-
assertThat(elapsed >= 100L, is(true));
216+
assertThat(SpannerRetryHelper.runTxWithRetriesOnAborted(callable)).isEqualTo(2);
217+
long elapsed = watch.elapsed(TimeUnit.NANOSECONDS);
218+
assertThat(elapsed >= RETRY_DELAY_NANOS).isTrue();
220219
}
221220

222221
private SpannerException abortedWithRetryInfo(int nanos) {

0 commit comments

Comments
 (0)