use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listGroupStatsExceptionTest.
@Test
@SuppressWarnings("all")
public void listGroupStatsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorStatsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
client.listGroupStats(projectName, timeRange);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listEventsTest.
@Test
@SuppressWarnings("all")
public void listEventsTest() {
String nextPageToken = "";
ErrorEvent errorEventsElement = ErrorEvent.newBuilder().build();
List<ErrorEvent> errorEvents = Arrays.asList(errorEventsElement);
ListEventsResponse expectedResponse = ListEventsResponse.newBuilder().setNextPageToken(nextPageToken).addAllErrorEvents(errorEvents).build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
String groupId = "groupId506361563";
ListEventsPagedResponse pagedListResponse = client.listEvents(projectName, groupId);
List<ErrorEvent> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getErrorEventsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEventsRequest actualRequest = (ListEventsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
Assert.assertEquals(groupId, actualRequest.getGroupId());
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSnapshotsExceptionTest.
@Test
@SuppressWarnings("all")
public void listSnapshotsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
ProjectName project = ProjectName.create("[PROJECT]");
client.listSnapshots(project);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method createTimeSeriesExceptionTest.
@Test
@SuppressWarnings("all")
public void createTimeSeriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
List<TimeSeries> timeSeries = new ArrayList<>();
client.createTimeSeries(name, timeSeries);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.bigtable.admin.v2.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listMonitoredResourceDescriptorsExceptionTest.
@Test
@SuppressWarnings("all")
public void listMonitoredResourceDescriptorsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
client.listMonitoredResourceDescriptors(name);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations