From 75515e8f5c124f04f97ed2684830ac181d59f6f2 Mon Sep 17 00:00:00 2001 From: Maciej Nedza Date: Tue, 7 Nov 2023 17:22:11 +0100 Subject: [PATCH] Fix tests after SDK parameters updated --- .../CustomersControllerListOrFindTest.java | 116 ++++++++++++++---- 1 file changed, 92 insertions(+), 24 deletions(-) diff --git a/src/test/java/com/maxio/advancedbilling/controllers/CustomersControllerListOrFindTest.java b/src/test/java/com/maxio/advancedbilling/controllers/CustomersControllerListOrFindTest.java index 038b2db9..cc8c7b87 100644 --- a/src/test/java/com/maxio/advancedbilling/controllers/CustomersControllerListOrFindTest.java +++ b/src/test/java/com/maxio/advancedbilling/controllers/CustomersControllerListOrFindTest.java @@ -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; @@ -58,7 +59,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingEmail() throws IOException, // when List 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); @@ -103,7 +106,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingEmail() throws IOException, // when List listCustomers = CUSTOMERS_CONTROLLER - .listCustomers(null, null, null, null, null, null, null, null, notExistingEmail); + .listCustomers(new ListCustomersInput().toBuilder() + .q(notExistingEmail).build() + ); // then assertThat(listCustomers).isEmpty(); @@ -116,7 +121,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingChargifyID() throws IOExcept // when List 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); @@ -129,7 +136,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingChargifyID() throws IOExcept // when List listCustomers = CUSTOMERS_CONTROLLER - .listCustomers(null, null, null, null, null, null, null, null, notExistingChargifyId); + .listCustomers(new ListCustomersInput().toBuilder() + .q(notExistingChargifyId).build() + ); // then assertThat(listCustomers).isEmpty(); @@ -142,7 +151,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingOrganization() throws IOExce // when List 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); @@ -155,7 +166,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingOrganization() throws IOExce // when List listCustomers = CUSTOMERS_CONTROLLER - .listCustomers(null, null, null, null, null, null, null, null, notExistingOrganization); + .listCustomers(new ListCustomersInput().toBuilder() + .q(notExistingOrganization).build() + ); // then assertThat(listCustomers).isEmpty(); @@ -168,7 +181,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingReference() throws IOExcepti // when List 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); @@ -181,7 +196,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingReference() throws IOExcepti // when List listCustomers = CUSTOMERS_CONTROLLER - .listCustomers(null, null, null, null, null, null, null, null, notExistingReference); + .listCustomers(new ListCustomersInput().toBuilder() + .q(notExistingReference).build() + ); // then assertThat(listCustomers).isEmpty(); @@ -194,7 +211,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingFirstName() throws IOExcepti // when List 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); @@ -207,7 +226,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingFirstName() throws IOExcepti // when List listCustomers = CUSTOMERS_CONTROLLER - .listCustomers(null, null, null, null, null, null, null, null, notExistingFirstName); + .listCustomers(new ListCustomersInput().toBuilder() + .q(notExistingFirstName).build() + ); // then assertThat(listCustomers).isEmpty(); @@ -220,7 +241,9 @@ void shouldReturnNotEmptyListWhenSearchingByExistingLastName() throws IOExceptio // when List 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); @@ -233,7 +256,9 @@ void shouldReturnEmptyListWhenSearchingByNotExistingLastName() throws IOExceptio // when List listCustomers = CUSTOMERS_CONTROLLER - .listCustomers(null, null, null, null, null, null, null, null, notExistingLastName); + .listCustomers(new ListCustomersInput().toBuilder() + .q(notExistingLastName).build() + ); // then assertThat(listCustomers).isEmpty(); @@ -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 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); @@ -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 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); @@ -278,23 +309,48 @@ void shouldReturnNotEmptyListWhenSearchingByExistingOrganizationUsingPagination( // when // 1st page (default if not provided) List 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 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 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 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 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); @@ -314,7 +370,13 @@ void shouldReturnEmptyListWhenSearchingByExistingOrganizationAndCreatedAtNotMatc // when List 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(); @@ -330,7 +392,13 @@ void shouldReturnEmptyListWhenSearchingByExistingOrganizationAndUpdatedAtNotMatc // when List 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();