From b435679f713a88a69b0073863a30c2a1f161f869 Mon Sep 17 00:00:00 2001 From: Maciej Nedza Date: Mon, 4 Dec 2023 13:52:02 +0100 Subject: [PATCH] [DE-613] Fix product price points tests --- .../ProductPricePointsBaseTest.java | 9 ++++++--- ...roductPricePointsControllerCreateTest.java | 4 +++- ...oductPricePointsControllerListAllTest.java | 11 ++++++++-- .../ProductPricePointsControllerListTest.java | 20 +++++++++++-------- .../ProductsControllerListProductsTest.java | 4 +++- .../ProductsControllerUpdateProductTest.java | 1 - 6 files changed, 33 insertions(+), 16 deletions(-) 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 37eb1ec6..991b36a1 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 @@ -20,6 +20,9 @@ import com.maxio.advancedbilling.models.ProductPricePoint; import com.maxio.advancedbilling.models.ProductPricePointResponse; import com.maxio.advancedbilling.models.ProductResponse; +import com.maxio.advancedbilling.models.containers.ArchiveProductPricePointPricePointId; +import com.maxio.advancedbilling.models.containers.ArchiveProductPricePointProductId; +import com.maxio.advancedbilling.models.containers.CreateProductPricePointProductId; import org.junit.jupiter.api.BeforeAll; import java.io.IOException; @@ -81,7 +84,7 @@ protected static ProductPricePointResponse createProductPricePointWithDelay(long } return PRODUCT_PRICE_POINTS_CONTROLLER - .createProductPricePoint(productId, new CreateProductPricePointRequest(createProductPricePoint)); + .createProductPricePoint(CreateProductPricePointProductId.fromNumber(productId), new CreateProductPricePointRequest(createProductPricePoint)); } protected static CreateProductPricePoint.Builder defaultBuilder() { @@ -105,8 +108,8 @@ protected static void archiveAllSitePricePointsExcludingDefault() throws IOExcep while (!sitePricePointsExcludingDefault.isEmpty()) { for (ProductPricePoint pricePoint : sitePricePointsExcludingDefault) { PRODUCT_PRICE_POINTS_CONTROLLER.archiveProductPricePoint( - pricePoint.getProductId(), - pricePoint.getId() + ArchiveProductPricePointProductId.fromNumber(pricePoint.getProductId()), + ArchiveProductPricePointPricePointId.fromNumber(pricePoint.getId()) ); } sitePricePointsExcludingDefault = listAllSitePricePointsPerPage200ExcludingDefault(); diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerCreateTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerCreateTest.java index aa8ff607..b0d618b7 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerCreateTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerCreateTest.java @@ -9,6 +9,7 @@ import com.maxio.advancedbilling.models.Product; import com.maxio.advancedbilling.models.ProductPricePoint; import com.maxio.advancedbilling.models.ProductPricePointErrors; +import com.maxio.advancedbilling.models.containers.CreateProductPricePointProductId; import com.maxio.advancedbilling.utils.CommonAssertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -112,7 +113,8 @@ void shouldReturn422WhenPricePointRequestIsEmpty() { void shouldReturn422WhenRequiredParametersAreMissing(CreateProductPricePointRequest request, ProductPricePointErrors expectedErrors) { // when - then assertThatExceptionOfType(ProductPricePointErrorResponseException.class) - .isThrownBy(() -> PRODUCT_PRICE_POINTS_CONTROLLER.createProductPricePoint(product.getId(), request)) + .isThrownBy(() -> PRODUCT_PRICE_POINTS_CONTROLLER + .createProductPricePoint(CreateProductPricePointProductId.fromNumber(product.getId()), request)) .withMessage("Unprocessable Entity (WebDAV)") .satisfies(e -> { assertThat(e.getResponseCode()).isEqualTo(422); diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListAllTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListAllTest.java index f85799de..a8e2d5de 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListAllTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListAllTest.java @@ -9,6 +9,8 @@ import com.maxio.advancedbilling.models.Product; import com.maxio.advancedbilling.models.ProductPricePoint; import com.maxio.advancedbilling.models.SortingDirection; +import com.maxio.advancedbilling.models.containers.ArchiveProductPricePointPricePointId; +import com.maxio.advancedbilling.models.containers.ArchiveProductPricePointProductId; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -46,8 +48,13 @@ static void beforeAll() throws IOException, ApiException { } archivedProductPricePoint = PRODUCT_PRICE_POINTS_CONTROLLER.archiveProductPricePoint( - product.getId(), - createProductPricePoint(product.getId(), defaultBuilder().name("archived-test-price-point-%s".formatted(randomAlphabetic(5))).build()).getPricePoint().getId() + ArchiveProductPricePointProductId.fromNumber(product.getId()), + ArchiveProductPricePointPricePointId.fromNumber( + createProductPricePoint(product.getId(), + defaultBuilder() + .name("archived-test-price-point-%s".formatted(randomAlphabetic(5))) + .build()).getPricePoint().getId() + ) ) .getPricePoint(); } diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListTest.java index 6d6fc2b5..cadab8a4 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/productpricepoints/ProductPricePointsControllerListTest.java @@ -6,6 +6,7 @@ import com.maxio.advancedbilling.models.PricePointType; import com.maxio.advancedbilling.models.Product; import com.maxio.advancedbilling.models.ProductPricePoint; +import com.maxio.advancedbilling.models.containers.ListProductPricePointsInputProductId; import com.maxio.advancedbilling.utils.CommonAssertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,7 +32,8 @@ void beforeEach() throws IOException, ApiException { void shouldReturn404WhenProductNotExists() { // when - then CommonAssertions.assertNotFound(() -> PRODUCT_PRICE_POINTS_CONTROLLER - .listProductPricePoints(new ListProductPricePointsInput.Builder(12345).build()) + .listProductPricePoints(new ListProductPricePointsInput + .Builder(ListProductPricePointsInputProductId.fromNumber(12345)).build()) ); } @@ -39,7 +41,8 @@ void shouldReturn404WhenProductNotExists() { void shouldReturnListWithOriginalPricePointOnly() throws IOException, ApiException { // when List productPricePoints = PRODUCT_PRICE_POINTS_CONTROLLER - .listProductPricePoints(new ListProductPricePointsInput.Builder(product.getId()).build()) + .listProductPricePoints(new ListProductPricePointsInput + .Builder(ListProductPricePointsInputProductId.fromNumber(product.getId())).build()) .getPricePoints(); // then @@ -83,7 +86,8 @@ void shouldReturnListWithAllPricePoints() throws IOException, ApiException { // when List productPricePoints = PRODUCT_PRICE_POINTS_CONTROLLER - .listProductPricePoints(new ListProductPricePointsInput.Builder(product.getId()).build()) + .listProductPricePoints(new ListProductPricePointsInput + .Builder(ListProductPricePointsInputProductId.fromNumber(product.getId())).build()) .getPricePoints(); // then @@ -106,7 +110,7 @@ void shouldReturnListWithPagedPricePoints() throws IOException, ApiException { // when List productPricePointsPage1 = PRODUCT_PRICE_POINTS_CONTROLLER .listProductPricePoints(new ListProductPricePointsInput.Builder() - .productId(product.getId()) + .productId(ListProductPricePointsInputProductId.fromNumber(product.getId())) .page(1) .perPage(2) .build() @@ -114,7 +118,7 @@ void shouldReturnListWithPagedPricePoints() throws IOException, ApiException { .getPricePoints(); List productPricePointsPage2 = PRODUCT_PRICE_POINTS_CONTROLLER .listProductPricePoints(new ListProductPricePointsInput.Builder() - .productId(product.getId()) + .productId(ListProductPricePointsInputProductId.fromNumber(product.getId())) .page(2) .perPage(2) .build() @@ -122,7 +126,7 @@ void shouldReturnListWithPagedPricePoints() throws IOException, ApiException { .getPricePoints(); List productPricePointsPage3 = PRODUCT_PRICE_POINTS_CONTROLLER .listProductPricePoints(new ListProductPricePointsInput.Builder() - .productId(product.getId()) + .productId(ListProductPricePointsInputProductId.fromNumber(product.getId())) .page(3) .perPage(2) .build() @@ -146,7 +150,7 @@ void shouldReturnListUsingTypeFilter() throws IOException, ApiException { // when - then List pricePointsOfDefaultType = PRODUCT_PRICE_POINTS_CONTROLLER .listProductPricePoints(new ListProductPricePointsInput.Builder() - .productId(product.getId()) + .productId(ListProductPricePointsInputProductId.fromNumber(product.getId())) .filterType(Collections.singletonList(PricePointType.ENUM_DEFAULT)) .build() ) @@ -158,7 +162,7 @@ void shouldReturnListUsingTypeFilter() throws IOException, ApiException { List pricePointsOfCatalogType = PRODUCT_PRICE_POINTS_CONTROLLER .listProductPricePoints(new ListProductPricePointsInput.Builder() - .productId(product.getId()) + .productId(ListProductPricePointsInputProductId.fromNumber(product.getId())) .filterType(Collections.singletonList(PricePointType.CATALOG)) .build() ) diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerListProductsTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerListProductsTest.java index 8b43d927..bb108ea1 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerListProductsTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerListProductsTest.java @@ -10,6 +10,7 @@ import com.maxio.advancedbilling.models.Product; import com.maxio.advancedbilling.models.ProductPricePoint; import com.maxio.advancedbilling.models.ProductResponse; +import com.maxio.advancedbilling.models.containers.CreateProductPricePointProductId; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -42,7 +43,8 @@ static void setupProducts() throws IOException, ApiException { .priceInCents(22).name("Price point to promote").build() ); ProductPricePoint pricePoint = productPricePointsController - .createProductPricePoint(productWithChangedPricePoint.getId(), createProductPricePointRequest) + .createProductPricePoint(CreateProductPricePointProductId.fromNumber(productWithChangedPricePoint.getId()), + createProductPricePointRequest) .getPricePoint(); productPricePointsController.promoteProductPricePointToDefault(productWithChangedPricePoint.getId(), pricePoint.getId()); productWithChangedPricePoint = productsController.readProduct(productWithChangedPricePoint.getId()).getProduct(); diff --git a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerUpdateProductTest.java b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerUpdateProductTest.java index d30f4ceb..6fc2c5db 100644 --- a/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerUpdateProductTest.java +++ b/tests/src/test/java/com/maxio/advancedbilling/controllers/products/ProductsControllerUpdateProductTest.java @@ -12,7 +12,6 @@ import org.junit.jupiter.params.provider.MethodSource; import java.io.IOException; -import java.time.Instant; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.Collections;