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