use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSubscriptionsExceptionTest.
@Test
@SuppressWarnings("all")
public void listSubscriptionsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
ProjectName project = ProjectName.create("[PROJECT]");
client.listSubscriptions(project);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listTimeSeriesTest.
@Test
@SuppressWarnings("all")
public void listTimeSeriesTest() {
String nextPageToken = "";
TimeSeries timeSeriesElement = TimeSeries.newBuilder().build();
List<TimeSeries> timeSeries = Arrays.asList(timeSeriesElement);
ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken(nextPageToken).addAllTimeSeries(timeSeries).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
ListTimeSeriesPagedResponse pagedListResponse = client.listTimeSeries(name, filter, interval, view);
List<TimeSeries> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTimeSeriesList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTimeSeriesRequest actualRequest = (ListTimeSeriesRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertEquals(interval, actualRequest.getInterval());
Assert.assertEquals(view, actualRequest.getView());
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method deleteEventsExceptionTest.
@Test
@SuppressWarnings("all")
public void deleteEventsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorStatsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
client.deleteEvents(projectName);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method deleteEventsTest.
@Test
@SuppressWarnings("all")
public void deleteEventsTest() {
DeleteEventsResponse expectedResponse = DeleteEventsResponse.newBuilder().build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
DeleteEventsResponse actualResponse = client.deleteEvents(projectName);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteEventsRequest actualRequest = (DeleteEventsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
}
use of com.google.monitoring.v3.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listEventsExceptionTest.
@Test
@SuppressWarnings("all")
public void listEventsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorStatsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
String groupId = "groupId506361563";
client.listEvents(projectName, groupId);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations