Skip to content

Commit

Permalink
Fix tests after SDK parameters updated
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-nedza committed Nov 7, 2023
1 parent 4c059cf commit 75515e8
Showing 1 changed file with 92 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import com.maxio.advancedbilling.models.CreateCustomerRequest;
import com.maxio.advancedbilling.models.Customer;
import com.maxio.advancedbilling.models.CustomerResponse;
import com.maxio.advancedbilling.models.ListCustomersInput;
import com.maxio.advancedbilling.models.SortingDirection;
import com.maxio.advancedbilling.models.containers.ListCustomersDirection;
import com.maxio.advancedbilling.models.containers.ListCustomersInputDirection;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -58,7 +59,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingEmail() throws IOException,

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, email);
.listCustomers(new ListCustomersInput().toBuilder()
.q(email).build()
);

// then
assertThat(listCustomers).hasSize(1);
Expand Down Expand Up @@ -103,7 +106,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingEmail() throws IOException,

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, notExistingEmail);
.listCustomers(new ListCustomersInput().toBuilder()
.q(notExistingEmail).build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -116,7 +121,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingChargifyID() throws IOExcept

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, chargifyId.toString());
.listCustomers(new ListCustomersInput().toBuilder()
.q(chargifyId.toString()).build()
);

// then
assertThat(listCustomers).hasSize(1);
Expand All @@ -129,7 +136,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingChargifyID() throws IOExcept

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, notExistingChargifyId);
.listCustomers(new ListCustomersInput().toBuilder()
.q(notExistingChargifyId).build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -142,7 +151,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingOrganization() throws IOExce

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.q(organization).build()
);

// then
assertThat(listCustomers).hasSize(10);
Expand All @@ -155,7 +166,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingOrganization() throws IOExce

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, notExistingOrganization);
.listCustomers(new ListCustomersInput().toBuilder()
.q(notExistingOrganization).build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -168,7 +181,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingReference() throws IOExcepti

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, reference);
.listCustomers(new ListCustomersInput().toBuilder()
.q(reference).build()
);

// then
assertThat(listCustomers).hasSize(1);
Expand All @@ -181,7 +196,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingReference() throws IOExcepti

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, notExistingReference);
.listCustomers(new ListCustomersInput().toBuilder()
.q(notExistingReference).build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -194,7 +211,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingFirstName() throws IOExcepti

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, firstName);
.listCustomers(new ListCustomersInput().toBuilder()
.q(firstName).build()
);

// then
assertThat(listCustomers).hasSize(1);
Expand All @@ -207,7 +226,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingFirstName() throws IOExcepti

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, notExistingFirstName);
.listCustomers(new ListCustomersInput().toBuilder()
.q(notExistingFirstName).build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -220,7 +241,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingLastName() throws IOExceptio

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, lastName);
.listCustomers(new ListCustomersInput().toBuilder()
.q(lastName).build()
);

// then
assertThat(listCustomers).hasSize(1);
Expand All @@ -233,7 +256,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingLastName() throws IOExceptio

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, null, null, null, null, null, notExistingLastName);
.listCustomers(new ListCustomersInput().toBuilder()
.q(notExistingLastName).build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -243,11 +268,14 @@ void shouldReturnEmptyListWhenSearchingByNotExistingLastName() throws IOExceptio
void shouldReturnNotEmptyListWhenSearchingByExistingOrganizationAndSortDescDirection() throws IOException, ApiException {
// given
String organization = "Maxio.com";
ListCustomersDirection sortDescDirection = ListCustomersDirection.fromSortingDirection(SortingDirection.DESC);
ListCustomersInputDirection sortDescDirection = ListCustomersInputDirection.fromSortingDirection(SortingDirection.DESC);

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(sortDescDirection, null, null, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.direction(sortDescDirection)
.q(organization).build()
);

// then
assertThat(listCustomers).hasSize(10);
Expand All @@ -258,11 +286,14 @@ void shouldReturnNotEmptyListWhenSearchingByExistingOrganizationAndSortDescDirec
void shouldReturnNotEmptyListWhenSearchingByExistingOrganizationAndSortAscDirection() throws IOException, ApiException {
// given
String organization = "Maxio.com";
ListCustomersDirection sortAscDirection = ListCustomersDirection.fromSortingDirection(SortingDirection.ASC);
ListCustomersInputDirection sortAscDirection = ListCustomersInputDirection.fromSortingDirection(SortingDirection.ASC);

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(sortAscDirection, null, null, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.direction(sortAscDirection)
.q(organization).build()
);

// then
assertThat(listCustomers).hasSize(10);
Expand All @@ -278,23 +309,48 @@ void shouldReturnNotEmptyListWhenSearchingByExistingOrganizationUsingPagination(
// when
// 1st page (default if not provided)
List<CustomerResponse> listCustomersOnPage1 = CUSTOMERS_CONTROLLER
.listCustomers(null, 1, perPage, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.page(1)
.perPage(perPage)
.q(organization)
.build()
);

// 2nd page
List<CustomerResponse> listCustomersOnPage2 = CUSTOMERS_CONTROLLER
.listCustomers(null, 2, perPage, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.page(2)
.perPage(perPage)
.q(organization)
.build()
);

// 3rd page
List<CustomerResponse> listCustomersOnPage3 = CUSTOMERS_CONTROLLER
.listCustomers(null, 3, perPage, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.page(3)
.perPage(perPage)
.q(organization)
.build()
);

// 4th page
List<CustomerResponse> listCustomersOnPage4 = CUSTOMERS_CONTROLLER
.listCustomers(null, 4, perPage, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.page(4)
.perPage(perPage)
.q(organization)
.build()
);

// n-th page
List<CustomerResponse> listCustomersOnPageN = CUSTOMERS_CONTROLLER
.listCustomers(null, 5, perPage, null, null, null, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.page(5)
.perPage(perPage)
.q(organization)
.build()
);

// then
assertThat(listCustomersOnPage1).hasSize(3);
Expand All @@ -314,7 +370,13 @@ void shouldReturnEmptyListWhenSearchingByExistingOrganizationAndCreatedAtNotMatc

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, createdAt, createdAtStartDate, createdAtEndDate, null, null, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.dateField(createdAt)
.startDate(createdAtStartDate)
.endDate(createdAtEndDate)
.q(organization)
.build()
);

// then
assertThat(listCustomers).isEmpty();
Expand All @@ -330,7 +392,13 @@ void shouldReturnEmptyListWhenSearchingByExistingOrganizationAndUpdatedAtNotMatc

// when
List<CustomerResponse> listCustomers = CUSTOMERS_CONTROLLER
.listCustomers(null, null, null, updatedAt, null, null, updatedAtStartDateTime, updatedAtEndDateTime, organization);
.listCustomers(new ListCustomersInput().toBuilder()
.dateField(updatedAt)
.startDate(updatedAtStartDateTime)
.endDate(updatedAtEndDateTime)
.q(organization)
.build()
);

// then
assertThat(listCustomers).isEmpty();
Expand Down

0 comments on commit 75515e8

Please sign in to comment.