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;
}
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);
}
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);
}
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);
}
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");
}
Aggregations