title: MockMvc Spring boot rest call Status expected:<200> but was:<500>
body: <p>While I am trying to test the get request by MockMvc, I am getting status code as 500 instead of 200.</p>
  
  <p>My Controller class Is :</p>
  
  <pre><code>@RestController
  @RequestMapping(path = "/product")
  public class ProductController {
  
      @Autowired
      ProductService productService;
  
      @GetMapping("/all")
      public List&lt;Product&gt; getProductList() {
          return productService.getProductList();
      }
  }
  </code></pre>
  
  <p>My Test class Is :</p>
  
  <pre><code>@SpringBootTest(classes = {ProductController.class, ProductService.class})
  @AutoConfigureMockMvc
  @ExtendWith(SpringExtension.class)
  public class ProductControllerTest {
  
      @Autowired 
      private MockMvc mockMvc;
  
      @MockBean
      private ProductService productService;
  
      @Test
      @DisplayName("Get Product List REST API ")
      void getProductList() throws Exception {
          MvcResult result =
          mockMvc.perform(
          MockMvcRequestBuilders.get("/product/all") 
          .contentType(IntegrationTestUtil.APPLICATION_JSON_UTF8))
          .andExpect(status().isOk())
          .andReturn();
  
  
          String resultDOW = result.getResponse().getContentAsString();
  
          assertNotNull(resultDOW);
      }
  }
  </code></pre>
  
  <p>When I run test case I got An error java.lang.AssertionError: Status expected:&lt;200> but was:&lt;500></p>