Skip to content

Commit 66c5e9e

Browse files
committed
api: Revert CallOptionsTest refactor from this PR
1 parent d50f99a commit 66c5e9e

File tree

1 file changed

+17
-37
lines changed

1 file changed

+17
-37
lines changed

api/src/test/java/io/grpc/CallOptionsTest.java

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
import static org.junit.Assert.fail;
3030
import static org.mockito.Mockito.mock;
3131

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;
3533
import io.grpc.ClientStreamTracer.StreamInfo;
3634
import io.grpc.internal.SerializingExecutor;
3735
import java.time.Duration;
@@ -108,15 +106,17 @@ public void allWiths() {
108106

109107
@Test
110108
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,
117117
allSet.withCallCredentials(mock(CallCredentials.class))
118-
.withCallCredentials(sampleCreds))
119-
.isEquivalentTo(allSet);
118+
.withCallCredentials(sampleCreds)))
119+
.isTrue();
120120
}
121121

122122
@Test
@@ -265,32 +265,12 @@ public void getWaitForReady() {
265265
assertSame(CallOptions.DEFAULT.withoutWaitForReady().getWaitForReady(), Boolean.FALSE);
266266
}
267267

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());
294274
}
295275

296276
private static class FakeTicker extends Deadline.Ticker {

0 commit comments

Comments
 (0)