From 844c110c4e50790d845e4cf90535b2db4d4efc12 Mon Sep 17 00:00:00 2001 From: szasz Date: Mon, 16 May 2022 18:42:43 +0200 Subject: [PATCH] Task1 - Implement service and acceptance tests - Reformatted unit test files. --- web/pom.xml | 2 +- .../impl/ProductControllerTest.java | 6 +++--- .../controller/impl/UserControllerTest.java | 20 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/web/pom.xml b/web/pom.xml index 400fec4..cbf0a38 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -73,4 +73,4 @@ test - \ No newline at end of file + diff --git a/web/src/test/java/com/demo/web/controller/impl/ProductControllerTest.java b/web/src/test/java/com/demo/web/controller/impl/ProductControllerTest.java index 0949a60..910e448 100644 --- a/web/src/test/java/com/demo/web/controller/impl/ProductControllerTest.java +++ b/web/src/test/java/com/demo/web/controller/impl/ProductControllerTest.java @@ -49,6 +49,8 @@ public class ProductControllerTest { @Mock private ProductModelAssembler productModelAssemblerMock; + private final Function addApiLinkToProduct = productId -> WebMvcLinkBuilder.linkTo(methodOn(ProductController.class).getProduct(productId)).withSelfRel(); + private ProductController undertest; @BeforeClass @@ -229,6 +231,4 @@ private Object[][] negativeCaseProductIdsDataProvider() { {0L}, {-1L}, {null} }; } - - private final Function addApiLinkToProduct = productId -> WebMvcLinkBuilder.linkTo(methodOn(ProductController.class).getProduct(productId)).withSelfRel(); -} \ No newline at end of file +} diff --git a/web/src/test/java/com/demo/web/controller/impl/UserControllerTest.java b/web/src/test/java/com/demo/web/controller/impl/UserControllerTest.java index 277aeb4..ad52984 100644 --- a/web/src/test/java/com/demo/web/controller/impl/UserControllerTest.java +++ b/web/src/test/java/com/demo/web/controller/impl/UserControllerTest.java @@ -64,6 +64,16 @@ public class UserControllerTest { @Mock private KafkaProducer kafkaProducerMock; + private final Function addApiLinkToUser = userName -> WebMvcLinkBuilder.linkTo(methodOn(UserController.class).getUser(userName)).withSelfRel(); + + private final Function verifyKafkaProducerSendingEventWithReason = changeReason -> { + final ArgumentCaptor valueCapture = getArgumentCaptorForKafkaEvent(); + + verify(kafkaProducerMock).sendUserChangeEvent(any(), valueCapture.capture()); + assertEquals(valueCapture.getValue().getChangeReason(), changeReason); + return null; + }; + private UserController undertest; @BeforeClass @@ -266,17 +276,7 @@ private Object[][] negativeCaseUserIdsDataProvider() { }; } - private final Function addApiLinkToUser = userName -> WebMvcLinkBuilder.linkTo(methodOn(UserController.class).getUser(userName)).withSelfRel(); - private ArgumentCaptor getArgumentCaptorForKafkaEvent() { return ArgumentCaptor.forClass(UserOperationNotificationEvent.class); } - - private final Function verifyKafkaProducerSendingEventWithReason = changeReason -> { - final ArgumentCaptor valueCapture = getArgumentCaptorForKafkaEvent(); - - verify(kafkaProducerMock).sendUserChangeEvent(any(), valueCapture.capture()); - assertEquals(valueCapture.getValue().getChangeReason(), changeReason); - return null; - }; }