Search in sources :

Example 1 with ListJobsPagedResponse

use of com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse in project java-scheduler by googleapis.

the class CloudSchedulerClientTest method listJobsTest.

@Test
public void listJobsTest() throws Exception {
    Job responsesElement = Job.newBuilder().build();
    ListJobsResponse expectedResponse = ListJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
    mockCloudScheduler.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListJobsPagedResponse pagedListResponse = client.listJobs(parent);
    List<Job> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudScheduler.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListJobsPagedResponse(com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 2 with ListJobsPagedResponse

use of com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse in project java-scheduler by googleapis.

the class CloudSchedulerClientTest method listJobsTest2.

@Test
public void listJobsTest2() throws Exception {
    Job responsesElement = Job.newBuilder().build();
    ListJobsResponse expectedResponse = ListJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
    mockCloudScheduler.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListJobsPagedResponse pagedListResponse = client.listJobs(parent);
    List<Job> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudScheduler.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListJobsPagedResponse(com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 3 with ListJobsPagedResponse

use of com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse in project java-scheduler by googleapis.

the class CloudSchedulerClientTest method listJobsTest2.

@Test
public void listJobsTest2() throws Exception {
    Job responsesElement = Job.newBuilder().build();
    ListJobsResponse expectedResponse = ListJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
    mockCloudScheduler.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListJobsPagedResponse pagedListResponse = client.listJobs(parent);
    List<Job> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudScheduler.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListJobsPagedResponse(com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 4 with ListJobsPagedResponse

use of com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse in project java-scheduler by googleapis.

the class CloudSchedulerClientTest method listJobsTest.

@Test
public void listJobsTest() throws Exception {
    Job responsesElement = Job.newBuilder().build();
    ListJobsResponse expectedResponse = ListJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
    mockCloudScheduler.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListJobsPagedResponse pagedListResponse = client.listJobs(parent);
    List<Job> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudScheduler.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListJobsPagedResponse(com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 ListJobsPagedResponse (com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse)2 ListJobsPagedResponse (com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListJobsPagedResponse)2