Search in sources :

Example 1 with ClientContactFilter

use of ch.aaap.harvestclient.api.filter.ClientContactFilter 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 2 with ClientContactFilter

use of ch.aaap.harvestclient.api.filter.ClientContactFilter 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 3 with ClientContactFilter

use of ch.aaap.harvestclient.api.filter.ClientContactFilter in project harvest-client by 3AP-AG.

the class ClientContactsApiListTest method listPaginated.

@Test
void listPaginated() {
    Pagination<ClientContact> clientContacts = clientContactsApi.list(new ClientContactFilter(), 1, 1);
    List<ClientContact> contacts = clientContacts.getList();
    assertThat(contacts).hasSize(1);
    assertThat(clientContacts.getNextPage()).isEqualTo(2);
    assertThat(clientContacts.getPreviousPage()).isNull();
    assertThat(clientContacts.getPerPage()).isEqualTo(1);
    assertThat(clientContacts.getTotalPages()).isGreaterThanOrEqualTo(2);
}
Also used : ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) ClientContact(ch.aaap.harvestclient.domain.ClientContact) ClientContactFilter(ch.aaap.harvestclient.api.filter.ClientContactFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 4 with ClientContactFilter

use of ch.aaap.harvestclient.api.filter.ClientContactFilter in project harvest-client by 3AP-AG.

the class ClientContactsApiListTest method list.

@Test
void list() {
    List<ClientContact> clientContacts = clientContactsApi.list(new ClientContactFilter());
    assertThat(clientContacts).isNotEmpty();
}
Also used : ImmutableClientContact(ch.aaap.harvestclient.domain.ImmutableClientContact) ClientContact(ch.aaap.harvestclient.domain.ClientContact) ClientContactFilter(ch.aaap.harvestclient.api.filter.ClientContactFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Aggregations

HarvestTest (ch.aaap.harvestclient.HarvestTest)4 ClientContactFilter (ch.aaap.harvestclient.api.filter.ClientContactFilter)4 ClientContact (ch.aaap.harvestclient.domain.ClientContact)4 ImmutableClientContact (ch.aaap.harvestclient.domain.ImmutableClientContact)4 Test (org.junit.jupiter.api.Test)4 Client (ch.aaap.harvestclient.domain.Client)1 Instant (java.time.Instant)1