title: Unit Test Spring-boot Rest Controller
body: <p>Is there anyway to write unit test for my RestController without mocking the service using @MockBean?</p>
  
  <pre><code>@Autowired
  private MockMvc mockMvc;
  
  @MockBean
  private CarService carService;
  
  
  @Test
  public void shouldReturnCarDetails() {
  
      //when(carService.getCarDetails(1)).thenReturn(new Car(1, 300));
      try {
          mockMvc.perform(MockMvcRequestBuilders.get("/api/cars/1")).andExpect(MockMvcResultMatchers.status().isOk())
                  .andExpect(MockMvcResultMatchers.jsonPath("speed").value(300));
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  }`
  </code></pre>