Search in sources :

Example 1 with ListGroupsPagedResponse

use of com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse in project java-monitoring by googleapis.

the class GroupServiceClientTest method listGroupsTest.

@Test
public void listGroupsTest() throws Exception {
    Group responsesElement = Group.newBuilder().build();
    ListGroupsResponse expectedResponse = ListGroupsResponse.newBuilder().setNextPageToken("").addAllGroup(Arrays.asList(responsesElement)).build();
    mockGroupService.addResponse(expectedResponse);
    FolderName name = FolderName.of("[FOLDER]");
    ListGroupsPagedResponse pagedListResponse = client.listGroups(name);
    List<Group> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListGroupsPagedResponse(com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse) ListGroupsRequest(com.google.monitoring.v3.ListGroupsRequest) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) ListGroupsResponse(com.google.monitoring.v3.ListGroupsResponse) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Example 2 with ListGroupsPagedResponse

use of com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse in project java-monitoring by googleapis.

the class GroupServiceClientTest method listGroupsTest4.

@Test
public void listGroupsTest4() throws Exception {
    Group responsesElement = Group.newBuilder().build();
    ListGroupsResponse expectedResponse = ListGroupsResponse.newBuilder().setNextPageToken("").addAllGroup(Arrays.asList(responsesElement)).build();
    mockGroupService.addResponse(expectedResponse);
    String name = "name3373707";
    ListGroupsPagedResponse pagedListResponse = client.listGroups(name);
    List<Group> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListGroupsPagedResponse(com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse) ListGroupsRequest(com.google.monitoring.v3.ListGroupsRequest) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) ListGroupsResponse(com.google.monitoring.v3.ListGroupsResponse) Test(org.junit.Test)

Example 3 with ListGroupsPagedResponse

use of com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse in project java-monitoring by googleapis.

the class GroupServiceClientTest method listGroupsTest2.

@Test
public void listGroupsTest2() throws Exception {
    Group responsesElement = Group.newBuilder().build();
    ListGroupsResponse expectedResponse = ListGroupsResponse.newBuilder().setNextPageToken("").addAllGroup(Arrays.asList(responsesElement)).build();
    mockGroupService.addResponse(expectedResponse);
    OrganizationName name = OrganizationName.of("[ORGANIZATION]");
    ListGroupsPagedResponse pagedListResponse = client.listGroups(name);
    List<Group> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) ListGroupsPagedResponse(com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse) ListGroupsRequest(com.google.monitoring.v3.ListGroupsRequest) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) ListGroupsResponse(com.google.monitoring.v3.ListGroupsResponse) Test(org.junit.Test)

Example 4 with ListGroupsPagedResponse

use of com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse in project java-monitoring by googleapis.

the class GroupServiceClientTest method listGroupsTest3.

@Test
public void listGroupsTest3() throws Exception {
    Group responsesElement = Group.newBuilder().build();
    ListGroupsResponse expectedResponse = ListGroupsResponse.newBuilder().setNextPageToken("").addAllGroup(Arrays.asList(responsesElement)).build();
    mockGroupService.addResponse(expectedResponse);
    ProjectName name = ProjectName.of("[PROJECT]");
    ListGroupsPagedResponse pagedListResponse = client.listGroups(name);
    List<Group> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getGroupList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListGroupsRequest actualRequest = ((ListGroupsRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListGroupsPagedResponse(com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse) ListGroupsRequest(com.google.monitoring.v3.ListGroupsRequest) Group(com.google.monitoring.v3.Group) AbstractMessage(com.google.protobuf.AbstractMessage) ListGroupsResponse(com.google.monitoring.v3.ListGroupsResponse) ProjectName(com.google.monitoring.v3.ProjectName) Test(org.junit.Test)

Aggregations

ListGroupsPagedResponse (com.google.cloud.monitoring.v3.GroupServiceClient.ListGroupsPagedResponse)4 Group (com.google.monitoring.v3.Group)4 ListGroupsRequest (com.google.monitoring.v3.ListGroupsRequest)4 ListGroupsResponse (com.google.monitoring.v3.ListGroupsResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 FolderName (com.google.monitoring.v3.FolderName)1 OrganizationName (com.google.monitoring.v3.OrganizationName)1 ProjectName (com.google.monitoring.v3.ProjectName)1