Search in sources :

Example 1 with ListServiceLevelObjectivesResponse

use of com.google.monitoring.v3.ListServiceLevelObjectivesResponse in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method listServiceLevelObjectivesTest.

@Test
public void listServiceLevelObjectivesTest() throws Exception {
    ServiceLevelObjective responsesElement = ServiceLevelObjective.newBuilder().build();
    ListServiceLevelObjectivesResponse expectedResponse = ListServiceLevelObjectivesResponse.newBuilder().setNextPageToken("").addAllServiceLevelObjectives(Arrays.asList(responsesElement)).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    ServiceName parent = ServiceName.ofProjectServiceName("[PROJECT]", "[SERVICE]");
    ListServiceLevelObjectivesPagedResponse pagedListResponse = client.listServiceLevelObjectives(parent);
    List<ServiceLevelObjective> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getServiceLevelObjectivesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListServiceLevelObjectivesRequest actualRequest = ((ListServiceLevelObjectivesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServiceLevelObjectivesRequest(com.google.monitoring.v3.ListServiceLevelObjectivesRequest) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) ServiceName(com.google.monitoring.v3.ServiceName) ListServiceLevelObjectivesPagedResponse(com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse) ListServiceLevelObjectivesResponse(com.google.monitoring.v3.ListServiceLevelObjectivesResponse) Test(org.junit.Test)

Example 2 with ListServiceLevelObjectivesResponse

use of com.google.monitoring.v3.ListServiceLevelObjectivesResponse in project java-monitoring by googleapis.

the class ServiceMonitoringServiceClientTest method listServiceLevelObjectivesTest2.

@Test
public void listServiceLevelObjectivesTest2() throws Exception {
    ServiceLevelObjective responsesElement = ServiceLevelObjective.newBuilder().build();
    ListServiceLevelObjectivesResponse expectedResponse = ListServiceLevelObjectivesResponse.newBuilder().setNextPageToken("").addAllServiceLevelObjectives(Arrays.asList(responsesElement)).build();
    mockServiceMonitoringService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListServiceLevelObjectivesPagedResponse pagedListResponse = client.listServiceLevelObjectives(parent);
    List<ServiceLevelObjective> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getServiceLevelObjectivesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockServiceMonitoringService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListServiceLevelObjectivesRequest actualRequest = ((ListServiceLevelObjectivesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListServiceLevelObjectivesRequest(com.google.monitoring.v3.ListServiceLevelObjectivesRequest) ServiceLevelObjective(com.google.monitoring.v3.ServiceLevelObjective) ListServiceLevelObjectivesPagedResponse(com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse) ListServiceLevelObjectivesResponse(com.google.monitoring.v3.ListServiceLevelObjectivesResponse) Test(org.junit.Test)

Aggregations

ListServiceLevelObjectivesPagedResponse (com.google.cloud.monitoring.v3.ServiceMonitoringServiceClient.ListServiceLevelObjectivesPagedResponse)2 ListServiceLevelObjectivesRequest (com.google.monitoring.v3.ListServiceLevelObjectivesRequest)2 ListServiceLevelObjectivesResponse (com.google.monitoring.v3.ListServiceLevelObjectivesResponse)2 ServiceLevelObjective (com.google.monitoring.v3.ServiceLevelObjective)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ServiceName (com.google.monitoring.v3.ServiceName)1