Skip to content

Commit

Permalink
Update ReviewControllerTest.java
Browse files Browse the repository at this point in the history
Added unfixed commented out test cases.
  • Loading branch information
nhkhai committed Mar 30, 2024
1 parent c59d263 commit c66597e
Showing 1 changed file with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,104 @@ public void getReviewTest() throws Exception {
// test_logger.info("Ending test: " + getCurrentMethodName() + ". ");
// }
// >>>>>>> main

// @DisplayName("Get All Reviews")
// @Test
// public void getAllReviewsTest() throws Exception {
// test_logger.info("Starting test: " + getCurrentMethodName() + ". ");

// // Step 1: Create the test objects.
// Review newReview =
// Review.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
// .address("123 HK St").postalCode(654321).phoneNumber(87654321)
// .email("[email protected]").build();

// Review newReview2 =
// Review.builder().firstName("Jack").lastName("Chang").country("China")
// .address("321 HK St").postalCode(123456).phoneNumber(12345678)
// .email("[email protected]").build();

// // Step 2: Convert the Java objects to JSON using ObjectMapper.
// String newReviewAsJSON = objectMapper.writeValueAsString(newReview);
// String newReviewAsJSON2 = objectMapper.writeValueAsString(newReview2);

// // Step 3: Build the request.
// RequestBuilder request = MockMvcRequestBuilders.post("/customers")
// .contentType(MediaType.APPLICATION_JSON)
// .content(newReviewAsJSON);

// RequestBuilder request2 = MockMvcRequestBuilders.post("/customers")
// .contentType(MediaType.APPLICATION_JSON)
// .content(newReviewAsJSON2);

// RequestBuilder request3 = MockMvcRequestBuilders.get("/customers")
// .contentType(MediaType.APPLICATION_JSON);

// // Step 4: Perform the request and get the response and assert.
// mockMvc.perform(request)
// .andDo(print())
// .andExpect(status().isCreated())
// .andExpect(content().contentType(MediaType.APPLICATION_JSON))
// .andExpect(jsonPath("$.firstName").value("Jackie"))
// .andExpect(jsonPath("$.lastName").value("Chan"));

// mockMvc.perform(request2)
// .andDo(print())
// .andExpect(status().isCreated())
// .andExpect(content().contentType(MediaType.APPLICATION_JSON))
// .andExpect(jsonPath("$.firstName").value("Jack"))
// .andExpect(jsonPath("$.lastName").value("Chang"));

// mockMvc.perform(request3)
// .andDo(print())
// .andExpect(status().isOk())
// .andExpect(content().contentType(MediaType.APPLICATION_JSON))
// .andExpect(jsonPath("$[0].firstName").value("Jackie"))
// .andExpect(jsonPath("$[0].lastName").value("Chan"))
// .andExpect(jsonPath("$[1].firstName").value("Jack"))
// .andExpect(jsonPath("$[1].lastName").value("Chang"));

// test_logger.info("Ending test: " + getCurrentMethodName() + ". ");
// }

// @DisplayName("Get one Review")
// @Test
// public void getOneReviewsTest() throws Exception {
// test_logger.info("Starting test: " + getCurrentMethodName() + ". ");

// // Step 1: Create the test objects.
// Review newReview =
// Review.builder().firstName("Jackie").lastName("Chan").country("Hong Kong")
// .address("123 HK St").postalCode(654321).phoneNumber(87654321)
// .email("[email protected]").build();

// // Step 2: Convert the Java objects to JSON using ObjectMapper.
// String newReviewAsJSON = objectMapper.writeValueAsString(newReview);

// // Step 3: Build the request.
// RequestBuilder request = MockMvcRequestBuilders.post("/customers")
// .contentType(MediaType.APPLICATION_JSON)
// .content(newReviewAsJSON);

// RequestBuilder request2 = MockMvcRequestBuilders.get("/customers/{uuid}",
// "1")
// .contentType(MediaType.APPLICATION_JSON);

// // Step 4: Perform the request and get the response and assert.
// mockMvc.perform(request)
// .andDo(print())
// .andExpect(status().isCreated())
// .andExpect(content().contentType(MediaType.APPLICATION_JSON))
// .andExpect(jsonPath("$.firstName").value("Jackie"))
// .andExpect(jsonPath("$.lastName").value("Chan"));

// mockMvc.perform(request2)
// .andDo(print())
// .andExpect(status().isOk())
// .andExpect(content().contentType(MediaType.APPLICATION_JSON))
// .andExpect(jsonPath("$.firstName").value("Jackie"))
// .andExpect(jsonPath("$.lastName").value("Chan"));

// test_logger.info("Ending test: " + getCurrentMethodName() + ". ");
// }
}

0 comments on commit c66597e

Please sign in to comment.