From 29aaebe0cacd141814415a6060e0c049701b5188 Mon Sep 17 00:00:00 2001 From: "nhkhai@gmail.com" Date: Sun, 24 Mar 2024 13:47:51 +0800 Subject: [PATCH 1/4] Fixed formatting. --- .../com/smartinventory/controllers/CustomerControllerTest.java | 2 +- .../com/smartinventory/controllers/ProductControllerTest.java | 2 +- .../sg/com/smartinventory/controllers/ReviewControllerTest.java | 2 +- .../java/sg/com/smartinventory/integration/IntegrationTest.java | 2 +- .../sg/com/smartinventory/services/CustomerServiceImplTest.java | 2 +- .../sg/com/smartinventory/services/ProductServiceImplTest.java | 2 +- .../sg/com/smartinventory/services/ReviewServiceImplTest.java | 2 +- src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java index ac43068..67ba64c 100644 --- a/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java @@ -57,7 +57,7 @@ void teardown() { public void createCustomerTest() throws Exception { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // Step 1: Create a Customer object + // Step 1: Create a Customer object. Customer newCustomer = Customer.builder().firstName("Jackie").lastName("Chan").country("Hong Kong") .address("123 HK St").postalCode(654321).phoneNumber(87654321) .email("jackie.chan@example.com").build(); diff --git a/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java index 2d38633..e2cdd8d 100644 --- a/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java @@ -57,7 +57,7 @@ void teardown() { public void createProductTest() throws Exception { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // Step 1: Create a Product object + // Step 1: Create a Product object. Product newProduct = Product.builder().category("Electronics").name("Smartphone") .description("High-end smartphone with advanced features. ") .price(999.99).stockQuantity(100).build(); diff --git a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java index 92c140f..510ce00 100644 --- a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java @@ -62,7 +62,7 @@ void teardown() { public void createReviewTest() throws Exception { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // Step 1: Create a Review object + // Step 1: Create a Review object. Review newReview = Review.builder().category("Electronics") .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) .productId(2).build(); diff --git a/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java b/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java index 8e9f383..9aebb3b 100644 --- a/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java +++ b/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java @@ -77,7 +77,7 @@ public void createCustomerTest() { .address("123 HK St").postalCode(654321).phoneNumber(87654321) .email("jackie.chan@example.com").build(); - // mock the save method of the customer repository + // Mock the save method of the customer repository. when((customerRepository.save(testObject1))).thenReturn(testObject1); // 2. Execution. diff --git a/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java b/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java index e60a73c..800a576 100644 --- a/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java +++ b/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java @@ -53,7 +53,7 @@ void teardown() { public void createCustomerTest() { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // 1. SETUP + // 1. SETUP. // Create a new customer. Customer customer = Customer.builder().firstName("John").lastName("Wick").country("USA").address("123 Main St") .postalCode(123456).phoneNumber(12345678).email("john.wick@example.com").build(); diff --git a/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java b/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java index 9f2b3e7..66fe6b0 100644 --- a/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java +++ b/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java @@ -53,7 +53,7 @@ void teardown() { public void createProductTest() { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // 1. SETUP + // 1. SETUP. // Create a new product. Product product = Product.builder().category("Electronics").name("Smartphone") .description("High-end smartphone with advanced features. ") diff --git a/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java b/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java index 6d85aac..92e9184 100644 --- a/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java +++ b/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java @@ -53,7 +53,7 @@ void teardown() { public void createReviewTest() { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // 1. SETUP + // 1. SETUP. // Create a new review. Review review = Review.builder().category("Electronics") .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) diff --git a/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java b/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java index 12c80a0..336db07 100644 --- a/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java +++ b/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java @@ -77,7 +77,7 @@ public void createCustomerTest() { .address("123 HK St").postalCode(654321).phoneNumber(87654321) .email("jackie.chan@example.com").build(); - // mock the save method of the customer repository + // Mock the save method of the customer repository. when((customerRepository.save(testObject1))).thenReturn(testObject1); // 2. Execution. From c9765eb401009b1e1b723ba8c8f1496ed5fb756c Mon Sep 17 00:00:00 2001 From: "nhkhai@gmail.com" Date: Sun, 24 Mar 2024 13:55:30 +0800 Subject: [PATCH 2/4] Update ReviewControllerTest.java Added skeleton test cases. --- .../controllers/ReviewControllerTest.java | 122 +++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java index 510ce00..9375699 100644 --- a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java @@ -62,7 +62,7 @@ void teardown() { public void createReviewTest() throws Exception { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); - // Step 1: Create a Review object. + // Step 1: Create a Review object. Review newReview = Review.builder().category("Electronics") .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) .productId(2).build(); @@ -93,4 +93,124 @@ public void createReviewTest() throws Exception { // test_logger.error("Ending test: createReviewTest. "); test_logger.info("Ending test: " + getCurrentMethodName() + ". "); } + + @DisplayName("Get All Reviews") + @Test + public void getAllReviewsTest() throws Exception { + test_logger.info("Starting test: " + getCurrentMethodName() + ". "); + + // Step 1: Create a Review objects. + Review newReview = Review.builder().category("Electronics") + .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) + .productId(2).build(); + + // Step 2: Convert the Java object to JSON using ObjectMapper. + String newReviewAsJSON = objectMapper.writeValueAsString(newReview); + + // Step 3: Build the request. + RequestBuilder request = MockMvcRequestBuilders.post("/reviews") + .contentType(MediaType.APPLICATION_JSON) + .content(newReviewAsJSON); + + // Step 4: Perform the request and get the response and assert. + mockMvc.perform(request) + // MvcResult Result = mockMvc.perform(request) + // .andDo(print -> test_logger.error("Starting Request: createReviewTest. ")) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.category").value("Electronics")) + .andExpect(jsonPath("$.rating").value(5)); + + test_logger.info("Ending test: " + getCurrentMethodName() + ". "); + } + + @DisplayName("Get One Review") + @Test + public void getOneReviewTest() throws Exception { + test_logger.info("Starting test: " + getCurrentMethodName() + ". "); + + // Step 1: Create a Review object. + Review newReview = Review.builder().category("Electronics") + .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) + .productId(2).build(); + + // Step 2: Convert the Java object to JSON using ObjectMapper. + String newReviewAsJSON = objectMapper.writeValueAsString(newReview); + + // Step 3: Build the request. + RequestBuilder request = MockMvcRequestBuilders.post("/reviews") + .contentType(MediaType.APPLICATION_JSON) + .content(newReviewAsJSON); + + // Step 4: Perform the request and get the response and assert. + mockMvc.perform(request) + // MvcResult Result = mockMvc.perform(request) + // .andDo(print -> test_logger.error("Starting Request: createReviewTest. ")) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.category").value("Electronics")) + .andExpect(jsonPath("$.rating").value(5)); + + test_logger.info("Ending test: " + getCurrentMethodName() + ". "); + } + + @DisplayName("Update Review") + @Test + public void updateReviewTest() throws Exception { + test_logger.info("Starting test: " + getCurrentMethodName() + ". "); + + // Step 1: Create a Review object. + Review newReview = Review.builder().category("Electronics") + .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) + .productId(2).build(); + + // Step 2: Convert the Java object to JSON using ObjectMapper. + String newReviewAsJSON = objectMapper.writeValueAsString(newReview); + + // Step 3: Build the request. + RequestBuilder request = MockMvcRequestBuilders.post("/reviews") + .contentType(MediaType.APPLICATION_JSON) + .content(newReviewAsJSON); + + // Step 4: Perform the request and get the response and assert. + mockMvc.perform(request) + // MvcResult Result = mockMvc.perform(request) + // .andDo(print -> test_logger.error("Starting Request: createReviewTest. ")) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.category").value("Electronics")) + .andExpect(jsonPath("$.rating").value(5)); + + test_logger.info("Ending test: " + getCurrentMethodName() + ". "); + } + + @DisplayName("Delete Review") + @Test + public void deleteReviewTest() throws Exception { + test_logger.info("Starting test: " + getCurrentMethodName() + ". "); + + // Step 1: Create a Review object. + Review newReview = Review.builder().category("Electronics") + .reviewContent("Great smartphone with excellent features. ").rating(5).customerId(1) + .productId(2).build(); + + // Step 2: Convert the Java object to JSON using ObjectMapper. + String newReviewAsJSON = objectMapper.writeValueAsString(newReview); + + // Step 3: Build the request. + RequestBuilder request = MockMvcRequestBuilders.post("/reviews") + .contentType(MediaType.APPLICATION_JSON) + .content(newReviewAsJSON); + + // Step 4: Perform the request and get the response and assert. + mockMvc.perform(request) + // MvcResult Result = mockMvc.perform(request) + // .andDo(print -> test_logger.error("Starting Request: createReviewTest. ")) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.category").value("Electronics")) + .andExpect(jsonPath("$.rating").value(5)); + + test_logger.info("Ending test: " + getCurrentMethodName() + ". "); + } } From 95bfc97f3d0aa3201f7770d79ad0049026c1c477 Mon Sep 17 00:00:00 2001 From: "nhkhai@gmail.com" Date: Mon, 25 Mar 2024 02:01:56 +0800 Subject: [PATCH 3/4] Update DataLoader.java Functionalize implementation. --- .../java/sg/com/smartinventory/utility/DataLoader.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/sg/com/smartinventory/utility/DataLoader.java b/src/main/java/sg/com/smartinventory/utility/DataLoader.java index 38493b7..afb8865 100644 --- a/src/main/java/sg/com/smartinventory/utility/DataLoader.java +++ b/src/main/java/sg/com/smartinventory/utility/DataLoader.java @@ -29,11 +29,21 @@ public DataLoader(CustomerRepository customerRepository, ProductRepository produ @PostConstruct public void loadData() { + // Clear all data. + clearTableData(); + + // Create fake data. + generateFakeData(); + } + + public void clearTableData() { // Clear all data. customerRepository.deleteAll(); productRepository.deleteAll(); reviewRepository.deleteAll(); + } + public void generateFakeData() { // Create fake data. customerRepository.save(new Customer("John", "Doe", "USA", "123 Main St", 123456, 12345678, "john.doe@example.com")); From c3bf1b5ef4c2c63ec744fd2552562630cac800ed Mon Sep 17 00:00:00 2001 From: "nhkhai@gmail.com" Date: Mon, 25 Mar 2024 02:21:15 +0800 Subject: [PATCH 4/4] Added skeleton for test case setup and cleanup. --- .../SmartInventoryApplicationTests.java | 25 +++++++++++++++++++ .../controllers/CustomerControllerTest.java | 12 +++++++++ .../controllers/ProductControllerTest.java | 12 +++++++++ .../controllers/ReviewControllerTest.java | 12 +++++++++ .../smartinventory/entities/CustomerTest.java | 12 +++++++++ .../entities/ErrorResponseTest.java | 12 +++++++++ .../smartinventory/entities/ProductTest.java | 12 +++++++++ .../smartinventory/entities/ReviewTest.java | 12 +++++++++ .../integration/IntegrationTest.java | 12 +++++++++ .../services/CustomerServiceImplTest.java | 12 +++++++++ .../services/ProductServiceImplTest.java | 12 +++++++++ .../services/ReviewServiceImplTest.java | 12 +++++++++ .../smartinventory/useCases/UseCaseTest.java | 12 +++++++++ .../utility/DataLoaderTest.java | 12 +++++++++ 14 files changed, 181 insertions(+) diff --git a/src/test/java/sg/com/smartinventory/SmartInventoryApplicationTests.java b/src/test/java/sg/com/smartinventory/SmartInventoryApplicationTests.java index 3558490..95d480f 100644 --- a/src/test/java/sg/com/smartinventory/SmartInventoryApplicationTests.java +++ b/src/test/java/sg/com/smartinventory/SmartInventoryApplicationTests.java @@ -4,6 +4,10 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -19,6 +23,27 @@ class SmartInventoryApplicationTests { // trace(), debug(), info(), warn(), error(). private static final Logger test_logger = LoggerFactory.getLogger(SmartInventoryApplicationTests.class); + // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + + @BeforeEach + void init() { + + } + + @AfterEach + void teardown() { + + } + @Test void contextLoads() { test_logger.info("Starting test: " + getCurrentMethodName() + ". "); diff --git a/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java index 67ba64c..3413443 100644 --- a/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/CustomerControllerTest.java @@ -6,7 +6,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -42,6 +44,16 @@ public class CustomerControllerTest { private static final Logger test_logger = LoggerFactory.getLogger(CustomerControllerTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java index e2cdd8d..35aa14d 100644 --- a/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/ProductControllerTest.java @@ -6,7 +6,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -42,6 +44,16 @@ public class ProductControllerTest { private static final Logger test_logger = LoggerFactory.getLogger(ProductControllerTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java index 9375699..438aad8 100644 --- a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java @@ -6,7 +6,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -42,6 +44,16 @@ public class ReviewControllerTest { private static final Logger test_logger = LoggerFactory.getLogger(ReviewControllerTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/entities/CustomerTest.java b/src/test/java/sg/com/smartinventory/entities/CustomerTest.java index b8d16f2..8011297 100644 --- a/src/test/java/sg/com/smartinventory/entities/CustomerTest.java +++ b/src/test/java/sg/com/smartinventory/entities/CustomerTest.java @@ -4,7 +4,9 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -32,6 +34,16 @@ public class CustomerTest { private static final Logger test_logger = LoggerFactory.getLogger(CustomerTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/entities/ErrorResponseTest.java b/src/test/java/sg/com/smartinventory/entities/ErrorResponseTest.java index e77bd62..549e723 100644 --- a/src/test/java/sg/com/smartinventory/entities/ErrorResponseTest.java +++ b/src/test/java/sg/com/smartinventory/entities/ErrorResponseTest.java @@ -4,7 +4,9 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -23,6 +25,16 @@ public class ErrorResponseTest { private static final Logger test_logger = LoggerFactory.getLogger(ErrorResponseTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/entities/ProductTest.java b/src/test/java/sg/com/smartinventory/entities/ProductTest.java index 1ec09a1..15f0e73 100644 --- a/src/test/java/sg/com/smartinventory/entities/ProductTest.java +++ b/src/test/java/sg/com/smartinventory/entities/ProductTest.java @@ -4,7 +4,9 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -32,6 +34,16 @@ public class ProductTest { private static final Logger test_logger = LoggerFactory.getLogger(ProductTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/entities/ReviewTest.java b/src/test/java/sg/com/smartinventory/entities/ReviewTest.java index 43479ff..ea1a174 100644 --- a/src/test/java/sg/com/smartinventory/entities/ReviewTest.java +++ b/src/test/java/sg/com/smartinventory/entities/ReviewTest.java @@ -4,7 +4,9 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -32,6 +34,16 @@ public class ReviewTest { private static final Logger test_logger = LoggerFactory.getLogger(ReviewTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java b/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java index 9aebb3b..145f396 100644 --- a/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java +++ b/src/test/java/sg/com/smartinventory/integration/IntegrationTest.java @@ -10,7 +10,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -57,6 +59,16 @@ public class IntegrationTest { private static final Logger test_logger = LoggerFactory.getLogger(IntegrationTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java b/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java index 800a576..46d13de 100644 --- a/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java +++ b/src/test/java/sg/com/smartinventory/services/CustomerServiceImplTest.java @@ -8,7 +8,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,6 +41,16 @@ public class CustomerServiceImplTest { private static final Logger test_logger = LoggerFactory.getLogger(CustomerServiceImplTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java b/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java index 66fe6b0..40b1010 100644 --- a/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java +++ b/src/test/java/sg/com/smartinventory/services/ProductServiceImplTest.java @@ -8,7 +8,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,6 +41,16 @@ public class ProductServiceImplTest { private static final Logger test_logger = LoggerFactory.getLogger(ProductServiceImplTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java b/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java index 92e9184..29c3e07 100644 --- a/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java +++ b/src/test/java/sg/com/smartinventory/services/ReviewServiceImplTest.java @@ -8,7 +8,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -39,6 +41,16 @@ public class ReviewServiceImplTest { private static final Logger test_logger = LoggerFactory.getLogger(ReviewServiceImplTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java b/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java index 336db07..da9fe02 100644 --- a/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java +++ b/src/test/java/sg/com/smartinventory/useCases/UseCaseTest.java @@ -10,7 +10,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -57,6 +59,16 @@ public class UseCaseTest { private static final Logger test_logger = LoggerFactory.getLogger(UseCaseTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() { diff --git a/src/test/java/sg/com/smartinventory/utility/DataLoaderTest.java b/src/test/java/sg/com/smartinventory/utility/DataLoaderTest.java index 36fb8e6..f19b575 100644 --- a/src/test/java/sg/com/smartinventory/utility/DataLoaderTest.java +++ b/src/test/java/sg/com/smartinventory/utility/DataLoaderTest.java @@ -4,7 +4,9 @@ import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -40,6 +42,16 @@ public class DataLoaderTest { private static final Logger test_logger = LoggerFactory.getLogger(DataLoaderTest.class); // Test Setup and Teardown configuration. + @BeforeAll + static void initAll() { + + } + + @AfterAll + static void teardownAll() { + + } + @BeforeEach void init() {