Search in sources :

Example 1 with InstanceGroupManager

use of com.google.cloud.compute.v1.InstanceGroupManager in project java-compute by googleapis.

the class InstanceGroupManagersClientTest method listManagedInstancesTest.

@Test
public void listManagedInstancesTest() throws Exception {
    ManagedInstance responsesElement = ManagedInstance.newBuilder().build();
    InstanceGroupManagersListManagedInstancesResponse expectedResponse = InstanceGroupManagersListManagedInstancesResponse.newBuilder().setNextPageToken("").addAllManagedInstances(Arrays.asList(responsesElement)).build();
    mockService.addResponse(expectedResponse);
    String project = "project-6911";
    String zone = "zone-5246";
    String instanceGroupManager = "instanceGroupManager-7543";
    ListManagedInstancesPagedResponse pagedListResponse = client.listManagedInstances(project, zone, instanceGroupManager);
    List<ManagedInstance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getManagedInstancesList().get(0), resources.get(0));
    List<String> actualRequests = mockService.getRequestPaths();
    Assert.assertEquals(1, actualRequests.size());
    String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
    Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Also used : ListManagedInstancesPagedResponse(com.google.cloud.compute.v1.InstanceGroupManagersClient.ListManagedInstancesPagedResponse) Test(org.junit.Test)

Example 2 with InstanceGroupManager

use of com.google.cloud.compute.v1.InstanceGroupManager in project java-compute by googleapis.

the class InstanceGroupManagersClientTest method listTest.

@Test
public void listTest() throws Exception {
    InstanceGroupManager responsesElement = InstanceGroupManager.newBuilder().build();
    InstanceGroupManagerList expectedResponse = InstanceGroupManagerList.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
    mockService.addResponse(expectedResponse);
    String project = "project-6911";
    String zone = "zone-5246";
    ListPagedResponse pagedListResponse = client.list(project, zone);
    List<InstanceGroupManager> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
    List<String> actualRequests = mockService.getRequestPaths();
    Assert.assertEquals(1, actualRequests.size());
    String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
    Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Also used : ListPagedResponse(com.google.cloud.compute.v1.InstanceGroupManagersClient.ListPagedResponse) AggregatedListPagedResponse(com.google.cloud.compute.v1.InstanceGroupManagersClient.AggregatedListPagedResponse) Test(org.junit.Test)

Example 3 with InstanceGroupManager

use of com.google.cloud.compute.v1.InstanceGroupManager in project java-compute by googleapis.

the class InstanceGroupManagersClientTest method listErrorsTest.

@Test
public void listErrorsTest() throws Exception {
    InstanceManagedByIgmError responsesElement = InstanceManagedByIgmError.newBuilder().build();
    InstanceGroupManagersListErrorsResponse expectedResponse = InstanceGroupManagersListErrorsResponse.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
    mockService.addResponse(expectedResponse);
    String project = "project-6911";
    String zone = "zone-5246";
    String instanceGroupManager = "instanceGroupManager-7543";
    ListErrorsPagedResponse pagedListResponse = client.listErrors(project, zone, instanceGroupManager);
    List<InstanceManagedByIgmError> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
    List<String> actualRequests = mockService.getRequestPaths();
    Assert.assertEquals(1, actualRequests.size());
    String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
    Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Also used : ListErrorsPagedResponse(com.google.cloud.compute.v1.InstanceGroupManagersClient.ListErrorsPagedResponse) Test(org.junit.Test)

Example 4 with InstanceGroupManager

use of com.google.cloud.compute.v1.InstanceGroupManager in project java-compute by googleapis.

the class RegionInstanceGroupManagersClientTest method listErrorsTest.

@Test
public void listErrorsTest() throws Exception {
    InstanceManagedByIgmError responsesElement = InstanceManagedByIgmError.newBuilder().build();
    RegionInstanceGroupManagersListErrorsResponse expectedResponse = RegionInstanceGroupManagersListErrorsResponse.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
    mockService.addResponse(expectedResponse);
    String project = "project-6911";
    String region = "region-9622";
    String instanceGroupManager = "instanceGroupManager-7543";
    ListErrorsPagedResponse pagedListResponse = client.listErrors(project, region, instanceGroupManager);
    List<InstanceManagedByIgmError> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
    List<String> actualRequests = mockService.getRequestPaths();
    Assert.assertEquals(1, actualRequests.size());
    String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
    Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Also used : ListErrorsPagedResponse(com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListErrorsPagedResponse) Test(org.junit.Test)

Example 5 with InstanceGroupManager

use of com.google.cloud.compute.v1.InstanceGroupManager in project java-compute by googleapis.

the class RegionInstanceGroupManagersClientTest method listPerInstanceConfigsTest.

@Test
public void listPerInstanceConfigsTest() throws Exception {
    PerInstanceConfig responsesElement = PerInstanceConfig.newBuilder().build();
    RegionInstanceGroupManagersListInstanceConfigsResp expectedResponse = RegionInstanceGroupManagersListInstanceConfigsResp.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
    mockService.addResponse(expectedResponse);
    String project = "project-6911";
    String region = "region-9622";
    String instanceGroupManager = "instanceGroupManager-7543";
    ListPerInstanceConfigsPagedResponse pagedListResponse = client.listPerInstanceConfigs(project, region, instanceGroupManager);
    List<PerInstanceConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
    List<String> actualRequests = mockService.getRequestPaths();
    Assert.assertEquals(1, actualRequests.size());
    String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
    Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Also used : ListPerInstanceConfigsPagedResponse(com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListPerInstanceConfigsPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 Instance (com.google.cloud.compute.v1.Instance)1 InstanceGroupManager (com.google.cloud.compute.v1.InstanceGroupManager)1 InstanceGroupManagersClient (com.google.cloud.compute.v1.InstanceGroupManagersClient)1 AggregatedListPagedResponse (com.google.cloud.compute.v1.InstanceGroupManagersClient.AggregatedListPagedResponse)1 ListErrorsPagedResponse (com.google.cloud.compute.v1.InstanceGroupManagersClient.ListErrorsPagedResponse)1 ListManagedInstancesPagedResponse (com.google.cloud.compute.v1.InstanceGroupManagersClient.ListManagedInstancesPagedResponse)1 ListPagedResponse (com.google.cloud.compute.v1.InstanceGroupManagersClient.ListPagedResponse)1 ListPerInstanceConfigsPagedResponse (com.google.cloud.compute.v1.InstanceGroupManagersClient.ListPerInstanceConfigsPagedResponse)1 InstanceTemplate (com.google.cloud.compute.v1.InstanceTemplate)1 InstanceTemplatesClient (com.google.cloud.compute.v1.InstanceTemplatesClient)1 Operation (com.google.cloud.compute.v1.Operation)1 ListErrorsPagedResponse (com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListErrorsPagedResponse)1 ListManagedInstancesPagedResponse (com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListManagedInstancesPagedResponse)1 ListPagedResponse (com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListPagedResponse)1 ListPerInstanceConfigsPagedResponse (com.google.cloud.compute.v1.RegionInstanceGroupManagersClient.ListPerInstanceConfigsPagedResponse)1 ArrayList (java.util.ArrayList)1