use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SpannerExceptionFactoryTest method abortWithoutRetryInfo.
@Test
public void abortWithoutRetryInfo() {
Status status = Status.fromCodeValue(Status.Code.ABORTED.value());
SpannerException e = SpannerExceptionFactory.newSpannerException(new StatusRuntimeException(status));
assertThat(e).isInstanceOf(AbortedException.class);
assertThat(((AbortedException) e).getRetryDelayInMillis()).isEqualTo(-1L);
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class VideoIntelligenceServiceClientTest method annotateVideoExceptionTest.
@Test
@SuppressWarnings("all")
public void annotateVideoExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockVideoIntelligenceService.addException(exception);
try {
String inputUri = "inputUri1707300727";
List<Feature> features = new ArrayList<>();
VideoContext videoContext = VideoContext.newBuilder().build();
String outputUri = "outputUri-1273518802";
String locationId = "locationId552319461";
client.annotateVideoAsync(inputUri, features, videoContext, outputUri, locationId).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(ApiException.class, e.getCause().getClass());
ApiException apiException = (ApiException) e.getCause();
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), apiException.getStatusCode());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class ReportErrorsServiceClientTest method reportErrorEventExceptionTest.
@Test
@SuppressWarnings("all")
public void reportErrorEventExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockReportErrorsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
ReportedErrorEvent event = ReportedErrorEvent.newBuilder().build();
client.reportErrorEvent(projectName, event);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method deleteGroupExceptionTest.
@Test
@SuppressWarnings("all")
public void deleteGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
client.deleteGroup(name);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method listGroupMembersExceptionTest.
@Test
@SuppressWarnings("all")
public void listGroupMembersExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
client.listGroupMembers(name);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations