Search in sources :

Example 1 with Client

use of ch.aaap.harvestclient.domain.Client in project harvest-client by 3AP-AG.

the class ClientsApiImpl method create.

@Override
public Client create(Client creationInfo) {
    Call<Client> call = service.create(creationInfo);
    Client client = ExceptionHandler.callOrThrow(call);
    log.debug("Created {}", client);
    return client;
}
Also used : Client(ch.aaap.harvestclient.domain.Client)

Example 2 with Client

use of ch.aaap.harvestclient.domain.Client in project harvest-client by 3AP-AG.

the class ProjectsApiCreateTest method createDefaultBudget.

@ParameterizedTest
@EnumSource(Project.BudgetMethod.class)
void createDefaultBudget(Project.BudgetMethod budgetMethod, TestInfo testInfo) {
    Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
    String name = "Project for test " + testInfo.getDisplayName();
    boolean billable = true;
    Project.BillingMethod billBy = Project.BillingMethod.PROJECT;
    Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetMethod).build();
    project = projectsApi.create(creationInfo);
    assertThat(project.getBillable()).isEqualTo(billable);
    assertThat(project.getBillBy()).isEqualTo(billBy);
    assertThat(project.getBudgetBy()).isEqualTo(budgetMethod);
    assertThat(project.getName()).isEqualTo(name);
    assertThat(project.getClient().getId()).isEqualTo(clientReference.getId());
}
Also used : Project(ch.aaap.harvestclient.domain.Project) ImmutableProject(ch.aaap.harvestclient.domain.ImmutableProject) Client(ch.aaap.harvestclient.domain.Client) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with Client

use of ch.aaap.harvestclient.domain.Client in project harvest-client by 3AP-AG.

the class ProjectsApiUpdateTest method beforeEach.

@BeforeEach
void beforeEach(TestInfo testInfo) {
    Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
    String name = "Project for test " + testInfo.getDisplayName();
    boolean billable = true;
    Project.BillingMethod billBy = Project.BillingMethod.PROJECT;
    Project.BudgetMethod budgetBy = Project.BudgetMethod.HOURS_PER_TASK;
    Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetBy).build();
    project = projectsApi.create(creationInfo);
}
Also used : Project(ch.aaap.harvestclient.domain.Project) ImmutableProject(ch.aaap.harvestclient.domain.ImmutableProject) Client(ch.aaap.harvestclient.domain.Client) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with Client

use of ch.aaap.harvestclient.domain.Client in project harvest-client by 3AP-AG.

the class ClientsApiCreateTest method create.

@Test
void create() {
    String name = "test Client";
    Client creationInfo = ImmutableClient.builder().name(name).build();
    client = clientsApi.create(creationInfo);
    assertThat(client.getName()).isEqualTo(name);
    Client gottenClient = clientsApi.get(client);
    assertThat(gottenClient).isEqualTo(gottenClient);
}
Also used : ImmutableClient(ch.aaap.harvestclient.domain.ImmutableClient) Client(ch.aaap.harvestclient.domain.Client) Test(org.junit.jupiter.api.Test) HarvestTest(ch.aaap.harvestclient.HarvestTest)

Example 5 with Client

use of ch.aaap.harvestclient.domain.Client in project harvest-client by 3AP-AG.

the class ClientsApiCreateTest method createInvalidCurrency.

/*
     * This test will fail if the test company is setup with a different currency
     */
@Test
void createInvalidCurrency() {
    String currency = "EU";
    Client creationInfo = ImmutableClient.builder().name("Test client").currency(currency).build();
    client = clientsApi.create(creationInfo);
    // Company object does not expose currency, this needs to be set to the test
    // account default currency
    // setting an invalid one will set it to the company default
    assertThat(client.getCurrency()).isEqualTo("USD");
}
Also used : ImmutableClient(ch.aaap.harvestclient.domain.ImmutableClient) Client(ch.aaap.harvestclient.domain.Client) Test(org.junit.jupiter.api.Test) HarvestTest(ch.aaap.harvestclient.HarvestTest)

Aggregations

Client (ch.aaap.harvestclient.domain.Client)22 HarvestTest (ch.aaap.harvestclient.HarvestTest)16 Test (org.junit.jupiter.api.Test)16 ImmutableClient (ch.aaap.harvestclient.domain.ImmutableClient)9 ImmutableProject (ch.aaap.harvestclient.domain.ImmutableProject)6 Project (ch.aaap.harvestclient.domain.Project)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 ClientFilter (ch.aaap.harvestclient.api.filter.ClientFilter)4 LocalDate (java.time.LocalDate)4 ClientContact (ch.aaap.harvestclient.domain.ClientContact)3 ImmutableClientContact (ch.aaap.harvestclient.domain.ImmutableClientContact)2 ClientUpdateInfo (ch.aaap.harvestclient.domain.param.ClientUpdateInfo)2 ImmutableClientUpdateInfo (ch.aaap.harvestclient.domain.param.ImmutableClientUpdateInfo)2 Reference (ch.aaap.harvestclient.domain.reference.Reference)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 Api (ch.aaap.harvestclient.api.Api)1 ClientContactsApi (ch.aaap.harvestclient.api.ClientContactsApi)1 ch.aaap.harvestclient.api.filter (ch.aaap.harvestclient.api.filter)1 ClientContactFilter (ch.aaap.harvestclient.api.filter.ClientContactFilter)1 EstimateFilter (ch.aaap.harvestclient.api.filter.EstimateFilter)1