From d1ede48c0d3ce2bd92ca43c94ffdcf8b4f8c530d Mon Sep 17 00:00:00 2001 From: Maciej Nedza Date: Wed, 16 Oct 2024 13:31:38 +0200 Subject: [PATCH] [DE-953] Test listing products filtering by ids --- .../ProductsControllerListProductsTest.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 a6e6bc08..0db36714 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 @@ -63,6 +63,22 @@ void shouldListProducts() throws IOException, ApiException { .isEqualTo(savedProducts); } + @Test + void shouldListProductsFilteringByIds() throws IOException, ApiException { + // when + List productList = productsController.listProducts( + new ListProductsInput.Builder().filter( + new ListProductsFilter.Builder() + .ids(List.of(savedProducts.get(0).getId(), savedProducts.get(2).getId())) + .build() + ).build() + ).stream().map(ProductResponse::getProduct).toList(); + + // then + assertThat(productList).usingRecursiveFieldByFieldElementComparatorIgnoringFields("updatedAt") + .isEqualTo(List.of(savedProducts.get(0), savedProducts.get(2))); + } + @Test void shouldListProductsFilteringByStartDate() throws IOException, ApiException { // given @@ -101,7 +117,6 @@ void shouldListProductsFilteringByEndDate() throws IOException, ApiException { assertThat(productList1.stream().map(ProductResponse::getProduct).toList()) .usingRecursiveFieldByFieldElementComparatorIgnoringFields("updatedAt").isEqualTo(savedProducts); assertThat(productList2).isEmpty(); - } @Test