use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.
the class JobSearchCreateJob method sampleCreateJob.
/**
* Create Job
*
* @param projectId Your Google Cloud Project ID
* @param tenantId Identifier of the Tenant
*/
public static void sampleCreateJob(String projectId, String tenantId, String companyName, String requisitionId, String title, String description, String jobApplicationUrl, String addressOne, String addressTwo, String languageCode) {
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
TenantOrProjectName parent = TenantName.of(projectId, tenantId);
List<String> uris = Arrays.asList(jobApplicationUrl);
Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
List<String> addresses = Arrays.asList(addressOne, addressTwo);
Job job = Job.newBuilder().setCompany(companyName).setRequisitionId(requisitionId).setTitle(title).setDescription(description).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCode).build();
CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
Job response = jobServiceClient.createJob(request);
System.out.printf("Created job: %s\n", response.getName());
} catch (Exception exception) {
System.err.println("Failed to create the client due to: " + exception);
}
}
use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.
the class JobSearchCreateTenant method sampleCreateTenant.
/**
* Create Tenant for scoping resources, e.g. companies and jobs
*/
public static void sampleCreateTenant(String projectId, String externalId) {
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build();
CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(parent.toString()).setTenant(tenant).build();
Tenant response = tenantServiceClient.createTenant(request);
System.out.println("Created Tenant");
System.out.printf("Name: %s\n", response.getName());
System.out.printf("External ID: %s\n", response.getExternalId());
} catch (Exception exception) {
System.err.println("Failed to create the client due to: " + exception);
}
}
use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.
the class CompanyServiceClientTest method listCompaniesTest2.
@Test
public void listCompaniesTest2() throws Exception {
Company responsesElement = Company.newBuilder().build();
ListCompaniesResponse expectedResponse = ListCompaniesResponse.newBuilder().setNextPageToken("").addAllCompanies(Arrays.asList(responsesElement)).build();
mockCompanyService.addResponse(expectedResponse);
TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
ListCompaniesPagedResponse pagedListResponse = client.listCompanies(parent);
List<Company> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getCompaniesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockCompanyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListCompaniesRequest actualRequest = ((ListCompaniesRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.
the class ApplicationServiceClientTest method listApplicationsTest.
@Test
public void listApplicationsTest() throws Exception {
Application responsesElement = Application.newBuilder().build();
ListApplicationsResponse expectedResponse = ListApplicationsResponse.newBuilder().setNextPageToken("").addAllApplications(Arrays.asList(responsesElement)).build();
mockApplicationService.addResponse(expectedResponse);
ProfileName parent = ProfileName.of("[PROJECT]", "[TENANT]", "[PROFILE]");
ListApplicationsPagedResponse pagedListResponse = client.listApplications(parent);
List<Application> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getApplicationsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockApplicationService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListApplicationsRequest actualRequest = ((ListApplicationsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.talent.v4beta1.Tenant in project java-talent by googleapis.
the class TenantServiceClientTest method listTenantsTest.
@Test
public void listTenantsTest() throws Exception {
Tenant responsesElement = Tenant.newBuilder().build();
ListTenantsResponse expectedResponse = ListTenantsResponse.newBuilder().setNextPageToken("").addAllTenants(Arrays.asList(responsesElement)).build();
mockTenantService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListTenantsPagedResponse pagedListResponse = client.listTenants(parent);
List<Tenant> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTenantsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockTenantService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTenantsRequest actualRequest = ((ListTenantsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations