use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeEntitiesExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeEntitiesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.analyzeEntities(document, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeSyntaxExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeSyntaxExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.analyzeSyntax(document, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeSentimentExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeSentimentExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
client.analyzeSentiment(document);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class TransactionRunnerImplTest method runAbortNoRetryInfo.
@Test
public void runAbortNoRetryInfo() {
runTransaction(new StatusRuntimeException(Status.fromCodeValue(Status.Code.ABORTED.value())));
ArgumentCaptor<Long> backoffMillis = ArgumentCaptor.forClass(Long.class);
verify(sleeper, times(1)).backoffSleep(Mockito.<Context>any(), backoffMillis.capture());
assertThat(backoffMillis.getValue()).isGreaterThan(0L);
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SpannerExceptionFactoryTest method connectionClosedIsRetryable.
@Test
public void connectionClosedIsRetryable() {
Status status = Status.fromCodeValue(Status.Code.INTERNAL.value()).withDescription("Connection closed with unknown cause");
SpannerException e = SpannerExceptionFactory.newSpannerException(new StatusRuntimeException(status));
assertThat(e.isRetryable()).isTrue();
}
Aggregations