Search in sources :

Example 1 with Tenant

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());
}
Also used : Tenant(com.google.cloud.talent.v4beta1.Tenant) UpdateTenantRequest(com.google.cloud.talent.v4beta1.UpdateTenantRequest) Test(org.junit.Test)

Example 2 with Tenant

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();
}
Also used : CreateTenantRequest(com.google.cloud.talent.v4beta1.CreateTenantRequest) Company(com.google.cloud.talent.v4beta1.Company) Tenant(com.google.cloud.talent.v4beta1.Tenant) CreateCompanyRequest(com.google.cloud.talent.v4beta1.CreateCompanyRequest) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest) BeforeClass(org.junit.BeforeClass)

Example 3 with Tenant

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());
}
Also used : Tenant(com.google.cloud.talent.v4beta1.Tenant) GetTenantRequest(com.google.cloud.talent.v4beta1.GetTenantRequest) Test(org.junit.Test)

Example 4 with Tenant

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()));
}
Also used : ListJobsPagedResponse(com.google.cloud.talent.v4.JobServiceClient.ListJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Example 5 with Tenant

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListTenantsPagedResponse(com.google.cloud.talent.v4.TenantServiceClient.ListTenantsPagedResponse) Test(org.junit.Test)

Aggregations

Tenant (com.google.cloud.talent.v4beta1.Tenant)10 Test (org.junit.Test)7 TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)6 TenantServiceClient (com.google.cloud.talent.v4.TenantServiceClient)4 ProjectName (com.google.cloud.talent.v4beta1.ProjectName)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Tenant (com.google.cloud.talent.v4.Tenant)3 TenantName (com.google.cloud.talent.v4.TenantName)3 CreateTenantRequest (com.google.cloud.talent.v4beta1.CreateTenantRequest)3 GetTenantRequest (com.google.cloud.talent.v4beta1.GetTenantRequest)3 ListTenantsRequest (com.google.cloud.talent.v4beta1.ListTenantsRequest)3 ProjectName (com.google.cloud.talent.v4.ProjectName)2 ListTenantsPagedResponse (com.google.cloud.talent.v4.TenantServiceClient.ListTenantsPagedResponse)2 TenantName (com.google.cloud.talent.v4beta1.TenantName)2 Tenant (org.openstack4j.model.identity.v2.Tenant)2 ClientEvent (com.google.cloud.talent.v4.ClientEvent)1 ListCompaniesPagedResponse (com.google.cloud.talent.v4.CompanyServiceClient.ListCompaniesPagedResponse)1 CreateClientEventRequest (com.google.cloud.talent.v4.CreateClientEventRequest)1 CreateTenantRequest (com.google.cloud.talent.v4.CreateTenantRequest)1 DeleteTenantRequest (com.google.cloud.talent.v4.DeleteTenantRequest)1