From e56ad14e1474dd966e869269ab5f4ba5114d027d Mon Sep 17 00:00:00 2001 From: Michal Pierog Date: Tue, 25 Jun 2024 14:08:17 +0200 Subject: [PATCH] [DE-874] Release 4.0.0 - fixing tests --- ...onentsControllerArchivePricePointTest.java | 27 +++++++++---- ...ntrollerListComponentsPricePointsTest.java | 38 ++++++++++--------- ...mponentsControllerListPricePointsTest.java | 14 +++---- ...trollerPromotePricePointToDefaultTest.java | 8 ++-- .../ComponentsControllerTestBase.java | 2 + ...entsControllerUnarchivePricePointTest.java | 19 ++++++---- ...ponentsControllerUpdatePricePointTest.java | 30 +++++++++++---- ...tomersControllerListSubscriptionsTest.java | 2 +- .../ProductPricePointsBaseTest.java | 2 +- .../ProductsControllerCreateProductTest.java | 12 +++--- .../products/ProductsControllerTestBase.java | 2 +- .../SubscriptionsControllerUpdateTest.java | 4 +- .../advancedbilling/utils/TestSetup.java | 6 +-- 13 files changed, 101 insertions(+), 65 deletions(-) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerArchivePricePointTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerArchivePricePointTest.java index d3cf1cd9..b4d5bee0 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerArchivePricePointTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerArchivePricePointTest.java @@ -4,6 +4,8 @@ import com.maxio.advancedbilling.exceptions.ApiException; import com.maxio.advancedbilling.models.Component; import com.maxio.advancedbilling.models.ComponentPricePoint; +import com.maxio.advancedbilling.models.containers.ArchiveComponentPricePointComponentId; +import com.maxio.advancedbilling.models.containers.ArchiveComponentPricePointPricePointId; import com.maxio.advancedbilling.utils.assertions.CommonAssertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -30,9 +32,10 @@ void shouldArchivePricePoint() throws IOException, ApiException { ComponentPricePoint componentPricePoint = TEST_SETUP.createComponentPricePoint(component.getId()); // when - ComponentPricePoint archivedPricePoint = COMPONENTS_CONTROLLER - .archiveComponentPricePoint(component.getId(), componentPricePoint.getId()) - .getPricePoint(); + ComponentPricePoint archivedPricePoint = COMPONENTS__PRICE_POINT_CONTROLLER.archiveComponentPricePoint( + ArchiveComponentPricePointComponentId.fromNumber(component.getId()), + ArchiveComponentPricePointPricePointId.fromNumber(componentPricePoint.getId()) + ).getPricePoint(); // then assertThat(archivedPricePoint.getArchivedAt()).isNotNull(); @@ -48,20 +51,28 @@ void shouldArchivePricePoint() throws IOException, ApiException { void shouldNotArchiveSamePricePointTwice() throws IOException, ApiException { // given ComponentPricePoint componentPricePoint = TEST_SETUP.createComponentPricePoint(component.getId()); - COMPONENTS_CONTROLLER.archiveComponentPricePoint(component.getId(), componentPricePoint.getId()); + COMPONENTS__PRICE_POINT_CONTROLLER.archiveComponentPricePoint( + ArchiveComponentPricePointComponentId.fromNumber(component.getId()), + ArchiveComponentPricePointPricePointId.fromNumber(componentPricePoint.getId()) + ); // when-then CommonAssertions - .assertThatErrorListResponse(() -> COMPONENTS_CONTROLLER.archiveComponentPricePoint(component.getId(), - componentPricePoint.getId())) + .assertThatErrorListResponse(() -> COMPONENTS__PRICE_POINT_CONTROLLER.archiveComponentPricePoint( + ArchiveComponentPricePointComponentId.fromNumber(component.getId()), + ArchiveComponentPricePointPricePointId.fromNumber(componentPricePoint.getId())) + ) .isUnprocessableEntity() .hasErrors("Price point is already archived."); } @Test void shouldNotArchivePricePointWhenProvidingInvalidCredentials() { - assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentsController() - .archiveComponentPricePoint(component.getId(), component.getDefaultPricePointId())); + assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentPricePointsController() + .archiveComponentPricePoint( + ArchiveComponentPricePointComponentId.fromNumber(component.getId()), + ArchiveComponentPricePointPricePointId.fromNumber(component.getDefaultPricePointId())) + ); } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListComponentsPricePointsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListComponentsPricePointsTest.java index cfd4f9f8..2ecdcd97 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListComponentsPricePointsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListComponentsPricePointsTest.java @@ -10,6 +10,8 @@ import com.maxio.advancedbilling.models.ListComponentsPricePointsInclude; import com.maxio.advancedbilling.models.ListPricePointsFilter; import com.maxio.advancedbilling.models.SortingDirection; +import com.maxio.advancedbilling.models.containers.ArchiveComponentPricePointComponentId; +import com.maxio.advancedbilling.models.containers.ArchiveComponentPricePointPricePointId; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -41,7 +43,10 @@ static void setupComponent() throws IOException, ApiException { component1_PricePoint1 = TEST_SETUP.createComponentPricePoint(component.getId(), b -> b.useSiteExchangeRate(true)); component1_PricePoint2 = TEST_SETUP.createComponentPricePoint(component.getId(), b -> b.useSiteExchangeRate(false)); component1_PricePoint3_Archived = TEST_SETUP.createComponentPricePoint(component.getId()); - COMPONENTS_CONTROLLER.archiveComponentPricePoint(component.getId(), component1_PricePoint3_Archived.getId()); + COMPONENTS__PRICE_POINT_CONTROLLER.archiveComponentPricePoint( + ArchiveComponentPricePointComponentId.fromNumber(component.getId()), + ArchiveComponentPricePointPricePointId.fromNumber(component1_PricePoint3_Archived.getId()) + ); component2_PricePoint1 = TEST_SETUP.createComponentPricePoint(component2.getId()); component2_PricePoint2 = TEST_SETUP.createComponentPricePoint(component2.getId()); @@ -50,20 +55,19 @@ static void setupComponent() throws IOException, ApiException { @Test void shouldListPricePointsWithCurrencyPrices() throws IOException, ApiException { // when - Map componentPricePointMap = COMPONENTS_CONTROLLER.listAllComponentPricePoints( - new ListAllComponentPricePointsInput.Builder() - .filter( - new ListPricePointsFilter.Builder() - .ids(List.of(component1_PricePoint1.getId(), component1_PricePoint2.getId())) - .build() - ) - .include(ListComponentsPricePointsInclude.CURRENCY_PRICES) - .build()) + Map componentPricePointMap = COMPONENTS__PRICE_POINT_CONTROLLER.listAllComponentPricePoints( + new ListAllComponentPricePointsInput.Builder() + .filter( + new ListPricePointsFilter.Builder() + .ids(List.of(component1_PricePoint1.getId(), component1_PricePoint2.getId())) + .build() + ) + .include(ListComponentsPricePointsInclude.CURRENCY_PRICES) + .build()) .getPricePoints() .stream() .collect(Collectors.toMap(ComponentPricePoint::getId, Function.identity())); - // then assertThat(componentPricePointMap.size()).isEqualTo(2); @@ -91,7 +95,7 @@ void shouldListPricePointsWithCurrencyPrices() throws IOException, ApiException @Test void shouldListArchivedPricePoints() throws IOException, ApiException { // when - List componentPricePoints = COMPONENTS_CONTROLLER.listAllComponentPricePoints( + List componentPricePoints = COMPONENTS__PRICE_POINT_CONTROLLER.listAllComponentPricePoints( new ListAllComponentPricePointsInput.Builder() .filter( new ListPricePointsFilter.Builder() @@ -119,7 +123,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { component2_PricePoint1.getId(), component2_PricePoint2.getId()); // when - List responsePage1 = COMPONENTS_CONTROLLER.listAllComponentPricePoints( + List responsePage1 = COMPONENTS__PRICE_POINT_CONTROLLER.listAllComponentPricePoints( new ListAllComponentPricePointsInput.Builder() .filter(new ListPricePointsFilter.Builder().ids(allIds).build()) .page(1) @@ -132,7 +136,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder(component1_PricePoint1, component1_PricePoint2); - List responsePage2 = COMPONENTS_CONTROLLER.listAllComponentPricePoints( + List responsePage2 = COMPONENTS__PRICE_POINT_CONTROLLER.listAllComponentPricePoints( new ListAllComponentPricePointsInput.Builder() .filter(new ListPricePointsFilter.Builder().ids(allIds).build()) .page(2) @@ -145,7 +149,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { .usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrder(component2_PricePoint1, component2_PricePoint2); - List responsePage3 = COMPONENTS_CONTROLLER.listAllComponentPricePoints( + List responsePage3 = COMPONENTS__PRICE_POINT_CONTROLLER.listAllComponentPricePoints( new ListAllComponentPricePointsInput.Builder() .filter(new ListPricePointsFilter.Builder().ids(allIds).build()) .page(3) @@ -155,7 +159,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { assertThat(responsePage3).isEmpty(); - List responsePageDesc = COMPONENTS_CONTROLLER.listAllComponentPricePoints( + List responsePageDesc = COMPONENTS__PRICE_POINT_CONTROLLER.listAllComponentPricePoints( new ListAllComponentPricePointsInput.Builder() .filter(new ListPricePointsFilter.Builder().ids(allIds).build()) .page(1) @@ -172,7 +176,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { @Test void shouldNotListComponentsPricePointsWhenProvidingInvalidCredentials() { - assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentsController() + assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentPricePointsController() .listAllComponentPricePoints(new ListAllComponentPricePointsInput())); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListPricePointsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListPricePointsTest.java index 974a2a43..5bc8d186 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListPricePointsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerListPricePointsTest.java @@ -51,7 +51,7 @@ static void setupComponent() throws IOException, ApiException { ) ); - componentPricePoint2CurrencyPrices = COMPONENTS_CONTROLLER + componentPricePoint2CurrencyPrices = COMPONENTS__PRICE_POINT_CONTROLLER .createCurrencyPrices(componentPricePoint2.getId(), createCurrencyPricesRequest) .getCurrencyPrices(); } @@ -59,7 +59,7 @@ static void setupComponent() throws IOException, ApiException { @Test void shouldListPricePointsWithCurrencyPrices() throws IOException, ApiException { // when - ComponentPricePointsResponse response = COMPONENTS_CONTROLLER.listComponentPricePoints( + ComponentPricePointsResponse response = COMPONENTS__PRICE_POINT_CONTROLLER.listComponentPricePoints( new ListComponentPricePointsInput.Builder() .componentId(component.getId()) .currencyPrices(true) @@ -124,7 +124,7 @@ void shouldListPricePointsWithCurrencyPrices() throws IOException, ApiException @Test void shouldListPricePointsWithPagination() throws IOException, ApiException { // when-then - ComponentPricePointsResponse responsePage1 = COMPONENTS_CONTROLLER.listComponentPricePoints( + ComponentPricePointsResponse responsePage1 = COMPONENTS__PRICE_POINT_CONTROLLER.listComponentPricePoints( new ListComponentPricePointsInput.Builder() .componentId(component.getId()) .page(1) @@ -137,7 +137,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { assertThat(responsePage1.getMeta().getTotalPages()).isEqualTo(2); assertThat(responsePage1.getMeta().getPerPage()).isEqualTo(2); - ComponentPricePointsResponse responsePage2 = COMPONENTS_CONTROLLER.listComponentPricePoints( + ComponentPricePointsResponse responsePage2 = COMPONENTS__PRICE_POINT_CONTROLLER.listComponentPricePoints( new ListComponentPricePointsInput.Builder() .componentId(component.getId()) .page(2) @@ -154,7 +154,7 @@ void shouldListPricePointsWithPagination() throws IOException, ApiException { @Test void shouldListPricePointsWithTypeFilters() throws IOException, ApiException { // when-then - ComponentPricePointsResponse defaultPricePoints = COMPONENTS_CONTROLLER.listComponentPricePoints( + ComponentPricePointsResponse defaultPricePoints = COMPONENTS__PRICE_POINT_CONTROLLER.listComponentPricePoints( new ListComponentPricePointsInput.Builder() .componentId(component.getId()) .filterType(List.of(PricePointType.ENUM_DEFAULT)) @@ -163,7 +163,7 @@ void shouldListPricePointsWithTypeFilters() throws IOException, ApiException { assertThat(defaultPricePoints.getPricePoints().size()).isEqualTo(1); assertThat(defaultPricePoints.getPricePoints().get(0).getType()).isEqualTo(PricePointType.ENUM_DEFAULT); - ComponentPricePointsResponse catalogPricePoints = COMPONENTS_CONTROLLER.listComponentPricePoints( + ComponentPricePointsResponse catalogPricePoints = COMPONENTS__PRICE_POINT_CONTROLLER.listComponentPricePoints( new ListComponentPricePointsInput.Builder() .componentId(component.getId()) .filterType(List.of(PricePointType.CATALOG)) @@ -176,7 +176,7 @@ void shouldListPricePointsWithTypeFilters() throws IOException, ApiException { @Test void shouldNotListPricePointsWhenProvidingInvalidCredentials() { - assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentsController() + assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentPricePointsController() .listComponentPricePoints(new ListComponentPricePointsInput())); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerPromotePricePointToDefaultTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerPromotePricePointToDefaultTest.java index d5a6dccd..1bb96eda 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerPromotePricePointToDefaultTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerPromotePricePointToDefaultTest.java @@ -31,7 +31,7 @@ void shouldPromoteComponentPricePointToDefault() throws IOException, ApiExceptio ComponentPricePoint catalogPricePoint = createCatalogPricePoint(component.getId()); // when - Component componentWithUpdatedPricePoint = COMPONENTS_CONTROLLER + Component componentWithUpdatedPricePoint = COMPONENTS__PRICE_POINT_CONTROLLER .promoteComponentPricePointToDefault( component.getId(), catalogPricePoint.getId() @@ -59,7 +59,7 @@ void shouldNotPromoteComponentPricePointToDefaultUsingNotExistentPricePoint() th Component component = createQuantityBasedComponent(); // when - then - new ApiExceptionAssert(() -> COMPONENTS_CONTROLLER.promoteComponentPricePointToDefault(component.getId(), 3)) + new ApiExceptionAssert(() -> COMPONENTS__PRICE_POINT_CONTROLLER.promoteComponentPricePointToDefault(component.getId(), 3)) .isUnprocessableEntity(); } @@ -70,7 +70,7 @@ void shouldNotPromoteComponentPricePointToDefaultWhenProvidingInvalidCredentials ComponentPricePoint catalogPricePoint = createCatalogPricePoint(component.getId()); // when - then - assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentsController() + assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentPricePointsController() .promoteComponentPricePointToDefault(component.getId(), catalogPricePoint.getId()) ); } @@ -91,7 +91,7 @@ private ComponentPricePoint createCatalogPricePoint(int componentId) throws IOEx ) .build(); - return COMPONENTS_CONTROLLER + return COMPONENTS__PRICE_POINT_CONTROLLER .createComponentPricePoint(componentId, new CreateComponentPricePointRequest( CreateComponentPricePointRequestPricePoint diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerTestBase.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerTestBase.java index af82c818..9ba61d7f 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerTestBase.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerTestBase.java @@ -1,6 +1,7 @@ package com.maxio.advancedbilling.controllers.components; import com.maxio.advancedbilling.TestClient; +import com.maxio.advancedbilling.controllers.ComponentPricePointsController; import com.maxio.advancedbilling.controllers.ComponentsController; import com.maxio.advancedbilling.exceptions.ApiException; import com.maxio.advancedbilling.models.Component; @@ -13,6 +14,7 @@ public class ComponentsControllerTestBase { protected static final ComponentsController COMPONENTS_CONTROLLER = TestClient.createClient().getComponentsController(); + protected static final ComponentPricePointsController COMPONENTS__PRICE_POINT_CONTROLLER = TestClient.createClient().getComponentPricePointsController(); protected static ProductFamily productFamily; protected static int productFamilyId; protected static final TestSetup TEST_SETUP = new TestSetup(); diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUnarchivePricePointTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUnarchivePricePointTest.java index 376758e9..a8e338df 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUnarchivePricePointTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUnarchivePricePointTest.java @@ -4,6 +4,8 @@ import com.maxio.advancedbilling.exceptions.ApiException; import com.maxio.advancedbilling.models.Component; import com.maxio.advancedbilling.models.ComponentPricePoint; +import com.maxio.advancedbilling.models.containers.ArchiveComponentPricePointComponentId; +import com.maxio.advancedbilling.models.containers.ArchiveComponentPricePointPricePointId; import com.maxio.advancedbilling.utils.assertions.CommonAssertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -29,9 +31,12 @@ void shouldUnarchivePricePoint() throws IOException, ApiException { ComponentPricePoint componentPricePoint = TEST_SETUP.createComponentPricePoint(component.getId()); // when - COMPONENTS_CONTROLLER - .archiveComponentPricePoint(component.getId(), componentPricePoint.getId()); - ComponentPricePoint unarchivedPricePoint = COMPONENTS_CONTROLLER + COMPONENTS__PRICE_POINT_CONTROLLER + .archiveComponentPricePoint( + ArchiveComponentPricePointComponentId.fromNumber(component.getId()), + ArchiveComponentPricePointPricePointId.fromNumber(componentPricePoint.getId()) + ); + ComponentPricePoint unarchivedPricePoint = COMPONENTS__PRICE_POINT_CONTROLLER .unarchiveComponentPricePoint(component.getId(), componentPricePoint.getId()) .getPricePoint(); @@ -52,26 +57,26 @@ void shouldNotUnarchiveNonArchivedPricePoint() throws IOException, ApiException // when-then CommonAssertions .assertUnprocessableEntity(ApiException.class, - () -> COMPONENTS_CONTROLLER.unarchiveComponentPricePoint(component.getId(), + () -> COMPONENTS__PRICE_POINT_CONTROLLER.unarchiveComponentPricePoint(component.getId(), componentPricePoint.getId())); } @Test void shouldNotUnarchivePricePointWhenComponentDoesNotExist() { // when - then - assertNotFound(() -> COMPONENTS_CONTROLLER + assertNotFound(() -> COMPONENTS__PRICE_POINT_CONTROLLER .unarchiveComponentPricePoint(123, component.getDefaultPricePointId())); } @Test void shouldNotUnarchiveNonExistentPricePoints() { // when - then - assertNotFound(() -> COMPONENTS_CONTROLLER.unarchiveComponentPricePoint(component.getId(), 123)); + assertNotFound(() -> COMPONENTS__PRICE_POINT_CONTROLLER.unarchiveComponentPricePoint(component.getId(), 123)); } @Test void shouldNotArchivePricePointWhenProvidingInvalidCredentials() { - assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentsController() + assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentPricePointsController() .unarchiveComponentPricePoint(component.getId(), component.getDefaultPricePointId())); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUpdatePricePointTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUpdatePricePointTest.java index e2b40cf9..3ba4f9a5 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUpdatePricePointTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/components/ComponentsControllerUpdatePricePointTest.java @@ -10,6 +10,8 @@ import com.maxio.advancedbilling.models.UpdateComponentPricePoint; import com.maxio.advancedbilling.models.UpdateComponentPricePointRequest; import com.maxio.advancedbilling.models.UpdatePrice; +import com.maxio.advancedbilling.models.containers.UpdateComponentPricePointComponentId; +import com.maxio.advancedbilling.models.containers.UpdateComponentPricePointPricePointId; import com.maxio.advancedbilling.models.containers.UpdatePriceStartingQuantity; import com.maxio.advancedbilling.models.containers.UpdatePriceUnitPrice; import org.junit.jupiter.api.BeforeAll; @@ -70,8 +72,10 @@ void shouldUpdateComponentPricePoint() throws IOException, ApiException { .build(); // when - ComponentPricePoint updatedPricePoint = COMPONENTS_CONTROLLER - .updateComponentPricePoint(component.getId(), componentPricePoint.getId(), + ComponentPricePoint updatedPricePoint = COMPONENTS__PRICE_POINT_CONTROLLER + .updateComponentPricePoint( + UpdateComponentPricePointComponentId.fromNumber(component.getId()), + UpdateComponentPricePointPricePointId.fromNumber(componentPricePoint.getId()), new UpdateComponentPricePointRequest(updateComponentPricePoint) ) .getPricePoint(); @@ -114,7 +118,11 @@ void shouldReturn422WhenUpdatingComponentPricePointWithInvalidData(UpdateCompone // when - then assertUnprocessableEntity( ErrorArrayMapResponseException.class, - () -> COMPONENTS_CONTROLLER.updateComponentPricePoint(component2.getId(), component2.getDefaultPricePointId(), request), + () -> COMPONENTS__PRICE_POINT_CONTROLLER.updateComponentPricePoint( + UpdateComponentPricePointComponentId.fromNumber(component2.getId()), + UpdateComponentPricePointPricePointId.fromNumber(component2.getDefaultPricePointId()), + request + ), e -> assertThat(e.getErrors()).containsExactlyInAnyOrderEntriesOf(expectedErrors) ); } @@ -145,20 +153,26 @@ private static Stream argsForShouldReturn422WhenUpdatingComponentPric void shouldNotUpdatePricePointWhenComponentAndPricePointDontExist() { assertUnprocessableEntity( ErrorArrayMapResponseException.class, - () -> COMPONENTS_CONTROLLER.updateComponentPricePoint(123, 123, + () -> COMPONENTS__PRICE_POINT_CONTROLLER.updateComponentPricePoint( + UpdateComponentPricePointComponentId.fromNumber(123), + UpdateComponentPricePointPricePointId.fromNumber(123), new UpdateComponentPricePointRequest(new UpdateComponentPricePoint.Builder().name("abc").build())), e -> assertThat(e.getErrors()).containsExactlyEntriesOf( Map.of("base", List.of( "component must be a valid component", "price_point must be a valid price_point") - ) - )); + ) + )); } @Test void shouldNotUpdateComponentPricePointWhenProvidingInvalidCredentials() { - assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentsController() - .updateComponentPricePoint(component.getId(), component.getDefaultPricePointId(), new UpdateComponentPricePointRequest())); + assertUnauthorized(() -> TestClient.createInvalidCredentialsClient().getComponentPricePointsController() + .updateComponentPricePoint( + UpdateComponentPricePointComponentId.fromNumber(component.getId()), + UpdateComponentPricePointPricePointId.fromNumber(component.getDefaultPricePointId()), + new UpdateComponentPricePointRequest()) + ); } } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/customers/CustomersControllerListSubscriptionsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/customers/CustomersControllerListSubscriptionsTest.java index 58c38c59..d8b009cd 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/customers/CustomersControllerListSubscriptionsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/customers/CustomersControllerListSubscriptionsTest.java @@ -111,7 +111,7 @@ void shouldReturnListOfSubscriptionsForCustomer() throws IOException, ApiExcepti Product product = productsController .createProduct( - productFamily.getId(), + String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest(new CreateOrUpdateProduct.Builder() .name("Test Product " + randomNumeric(10)) .handle("test-product-" + randomNumeric(10)) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsBaseTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsBaseTest.java index 561f687a..76f0a6cf 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsBaseTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsBaseTest.java @@ -57,7 +57,7 @@ static void setupProductFamily() throws IOException, ApiException { protected static Product createProduct() throws IOException, ApiException { return PRODUCTS_CONTROLLER .createProduct( - productFamily.getId(), + String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest(new CreateOrUpdateProduct.Builder() .name("product-name-%s".formatted(randomNumeric(10))) .handle("product-handle-%s".formatted(randomNumeric(10))) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerCreateProductTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerCreateProductTest.java index 229d999c..1a5038dc 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerCreateProductTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerCreateProductTest.java @@ -28,7 +28,7 @@ void shouldCreateProductWhenOnlyRequiredParametersAreProvided() throws IOExcepti ZonedDateTime timestamp = ZonedDateTime.now().minusSeconds(5); String handle = "washington-" + RandomStringUtils.randomAlphanumeric(5).toLowerCase(); Product product = productsController - .createProduct(productFamily.getId(), new CreateOrUpdateProductRequest( + .createProduct(String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest( new CreateOrUpdateProduct.Builder() .name("Sample product") .handle(handle) @@ -100,7 +100,7 @@ void shouldCreateProductWhenAllParametersAreProvided() throws IOException, ApiEx ZonedDateTime timestamp = ZonedDateTime.now().minusSeconds(5); String handle = "washington-" + RandomStringUtils.randomAlphanumeric(5).toLowerCase(); Product product = productsController - .createProduct(productFamily.getId(), new CreateOrUpdateProductRequest( + .createProduct(String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest( new CreateOrUpdateProduct.Builder() .name("Sample product full") .handle(handle) @@ -183,12 +183,12 @@ void shouldNotCreateProductWithExistingHandle() throws IOException, ApiException .interval(1) .intervalUnit(IntervalUnit.MONTH) .build(); - productsController.createProduct(productFamily.getId(), new CreateOrUpdateProductRequest(createOrUpdateProduct)); + productsController.createProduct(String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest(createOrUpdateProduct)); // then CommonAssertions .assertThatErrorListResponse(() -> productsController - .createProduct(productFamily.getId(), new CreateOrUpdateProductRequest(createOrUpdateProduct)) + .createProduct(String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest(createOrUpdateProduct)) ) .isUnprocessableEntity() .hasErrors("API Handle: must be unique - '%s' has been taken by another Product in this Site.".formatted(handle)); @@ -200,7 +200,7 @@ void shouldNotCreateProductWhenBasicParametersAreBlank(CreateOrUpdateProduct cre // when - then CommonAssertions .assertThatErrorListResponse(() -> productsController.createProduct( - productFamily.getId(), new CreateOrUpdateProductRequest(createProduct)) + String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest(createProduct)) ) .isUnprocessableEntity() .hasErrors(errorMessages); @@ -254,7 +254,7 @@ void shouldNotCreateProductForNotOwnedProductFamily() { // when - then new ApiExceptionAssert<>(() -> productsController - .createProduct(999999, new CreateOrUpdateProductRequest(createOrUpdateProduct))) + .createProduct("999999", new CreateOrUpdateProductRequest(createOrUpdateProduct))) .hasErrorCode(403) .hasMessageStartingWithHttpNotOk(); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerTestBase.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerTestBase.java index 43e53596..48242c52 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerTestBase.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerTestBase.java @@ -32,7 +32,7 @@ protected Product createProduct() throws IOException, ApiException { protected static Product createProductWithHandle(String handle) throws IOException, ApiException { return productsController - .createProduct(productFamily.getId(), new CreateOrUpdateProductRequest( + .createProduct(String.valueOf(productFamily.getId()), new CreateOrUpdateProductRequest( new CreateOrUpdateProduct.Builder() .name("Initial Sample product-" + RandomStringUtils.randomAlphanumeric(5)) .handle(handle) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java index b1f5a019..893e6a70 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/subscriptions/SubscriptionsControllerUpdateTest.java @@ -157,7 +157,7 @@ void shouldUpdateComponentAndCustomPricing() throws IOException, ApiException { PricePointType pricePointType2 = subscriptionComponent2.getPricePointType(); assertThat(pricePointType2).isEqualTo(PricePointType.ENUM_DEFAULT); - ComponentPricePointsResponse customPricePoint1 = CLIENT.getComponentsController().listComponentPricePoints(new ListComponentPricePointsInput.Builder() + ComponentPricePointsResponse customPricePoint1 = CLIENT.getComponentPricePointsController().listComponentPricePoints(new ListComponentPricePointsInput.Builder() .filterType(List.of(PricePointType.CUSTOM)).componentId(component1.getId()).build()); assertThat(customPricePoint1.getPricePoints()) .isNotNull() @@ -184,7 +184,7 @@ void shouldUpdateComponentAndCustomPricing() throws IOException, ApiException { .build() ); - ComponentPricePointsResponse customPricePoint2 = CLIENT.getComponentsController().listComponentPricePoints(new ListComponentPricePointsInput.Builder() + ComponentPricePointsResponse customPricePoint2 = CLIENT.getComponentPricePointsController().listComponentPricePoints(new ListComponentPricePointsInput.Builder() .filterType(List.of(PricePointType.CUSTOM)).componentId(component2.getId()).build()); assertThat(customPricePoint2.getPricePoints()) .isNotNull() diff --git a/tests/src/test/java/com/maxio/advancedbilling/utils/TestSetup.java b/tests/src/test/java/com/maxio/advancedbilling/utils/TestSetup.java index 6d511638..493d47e7 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/utils/TestSetup.java +++ b/tests/src/test/java/com/maxio/advancedbilling/utils/TestSetup.java @@ -118,7 +118,7 @@ public Product createProduct(ProductFamily productFamily, Consumer