Search in sources :

Example 1 with ClientContact

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

the class ClientContactsApiImpl method create.

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

Example 2 with ClientContact

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

the class ClientContactsApiCreateTest method createAllOptions.

@Test
void createAllOptions() {
    // opposites of the defaults
    String title = "Mr. ";
    String firstName = "test first";
    String lastName = "test Last";
    String email = "hey@example.com";
    String phoneOffice = "006 00 12";
    String phoneMobile = "1232 32323 32 ";
    String fax = "this is a fax ?";
    ClientContact creationInfo = ImmutableClientContact.builder().client(clientReference).firstName(firstName).lastName(lastName).email(email).phoneMobile(phoneMobile).phoneOffice(phoneOffice).fax(fax).build();
    clientContact = clientContactsApi.create(creationInfo);
    assertThat(clientContact).usingComparatorForType((x, y) -> (int) (y.getId() - x.getId()), Reference.class).isEqualToIgnoringNullFields(creationInfo);
}
Also used : HarvestTest(ch.aaap.harvestclient.HarvestTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ClientContactsApi(ch.aaap.harvestclient.api.ClientContactsApi) ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) TestSetupUtil(util.TestSetupUtil) Test(org.junit.jupiter.api.Test) RequestProcessingException(ch.aaap.harvestclient.exception.RequestProcessingException) AfterEach(org.junit.jupiter.api.AfterEach) Client(ch.aaap.harvestclient.domain.Client) Reference(ch.aaap.harvestclient.domain.reference.Reference) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) ClientContact(ch.aaap.harvestclient.domain.ClientContact) ExistingData(util.ExistingData) ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) ClientContact(ch.aaap.harvestclient.domain.ClientContact) Reference(ch.aaap.harvestclient.domain.reference.Reference) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 3 with ClientContact

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

the class ClientContactsApiListTest method listByClient.

@Test
void listByClient() {
    Reference<Client> anotherClientReference = ExistingData.getInstance().getAnotherClientReference();
    ClientContact creationInfo = ImmutableClientContact.builder().client(anotherClientReference).firstName("inactive test ClientContact").build();
    clientContact = clientContactsApi.create(creationInfo);
    ClientContactFilter filter = new ClientContactFilter();
    filter.setClientReference(anotherClientReference);
    List<ClientContact> clientContacts = clientContactsApi.list(filter);
    assertThat(clientContacts).usingFieldByFieldElementComparator().contains(clientContact);
}
Also used : ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) ClientContact(ch.aaap.harvestclient.domain.ClientContact) Client(ch.aaap.harvestclient.domain.Client) ClientContactFilter(ch.aaap.harvestclient.api.filter.ClientContactFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 4 with ClientContact

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

the class ClientContactsApiListTest method listByUpdatedSince.

@Test
void listByUpdatedSince() {
    Instant creationTime = Instant.now().minusSeconds(1);
    ClientContact creationInfo = ImmutableClientContact.builder().client(clientReference).firstName("newly created test ClientContact").build();
    clientContact = clientContactsApi.create(creationInfo);
    ClientContactFilter filter = new ClientContactFilter();
    filter.setUpdatedSince(creationTime);
    List<ClientContact> clientContacts = clientContactsApi.list(filter);
    assertThat(clientContacts).usingFieldByFieldElementComparator().containsExactly(clientContact);
}
Also used : ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) ClientContact(ch.aaap.harvestclient.domain.ClientContact) Instant(java.time.Instant) ClientContactFilter(ch.aaap.harvestclient.api.filter.ClientContactFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 5 with ClientContact

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

the class ClientContactsApiCreateTest method createInvalidEmail.

@Test
void createInvalidEmail() {
    String firstName = "test first";
    String email = "this is not an email";
    ClientContact creationInfo = ImmutableClientContact.builder().client(clientReference).firstName(firstName).email(email).build();
    assertThatExceptionOfType(RequestProcessingException.class).isThrownBy(() -> clientContact = clientContactsApi.create(creationInfo)).withMessageContaining("Email is not valid");
}
Also used : ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) ClientContact(ch.aaap.harvestclient.domain.ClientContact) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Aggregations

ClientContact (ch.aaap.harvestclient.domain.ClientContact)12 HarvestTest (ch.aaap.harvestclient.HarvestTest)9 ImmutableClientContact (ch.aaap.harvestclient.domain.ImmutableClientContact)9 Test (org.junit.jupiter.api.Test)9 ClientContactFilter (ch.aaap.harvestclient.api.filter.ClientContactFilter)4 Client (ch.aaap.harvestclient.domain.Client)3 ClientContactUpdateInfo (ch.aaap.harvestclient.domain.param.ClientContactUpdateInfo)2 ImmutableClientContactUpdateInfo (ch.aaap.harvestclient.domain.param.ImmutableClientContactUpdateInfo)2 Reference (ch.aaap.harvestclient.domain.reference.Reference)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 Harvest (ch.aaap.harvestclient.core.Harvest)1 User (ch.aaap.harvestclient.domain.User)1 RequestProcessingException (ch.aaap.harvestclient.exception.RequestProcessingException)1 Instant (java.time.Instant)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 AfterEach (org.junit.jupiter.api.AfterEach)1