use of com.google.devtools.clouderrorreporting.v1beta1.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.devtools.clouderrorreporting.v1beta1.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());
}
}
use of com.google.devtools.clouderrorreporting.v1beta1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSnapshotsTest.
@Test
@SuppressWarnings("all")
public void listSnapshotsTest() {
String nextPageToken = "";
Snapshot snapshotsElement = Snapshot.newBuilder().build();
List<Snapshot> snapshots = Arrays.asList(snapshotsElement);
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken(nextPageToken).addAllSnapshots(snapshots).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.create("[PROJECT]");
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = (ListSnapshotsRequest) actualRequests.get(0);
Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
use of com.google.devtools.clouderrorreporting.v1beta1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method listTopicsTest.
@Test
@SuppressWarnings("all")
public void listTopicsTest() {
String nextPageToken = "";
Topic topicsElement = Topic.newBuilder().build();
List<Topic> topics = Arrays.asList(topicsElement);
ListTopicsResponse expectedResponse = ListTopicsResponse.newBuilder().setNextPageToken(nextPageToken).addAllTopics(topics).build();
mockPublisher.addResponse(expectedResponse);
ProjectName project = ProjectName.create("[PROJECT]");
ListTopicsPagedResponse pagedListResponse = client.listTopics(project);
List<Topic> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTopicsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockPublisher.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTopicsRequest actualRequest = (ListTopicsRequest) actualRequests.get(0);
Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
use of com.google.devtools.clouderrorreporting.v1beta1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method listTopicsExceptionTest.
@Test
@SuppressWarnings("all")
public void listTopicsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockPublisher.addException(exception);
try {
ProjectName project = ProjectName.create("[PROJECT]");
client.listTopics(project);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations