use of com.google.spanner.admin.instance.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listTimeSeriesExceptionTest.
@Test
@SuppressWarnings("all")
public void listTimeSeriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
client.listTimeSeries(name, filter, interval, view);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.spanner.admin.instance.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method createMetricDescriptorTest.
@Test
@SuppressWarnings("all")
public void createMetricDescriptorTest() {
String name2 = "name2-1052831874";
String type = "type3575610";
String unit = "unit3594628";
String description = "description-1724546052";
String displayName = "displayName1615086568";
MetricDescriptor expectedResponse = MetricDescriptor.newBuilder().setName(name2).setType(type).setUnit(unit).setDescription(description).setDisplayName(displayName).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
MetricDescriptor actualResponse = client.createMetricDescriptor(name, metricDescriptor);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateMetricDescriptorRequest actualRequest = (CreateMetricDescriptorRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(metricDescriptor, actualRequest.getMetricDescriptor());
}
use of com.google.spanner.admin.instance.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSubscriptionsTest.
@Test
@SuppressWarnings("all")
public void listSubscriptionsTest() {
String nextPageToken = "";
Subscription subscriptionsElement = Subscription.newBuilder().build();
List<Subscription> subscriptions = Arrays.asList(subscriptionsElement);
ListSubscriptionsResponse expectedResponse = ListSubscriptionsResponse.newBuilder().setNextPageToken(nextPageToken).addAllSubscriptions(subscriptions).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.create("[PROJECT]");
ListSubscriptionsPagedResponse pagedListResponse = client.listSubscriptions(project);
List<Subscription> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSubscriptionsRequest actualRequest = (ListSubscriptionsRequest) actualRequests.get(0);
Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
use of com.google.spanner.admin.instance.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GrpcSpannerRpc method listInstances.
@Override
public Paginated<Instance> listInstances(int pageSize, @Nullable String pageToken, @Nullable String filter) throws SpannerException {
ListInstancesRequest.Builder request = ListInstancesRequest.newBuilder().setParent(projectName()).setPageSize(pageSize);
if (pageToken != null) {
request.setPageToken(pageToken);
}
if (filter != null) {
request.setFilter(filter);
}
ListInstancesResponse response = get(doUnaryCall(InstanceAdminGrpc.METHOD_LIST_INSTANCES, request.build(), projectName(), null));
return new Paginated<>(response.getInstancesList(), response.getNextPageToken());
}
use of com.google.spanner.admin.instance.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GrpcSpannerRpc method listInstanceConfigs.
@Override
public Paginated<InstanceConfig> listInstanceConfigs(int pageSize, @Nullable String pageToken) throws SpannerException {
ListInstanceConfigsRequest.Builder request = ListInstanceConfigsRequest.newBuilder().setParent(projectName()).setPageSize(0);
if (pageToken != null) {
request.setPageToken(pageToken);
}
ListInstanceConfigsResponse response = get(doUnaryCall(InstanceAdminGrpc.METHOD_LIST_INSTANCE_CONFIGS, request.build(), projectName(), null));
return new Paginated<>(response.getInstanceConfigsList(), response.getNextPageToken());
}
Aggregations