|
29 | 29 | import static org.junit.Assert.fail; |
30 | 30 | import static org.mockito.Mockito.mock; |
31 | 31 |
|
32 | | -import com.google.common.truth.Fact; |
33 | | -import com.google.common.truth.FailureMetadata; |
34 | | -import com.google.common.truth.Subject; |
| 32 | +import com.google.common.base.Objects; |
35 | 33 | import io.grpc.ClientStreamTracer.StreamInfo; |
36 | 34 | import io.grpc.internal.SerializingExecutor; |
37 | 35 | import java.time.Duration; |
@@ -108,15 +106,17 @@ public void allWiths() { |
108 | 106 |
|
109 | 107 | @Test |
110 | 108 | public void noStrayModifications() { |
111 | | - assertAbout(callOptions()).that(allSet.withAuthority("blah").withAuthority(sampleAuthority)) |
112 | | - .isEquivalentTo(allSet); |
113 | | - assertAbout(callOptions()).that( |
114 | | - allSet.withDeadline(Deadline.after(314, NANOSECONDS)).withDeadline(sampleDeadline)) |
115 | | - .isEquivalentTo(allSet); |
116 | | - assertAbout(callOptions()).that( |
| 109 | + assertThat(equal(allSet, allSet.withAuthority("blah").withAuthority(sampleAuthority))) |
| 110 | + .isTrue(); |
| 111 | + assertThat( |
| 112 | + equal(allSet, |
| 113 | + allSet.withDeadline(Deadline.after(314, NANOSECONDS)).withDeadline(sampleDeadline))) |
| 114 | + .isTrue(); |
| 115 | + assertThat( |
| 116 | + equal(allSet, |
117 | 117 | allSet.withCallCredentials(mock(CallCredentials.class)) |
118 | | - .withCallCredentials(sampleCreds)) |
119 | | - .isEquivalentTo(allSet); |
| 118 | + .withCallCredentials(sampleCreds))) |
| 119 | + .isTrue(); |
120 | 120 | } |
121 | 121 |
|
122 | 122 | @Test |
@@ -265,32 +265,12 @@ public void getWaitForReady() { |
265 | 265 | assertSame(CallOptions.DEFAULT.withoutWaitForReady().getWaitForReady(), Boolean.FALSE); |
266 | 266 | } |
267 | 267 |
|
268 | | - private static Subject.Factory<CallOptionsSubject, CallOptions> callOptions() { |
269 | | - return CallOptionsSubject::new; |
270 | | - } |
271 | | - |
272 | | - private static final class CallOptionsSubject extends Subject { |
273 | | - |
274 | | - private final CallOptions actual; |
275 | | - |
276 | | - private CallOptionsSubject(FailureMetadata metadata, CallOptions actual) { |
277 | | - super(metadata, actual); |
278 | | - this.actual = actual; |
279 | | - } |
280 | | - |
281 | | - public void isEquivalentTo(CallOptions expected) { |
282 | | - if (actual == null) { |
283 | | - failWithActual("expected", expected); |
284 | | - return; |
285 | | - } |
286 | | - if (expected == null) { |
287 | | - failWithoutActual(Fact.simpleFact("expected non-null CallOptions")); |
288 | | - return; |
289 | | - } |
290 | | - check("deadline").that(actual.getDeadline()).isEqualTo(expected.getDeadline()); |
291 | | - check("authority").that(actual.getAuthority()).isEqualTo(expected.getAuthority()); |
292 | | - check("credentials").that(actual.getCredentials()).isEqualTo(expected.getCredentials()); |
293 | | - } |
| 268 | + // Only used in noStrayModifications() |
| 269 | + // TODO(carl-mastrangelo): consider making a CallOptionsSubject for Truth. |
| 270 | + private static boolean equal(CallOptions o1, CallOptions o2) { |
| 271 | + return Objects.equal(o1.getDeadline(), o2.getDeadline()) |
| 272 | + && Objects.equal(o1.getAuthority(), o2.getAuthority()) |
| 273 | + && Objects.equal(o1.getCredentials(), o2.getCredentials()); |
294 | 274 | } |
295 | 275 |
|
296 | 276 | private static class FakeTicker extends Deadline.Ticker { |
|
0 commit comments