From 6ddeb0ad3bf9f2561309cbf5bf30f092eddb9f97 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Sat, 2 Sep 2023 08:57:41 +0000 Subject: [PATCH] feat: adds negative test case --- .../web/controllers/ProductControllerIT.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/catalog-service/src/test/java/com/example/catalogservice/web/controllers/ProductControllerIT.java b/catalog-service/src/test/java/com/example/catalogservice/web/controllers/ProductControllerIT.java index 754f380c..5f754328 100644 --- a/catalog-service/src/test/java/com/example/catalogservice/web/controllers/ProductControllerIT.java +++ b/catalog-service/src/test/java/com/example/catalogservice/web/controllers/ProductControllerIT.java @@ -267,6 +267,27 @@ void productsShouldExistsByProductCodes() { .isEqualTo(Boolean.TRUE); } + @Test + void productsShouldNotExistsByProductCodes() { + List productCodeList = List.of("P1", "P2", "P3", "P4", "P5"); + + webTestClient + .get() + .uri( + uriBuilder -> { + uriBuilder.queryParam("productCodes", productCodeList); + uriBuilder.path("/api/catalog/exists"); + return uriBuilder.build(); + }) + .exchange() + .expectStatus() + .isOk() + .expectHeader() + .contentType(MediaType.APPLICATION_JSON) + .expectBody(Boolean.class) + .isEqualTo(Boolean.FALSE); + } + @Test void shouldCreateNewProduct() { ProductDto productDto = new ProductDto("code 4", "name 4", "description 4", 19.0);