Search in sources :

Example 1 with ListTimeSeriesPagedResponse

use of com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse 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());
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) TimeInterval(com.google.monitoring.v3.TimeInterval) ProjectName(com.google.monitoring.v3.ProjectName) ListTimeSeriesResponse(com.google.monitoring.v3.ListTimeSeriesResponse) TimeSeriesView(com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView) ListTimeSeriesPagedResponse(com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) ListTimeSeriesRequest(com.google.monitoring.v3.ListTimeSeriesRequest) Test(org.junit.Test)

Aggregations

ListTimeSeriesPagedResponse (com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListTimeSeriesPagedResponse)1 ListTimeSeriesRequest (com.google.monitoring.v3.ListTimeSeriesRequest)1 TimeSeriesView (com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView)1 ListTimeSeriesResponse (com.google.monitoring.v3.ListTimeSeriesResponse)1 ProjectName (com.google.monitoring.v3.ProjectName)1 TimeInterval (com.google.monitoring.v3.TimeInterval)1 TimeSeries (com.google.monitoring.v3.TimeSeries)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Test (org.junit.Test)1