Search in sources :

Example 31 with Company

use of com.google.cloud.talent.v4beta1.Company in project universal-db by teamapps-org.

the class DeleteTest method testDeleteReferences.

@Test
public void testDeleteReferences() {
    Person p1 = Person.create().setLastName("p1").save();
    Person p2 = Person.create().setLastName("p2").save();
    Person p3 = Person.create().setLastName("p3").save();
    Person p4 = Person.create().setLastName("p4").save();
    Company c1 = Company.create().setName("c1").addEmployees(p1, p2, p3).save();
    Company c2 = Company.create().setName("c2").addEmployees(p4).save();
    assertTrue("employess of c1", TestBase.compareEntities(c1.getEmployees(), p1, p2, p3));
    assertTrue("employess of c2", TestBase.compareEntities(c2.getEmployees(), p4));
    assertEquals(p1.getCompany(), c1);
    assertEquals(p2.getCompany(), c1);
    assertEquals(p3.getCompany(), c1);
    assertEquals(p4.getCompany(), c2);
    c1.removeAllEmployees().save();
    assertTrue("p1 has no c", p1.getCompany() == null);
    assertTrue("p2 has no c", p2.getCompany() == null);
    assertTrue("p3 has no c", p3.getCompany() == null);
    assertTrue("p4 has c", p4.getCompany() != null);
    assertEquals("c1 has no employees", 0, c1.getEmployeesCount());
    assertTrue("employess of c1", TestBase.compareEntities(c1.getEmployees()));
}
Also used : Company(org.teamapps.datamodel.testdb1.Company) Person(org.teamapps.datamodel.testdb1.Person) Test(org.junit.Test)

Example 32 with Company

use of com.google.cloud.talent.v4beta1.Company in project java-talent by googleapis.

the class JobSearchDeleteCompany method sampleDeleteCompany.

/**
 * Delete Company
 */
public static void sampleDeleteCompany(String projectId, String tenantId, String companyId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        CompanyName name = CompanyWithTenantName.of(projectId, tenantId, companyId);
        DeleteCompanyRequest request = DeleteCompanyRequest.newBuilder().setName(name.toString()).build();
        companyServiceClient.deleteCompany(request);
        System.out.println("Deleted company");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : DeleteCompanyRequest(com.google.cloud.talent.v4beta1.DeleteCompanyRequest) CompanyName(com.google.cloud.talent.v4beta1.CompanyName) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient)

Example 33 with Company

use of com.google.cloud.talent.v4beta1.Company in project java-talent by googleapis.

the class JobSearchGetCompany method sampleGetCompany.

/**
 * Get Company
 */
public static void sampleGetCompany(String projectId, String tenantId, String companyId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        CompanyName name = CompanyWithTenantName.of(projectId, tenantId, companyId);
        GetCompanyRequest request = GetCompanyRequest.newBuilder().setName(name.toString()).build();
        Company response = companyServiceClient.getCompany(request);
        System.out.printf("Company name: %s\n", response.getName());
        System.out.printf("Display name: %s\n", response.getDisplayName());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : CompanyName(com.google.cloud.talent.v4beta1.CompanyName) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) GetCompanyRequest(com.google.cloud.talent.v4beta1.GetCompanyRequest)

Example 34 with Company

use of com.google.cloud.talent.v4beta1.Company in project java-talent by googleapis.

the class JobSearchListCompanies method sampleListCompanies.

/**
 * List Companies
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleListCompanies(String projectId, String tenantId) {
    try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            System.out.printf("Company Name: %s\n", responseItem.getName());
            System.out.printf("Display Name: %s\n", responseItem.getDisplayName());
            System.out.printf("External ID: %s\n", responseItem.getExternalId());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : ListCompaniesRequest(com.google.cloud.talent.v4beta1.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 35 with Company

use of com.google.cloud.talent.v4beta1.Company 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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListCompaniesPagedResponse(com.google.cloud.talent.v4beta1.CompanyServiceClient.ListCompaniesPagedResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 Company (com.google.cloud.talent.v4beta1.Company)10 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)8 Company (com.google.api.ads.admanager.axis.v202202.Company)7 CompanyServiceInterface (com.google.api.ads.admanager.axis.v202202.CompanyServiceInterface)7 AdManagerSession (com.google.api.ads.admanager.lib.client.AdManagerSession)6 MockHttpIntegrationTest (com.google.api.ads.common.lib.testing.MockHttpIntegrationTest)6 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)6 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)5 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)5 Company (com.google.api.ads.admanager.axis.v202108.Company)4 CompanyServiceInterface (com.google.api.ads.admanager.axis.v202108.CompanyServiceInterface)4 Company (com.google.api.ads.admanager.axis.v202111.Company)4 CompanyServiceInterface (com.google.api.ads.admanager.axis.v202111.CompanyServiceInterface)4 CompanyName (com.google.cloud.talent.v4beta1.CompanyName)4 Diff (org.xmlunit.diff.Diff)4 AdManagerServices (com.google.api.ads.admanager.axis.factory.AdManagerServices)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)3 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)3