use of com.google.cloud.dataproc.v1.AutoscalingPolicyServiceClient.ListAutoscalingPoliciesPagedResponse in project java-dataproc by googleapis.
the class AutoscalingPolicyServiceClientTest method listAutoscalingPoliciesTest2.
@Test
public void listAutoscalingPoliciesTest2() throws Exception {
AutoscalingPolicy responsesElement = AutoscalingPolicy.newBuilder().build();
ListAutoscalingPoliciesResponse expectedResponse = ListAutoscalingPoliciesResponse.newBuilder().setNextPageToken("").addAllPolicies(Arrays.asList(responsesElement)).build();
mockAutoscalingPolicyService.addResponse(expectedResponse);
RegionName parent = RegionName.of("[PROJECT]", "[REGION]");
ListAutoscalingPoliciesPagedResponse pagedListResponse = client.listAutoscalingPolicies(parent);
List<AutoscalingPolicy> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAutoscalingPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAutoscalingPoliciesRequest actualRequest = ((ListAutoscalingPoliciesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dataproc.v1.AutoscalingPolicyServiceClient.ListAutoscalingPoliciesPagedResponse in project java-dataproc by googleapis.
the class AutoscalingPolicyServiceClientTest method listAutoscalingPoliciesTest3.
@Test
public void listAutoscalingPoliciesTest3() throws Exception {
AutoscalingPolicy responsesElement = AutoscalingPolicy.newBuilder().build();
ListAutoscalingPoliciesResponse expectedResponse = ListAutoscalingPoliciesResponse.newBuilder().setNextPageToken("").addAllPolicies(Arrays.asList(responsesElement)).build();
mockAutoscalingPolicyService.addResponse(expectedResponse);
String parent = "parent-995424086";
ListAutoscalingPoliciesPagedResponse pagedListResponse = client.listAutoscalingPolicies(parent);
List<AutoscalingPolicy> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAutoscalingPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAutoscalingPoliciesRequest actualRequest = ((ListAutoscalingPoliciesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.dataproc.v1.AutoscalingPolicyServiceClient.ListAutoscalingPoliciesPagedResponse in project java-dataproc by googleapis.
the class AutoscalingPolicyServiceClientTest method listAutoscalingPoliciesTest.
@Test
public void listAutoscalingPoliciesTest() throws Exception {
AutoscalingPolicy responsesElement = AutoscalingPolicy.newBuilder().build();
ListAutoscalingPoliciesResponse expectedResponse = ListAutoscalingPoliciesResponse.newBuilder().setNextPageToken("").addAllPolicies(Arrays.asList(responsesElement)).build();
mockAutoscalingPolicyService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListAutoscalingPoliciesPagedResponse pagedListResponse = client.listAutoscalingPolicies(parent);
List<AutoscalingPolicy> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAutoscalingPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAutoscalingPoliciesRequest actualRequest = ((ListAutoscalingPoliciesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations