diff --git a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java index eefa75a..4d13242 100644 --- a/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java +++ b/src/test/java/sg/com/smartinventory/controllers/ReviewControllerTest.java @@ -84,34 +84,34 @@ public void getReviewTest() throws Exception { // Build the GET request RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/reviews/2"); //======= // = = = DATA INTEGRITY VIOLATION EXCEPTION = = = - public void createReviewTest() 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)); - // .andDo(print -> test_logger.error("Customer's id: {}", - // print.getResponse().getContentAsString())) - // .andDo(print -> test_logger.error("Starting Request: createReviewTest. ")) - // .andReturn(); + // public void createReviewTest() 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)); + // // .andDo(print -> test_logger.error("Customer's id: {}", + // // print.getResponse().getContentAsString())) + // // .andDo(print -> test_logger.error("Starting Request: createReviewTest. ")) + // // .andReturn(); // >>>>>>> main // when(reviewService.getReview(2L)).thenReturn(testReview);