Skip to content

Commit 7f8f2fd

Browse files
committed
test: fix ErrorProne MissingFail warnings in unit tests
1 parent 75d3f3d commit 7f8f2fd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

core/src/test/java/io/grpc/internal/DelayedClientCallTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import io.grpc.Metadata;
3737
import io.grpc.Status;
3838
import io.grpc.StatusException;
39+
import static org.junit.Assert.assertThrows;
3940
import static org.junit.Assert.fail;
4041
import java.lang.reflect.Method;
4142
import java.lang.reflect.Modifier;
@@ -233,6 +234,7 @@ public void delayedCallsRunUnderContext() throws Exception {
233234
}
234235

235236
@Test
237+
@SuppressWarnings("MissingFail")
236238
public void drainPendingCallFails() {
237239
DelayedClientCall<String, Integer> delayedClientCall =
238240
new DelayedClientCall<>(callExecutor, fakeClock.getScheduledExecutorService(), null);
@@ -259,6 +261,7 @@ public Void answer(org.mockito.invocation.InvocationOnMock invocation) {
259261
}
260262

261263
@Test
264+
@SuppressWarnings("unchecked")
262265
public void drainPendingCallbacksFails() {
263266
DelayedClientCall<String, Integer> delayedClientCall =
264267
new DelayedClientCall<>(callExecutor, fakeClock.getScheduledExecutorService(), null);
@@ -303,6 +306,7 @@ public Void answer(org.mockito.invocation.InvocationOnMock invocation) {
303306
} catch (RuntimeException e) {
304307
assertThat(e).isSameInstanceAs(error);
305308
}
309+
306310
// Verify it was called twice (once during drain, once just now)
307311
verify(listener, times(2)).onReady();
308312
}

core/src/test/java/io/grpc/internal/DelayedStreamTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.junit.Assert.assertFalse;
2222
import static org.junit.Assert.assertNotNull;
2323
import static org.junit.Assert.assertNull;
24+
import static org.junit.Assert.assertThrows;
2425
import static org.junit.Assert.assertTrue;
2526
import static org.junit.Assert.fail;
2627
import static org.mockito.ArgumentMatchers.any;
@@ -474,6 +475,7 @@ public Void answer(InvocationOnMock in) {
474475
}
475476

476477
@Test
478+
@SuppressWarnings({"unchecked", "MissingFail"})
477479
public void drainPendingCallFails() {
478480
stream.start(listener);
479481
stream.request(1);
@@ -504,6 +506,7 @@ public Void answer(InvocationOnMock invocation) {
504506
}
505507

506508
@Test
509+
@SuppressWarnings("unchecked")
507510
public void drainPendingCallbacksFails() {
508511
stream.start(listener);
509512
final RuntimeException error = new RuntimeException("fail");
@@ -544,6 +547,7 @@ public Void answer(InvocationOnMock invocation) {
544547
} catch (RuntimeException e) {
545548
assertThat(e).isSameInstanceAs(error);
546549
}
550+
547551
// Verify it was called twice (once during drain, once just now)
548552
verify(listener, times(2)).onReady();
549553
}

0 commit comments

Comments
 (0)