use of com.google.api.gax.rpc.testing.FakeApiException in project java-bigtable by googleapis.
the class AwaitReplicationCallableTest method testGenerateFailure.
@Test
public void testGenerateFailure() throws Exception {
GenerateConsistencyTokenRequest expectedRequest = GenerateConsistencyTokenRequest.newBuilder().setName(TABLE_NAME.toString()).build();
FakeApiException fakeError = new FakeApiException("fake", null, Code.INTERNAL, false);
Mockito.when(mockGenerateConsistencyTokenCallable.futureCall(expectedRequest, CALL_CONTEXT)).thenReturn(ApiFutures.<GenerateConsistencyTokenResponse>immediateFailedFuture(fakeError));
ApiFuture<Void> future = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
Throwable actualError = null;
try {
future.get();
} catch (ExecutionException e) {
actualError = e.getCause();
}
assertThat(actualError).isSameInstanceAs(fakeError);
}
use of com.google.api.gax.rpc.testing.FakeApiException in project java-bigtable by googleapis.
the class AwaitReplicationCallableTest method testCheckFailure.
@Test
public void testCheckFailure() throws Exception {
GenerateConsistencyTokenRequest expectedRequest = GenerateConsistencyTokenRequest.newBuilder().setName(TABLE_NAME.toString()).build();
GenerateConsistencyTokenResponse expectedResponse = GenerateConsistencyTokenResponse.newBuilder().setConsistencyToken("fake-token").build();
Mockito.when(mockGenerateConsistencyTokenCallable.futureCall(expectedRequest, CALL_CONTEXT)).thenReturn(ApiFutures.immediateFuture(expectedResponse));
CheckConsistencyRequest expectedRequest2 = CheckConsistencyRequest.newBuilder().setName(TABLE_NAME.toString()).setConsistencyToken("fake-token").build();
FakeApiException expectedError = new FakeApiException("fake", null, Code.INTERNAL, false);
Mockito.when(mockCheckConsistencyCallable.futureCall(expectedRequest2, CALL_CONTEXT)).thenReturn(ApiFutures.<CheckConsistencyResponse>immediateFailedFuture(expectedError));
ApiFuture<Void> future = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
Throwable actualError = null;
try {
future.get();
} catch (ExecutionException e) {
actualError = e.getCause();
}
assertThat(actualError).isSameInstanceAs(expectedError);
}
Aggregations