use of com.google.cloud.talent.v4.Tenant in project java-talent by googleapis.
the class ITSystemTest method updateTenantTest.
@Test
public void updateTenantTest() {
String external_id = String.valueOf(Instant.now().getEpochSecond());
Tenant updateTenant = tenant.toBuilder().setExternalId(external_id).build();
UpdateTenantRequest request = UpdateTenantRequest.newBuilder().setTenant(updateTenant).build();
Tenant actual = tenantServiceClient.updateTenant(request);
assertEquals(tenant.getName(), actual.getName());
assertEquals(external_id, actual.getExternalId());
}
use of com.google.cloud.talent.v4.Tenant in project java-talent by googleapis.
the class ITSystemTest method beforeTest.
@BeforeClass
public static void beforeTest() throws IOException {
/* create tenant */
tenantServiceClient = TenantServiceClient.create();
Tenant createTenant = Tenant.newBuilder().setName(TENANT_NAME).setExternalId(EXTERNAL_ID).build();
CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(PROJECT_NAME.toString()).setTenant(createTenant).build();
tenant = tenantServiceClient.createTenant(request);
tenantId = getId(tenant.getName());
tenantName = TenantName.of(PROJECT_ID, tenantId);
/* create company */
companyServiceClient = CompanyServiceClient.create();
Company createCompany = Company.newBuilder().setDisplayName(DISPLAY_NAME).setExternalId(EXTERNAL_ID).build();
CreateCompanyRequest companyRequest = CreateCompanyRequest.newBuilder().setParent(tenantName.toString()).setCompany(createCompany).build();
company = companyServiceClient.createCompany(companyRequest);
companyId = getId(company.getName());
companyName = CompanyName.ofProjectTenantCompanyName(PROJECT_ID, tenantId, companyId);
/* create job */
jobServiceClient = JobServiceClient.create();
Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(Arrays.asList(JOB_APPLICATION_URL)).build();
Job createJob = Job.newBuilder().setCompany(companyId).setRequisitionId(REQUISITION_ID).setTitle(TITLE).setDescription(DESCRIPTION).setApplicationInfo(applicationInfo).addAllAddresses(Arrays.asList(ADDRESS_ONE, ADDRESS_TWO)).setLanguageCode(LANGUAGE_CODE).build();
CreateJobRequest jobRequest = CreateJobRequest.newBuilder().setParent(tenantName.toString()).setJob(createJob).build();
job = jobServiceClient.createJob(jobRequest);
jobId = getId(job.getName());
jobName = JobName.ofProjectTenantJobName(PROJECT_ID, tenantId, jobId);
/*create event */
eventServiceClient = EventServiceClient.create();
// create completion
completionClient = CompletionClient.create();
}
use of com.google.cloud.talent.v4.Tenant in project java-talent by googleapis.
the class ITSystemTest method getTenantTest.
@Test
public void getTenantTest() {
GetTenantRequest request = GetTenantRequest.newBuilder().setName(tenantName.toString()).build();
Tenant actual = tenantServiceClient.getTenant(request);
assertEquals(tenant.getName(), actual.getName());
assertEquals(tenant.getExternalId(), actual.getExternalId());
}
use of com.google.cloud.talent.v4.Tenant 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.Tenant in project java-talent by googleapis.
the class TenantServiceClientTest method listTenantsTest2.
@Test
public void listTenantsTest2() throws Exception {
Tenant responsesElement = Tenant.newBuilder().build();
ListTenantsResponse expectedResponse = ListTenantsResponse.newBuilder().setNextPageToken("").addAllTenants(Arrays.asList(responsesElement)).build();
mockTenantService.addResponse(expectedResponse);
String parent = "parent-995424086";
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, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations