use of com.google.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method analyzeEntitySentimentExceptionTest.
@Test
@SuppressWarnings("all")
public void analyzeEntitySentimentExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.analyzeEntitySentiment(document, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.api.gax.grpc.ApiException 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 com.google.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class LanguageServiceClientTest method annotateTextExceptionTest.
@Test
@SuppressWarnings("all")
public void annotateTextExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLanguageService.addException(exception);
try {
Document document = Document.newBuilder().build();
AnnotateTextRequest.Features features = AnnotateTextRequest.Features.newBuilder().build();
EncodingType encodingType = EncodingType.NONE;
client.annotateText(document, features, encodingType);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class ErrorGroupServiceClientTest method updateGroupExceptionTest.
@Test
@SuppressWarnings("all")
public void updateGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorGroupService.addException(exception);
try {
ErrorGroup group = ErrorGroup.newBuilder().build();
client.updateGroup(group);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.api.gax.grpc.ApiException in project google-cloud-java by GoogleCloudPlatform.
the class ErrorGroupServiceClientTest method getGroupExceptionTest.
@Test
@SuppressWarnings("all")
public void getGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorGroupService.addException(exception);
try {
GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
client.getGroup(groupName);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations