content: package kr.co.fastcampus.eatgo.interfaces;
  
  import kr.co.fastcampus.eatgo.application.ReviewService;
  import kr.co.fastcampus.eatgo.domain.Review;
  import org.junit.jupiter.api.Test;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
  import org.springframework.boot.test.mock.mockito.MockBean;
  import org.springframework.http.MediaType;
  import org.springframework.test.web.servlet.MockMvc;
  
  import static org.mockito.ArgumentMatchers.any;
  import static org.mockito.BDDMockito.given;
  import static org.mockito.Mockito.never;
  import static org.mockito.Mockito.verify;
  import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  
  @WebMvcTest(ReviewController.class)
  public class ReviewControllerTests {
  
      @Autowired
      private MockMvc mvc;
  
      @MockBean
      private ReviewService reviewService;
  
      @Test
      public void createWithValidAttriutes() throws Exception {
          String token = "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOjEwMDQsIm5hbWUiOiJKb2huIn0.8hm6ZOJykSINHxL-rf0yV882fApL3hyQ9-WGlJUyo2A";
  
          given(reviewService.addReview(1L, "John", 3, "Mat-it-da")).willReturn(
                  Review.builder().id(1004L).build());
  
          mvc.perform(post("/restaurants/1/reviews")
                  .header("Authorization", "Bearer " + token)
                  .contentType(MediaType.APPLICATION_JSON)
                  .content("{\"score\":3,\"description\":\"Mat-it-da\"}"))
                  .andExpect(status().isCreated())
                  .andExpect(header().string("location", "/restaurants/1/reviews/1004"));
  
          verify(reviewService).addReview(1L, "John", 3, "Mat-it-da");
      }
  
      @Test
      public void createWithInvalidAttriutes() throws Exception {
          mvc.perform(post("/restaurants/1/reviews")
                  .contentType(MediaType.APPLICATION_JSON)
                  .content("{}"))
                  .andExpect(status().isBadRequest());
  
          verify(reviewService, never()).addReview(any(), any(), any(), any());
      }
  
  }
  