use of com.google.api.ads.admanager.axis.v202205.TimeSeries in project java-monitoring by googleapis.
the class MetricServiceClientTest method createServiceTimeSeriesExceptionTest2.
@Test
public void createServiceTimeSeriesExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
String name = "name3373707";
List<TimeSeries> timeSeries = new ArrayList<>();
client.createServiceTimeSeries(name, timeSeries);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.api.ads.admanager.axis.v202205.TimeSeries in project java-monitoring by googleapis.
the class MetricServiceClientTest method listTimeSeriesTest2.
@Test
public void listTimeSeriesTest2() throws Exception {
TimeSeries responsesElement = TimeSeries.newBuilder().build();
ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken("").addAllTimeSeries(Arrays.asList(responsesElement)).build();
mockMetricService.addResponse(expectedResponse);
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
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<AbstractMessage> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTimeSeriesRequest actualRequest = ((ListTimeSeriesRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertEquals(interval, actualRequest.getInterval());
Assert.assertEquals(view, actualRequest.getView());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.api.ads.admanager.axis.v202205.TimeSeries in project java-monitoring by googleapis.
the class MetricServiceClientTest method listTimeSeriesTest4.
@Test
public void listTimeSeriesTest4() throws Exception {
TimeSeries responsesElement = TimeSeries.newBuilder().build();
ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken("").addAllTimeSeries(Arrays.asList(responsesElement)).build();
mockMetricService.addResponse(expectedResponse);
String name = "name3373707";
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
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<AbstractMessage> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTimeSeriesRequest actualRequest = ((ListTimeSeriesRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertEquals(interval, actualRequest.getInterval());
Assert.assertEquals(view, actualRequest.getView());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.api.ads.admanager.axis.v202205.TimeSeries in project java-monitoring by googleapis.
the class MetricServiceClientTest method createTimeSeriesExceptionTest.
@Test
public void createTimeSeriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.of("[PROJECT]");
List<TimeSeries> timeSeries = new ArrayList<>();
client.createTimeSeries(name, timeSeries);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.api.ads.admanager.axis.v202205.TimeSeries in project java-monitoring by googleapis.
the class MetricServiceClientTest method createTimeSeriesTest2.
@Test
public void createTimeSeriesTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockMetricService.addResponse(expectedResponse);
String name = "name3373707";
List<TimeSeries> timeSeries = new ArrayList<>();
client.createTimeSeries(name, timeSeries);
List<AbstractMessage> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateTimeSeriesRequest actualRequest = ((CreateTimeSeriesRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertEquals(timeSeries, actualRequest.getTimeSeriesList());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations