|
18 | 18 |
|
19 | 19 | import static com.google.common.truth.Truth.assertThat; |
20 | 20 | import static org.junit.Assert.fail; |
| 21 | +import static org.mockito.Mockito.mock; |
| 22 | +import static org.mockito.Mockito.never; |
| 23 | +import static org.mockito.Mockito.verify; |
21 | 24 |
|
22 | 25 | import com.google.common.collect.ImmutableList; |
23 | 26 | import com.google.common.collect.ImmutableMap; |
|
69 | 72 | import org.junit.experimental.runners.Enclosed; |
70 | 73 | import org.junit.runner.RunWith; |
71 | 74 | import org.junit.runners.JUnit4; |
| 75 | +import org.mockito.ArgumentCaptor; |
72 | 76 |
|
73 | 77 | /** Unit tests for {@link CsdsService}. */ |
74 | 78 | @RunWith(Enclosed.class) |
@@ -133,6 +137,19 @@ public void fetchClientConfig_invalidArgument() { |
133 | 137 | } |
134 | 138 | } |
135 | 139 |
|
| 140 | + @Test |
| 141 | + @SuppressWarnings("unchecked") |
| 142 | + public void fetchClientConfig_errorDoesNotComplete() { |
| 143 | + StreamObserver<ClientStatusResponse> responseObserver = mock(StreamObserver.class); |
| 144 | + |
| 145 | + CSDS_SERVICE_MINIMAL.delegate.fetchClientStatus(REQUEST_INVALID, responseObserver); |
| 146 | + |
| 147 | + ArgumentCaptor<Throwable> error = ArgumentCaptor.forClass(Throwable.class); |
| 148 | + verify(responseObserver).onError(error.capture()); |
| 149 | + assertThat(Status.fromThrowable(error.getValue()).getCode()).isEqualTo(Code.INVALID_ARGUMENT); |
| 150 | + verify(responseObserver, never()).onCompleted(); |
| 151 | + } |
| 152 | + |
136 | 153 | /** Unexpected exceptions translated to Status.Code.INTERNAL. */ |
137 | 154 | @Test |
138 | 155 | public void fetchClientConfig_unexpectedException() { |
|
0 commit comments