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()));
}
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()));
}
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()));
}
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()));
}
Aggregations