Search in sources :

Example 1 with ListJobsRequest

use of com.google.cloud.talent.v4.ListJobsRequest in project java-talent by googleapis.

the class JobServiceClientTest method listJobsTest.

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

Example 2 with ListJobsRequest

use of com.google.cloud.talent.v4.ListJobsRequest in project java-talent by googleapis.

the class JobSearchListJobs method sampleListJobs.

/**
 * List Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListJobs(String projectId, String tenantId, String filter) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
            System.out.printf("Job name: %s\n", responseItem.getName());
            System.out.printf("Job requisition ID: %s\n", responseItem.getRequisitionId());
            System.out.printf("Job title: %s\n", responseItem.getTitle());
            System.out.printf("Job description: %s\n", responseItem.getDescription());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : ListJobsRequest(com.google.cloud.talent.v4beta1.ListJobsRequest) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job)

Example 3 with ListJobsRequest

use of com.google.cloud.talent.v4.ListJobsRequest in project java-talent by googleapis.

the class JobSearchListJobs method listJobs.

// Search Jobs with histogram queries.
public static void listJobs(String projectId, String tenantId, String filter) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
            System.out.format("Job name: %s%n", responseItem.getName());
            System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId());
            System.out.format("Job title: %s%n", responseItem.getTitle());
            System.out.format("Job description: %s%n", responseItem.getDescription());
        }
    }
}
Also used : ListJobsRequest(com.google.cloud.talent.v4.ListJobsRequest) TenantName(com.google.cloud.talent.v4.TenantName) JobServiceClient(com.google.cloud.talent.v4.JobServiceClient) Job(com.google.cloud.talent.v4.Job)

Example 4 with ListJobsRequest

use of com.google.cloud.talent.v4.ListJobsRequest in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchListJobs method listJobs.

// Search Jobs with histogram queries.
public static void listJobs(String projectId, String tenantId, String filter) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantName parent = TenantName.of(projectId, tenantId);
        ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
            System.out.format("Job name: %s%n", responseItem.getName());
            System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId());
            System.out.format("Job title: %s%n", responseItem.getTitle());
            System.out.format("Job description: %s%n", responseItem.getDescription());
        }
    }
}
Also used : ListJobsRequest(com.google.cloud.talent.v4beta1.ListJobsRequest) TenantName(com.google.cloud.talent.v4beta1.TenantName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job)

Example 5 with ListJobsRequest

use of com.google.cloud.talent.v4.ListJobsRequest in project java-talent by googleapis.

the class JobServiceClientTest method listJobsTest2.

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

Aggregations

Job (com.google.cloud.talent.v4beta1.Job)3 ListJobsRequest (com.google.cloud.talent.v4beta1.ListJobsRequest)3 Test (org.junit.Test)3 ListJobsPagedResponse (com.google.cloud.talent.v4.JobServiceClient.ListJobsPagedResponse)2 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Job (com.google.cloud.talent.v4.Job)1 JobServiceClient (com.google.cloud.talent.v4.JobServiceClient)1 ListJobsRequest (com.google.cloud.talent.v4.ListJobsRequest)1 TenantName (com.google.cloud.talent.v4.TenantName)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)1