title: Spring Boot - Test for controller fails with 404 code
body: <p>I want to write a test for controller. Here is test snippet:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @WebMvcTest(WeatherStationController.class)
  @ContextConfiguration(classes = MockConfig.class)
  public class WeatherStationControllerTest {
  
      @Autowired
      private MockMvc mockMvc;
  
      @Autowired
      private IStationRepository stationRepository;
  
      @Test
      public void shouldReturnCorrectStation() throws Exception {
  
          mockMvc.perform(get("/stations")
                  .accept(MediaType.APPLICATION_JSON))
                  .andExpect(status().isOk());
      }
  }
  </code></pre>
  
  <p>controller code snippet:</p>
  
  <pre><code>@RestController
  @RequestMapping(value = "stations")
  public class WeatherStationController {
  
      @Autowired
      private WeatherStationService weatherService;
  
      @RequestMapping(method = RequestMethod.GET)
      public List&lt;WeatherStation&gt; getAllWeatherStations() {
          return weatherService.getAllStations();
      }
  
      @RequestMapping(value = "/{id}", method = RequestMethod.GET)
      public WeatherStation getWeatherStation(@PathVariable String id) {
          return weatherService.getStation(id);
      }
  </code></pre>
  
  <p>MockConfig class:</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages = "edu.lelyak.repository")
  public class MockConfig {
  
      //**************************** MOCK BEANS ******************************
  
      @Bean
      @Primary
      public WeatherStationService weatherServiceMock() {
          WeatherStationService mock = Mockito.mock(WeatherStationService.class);
          return mock;
      }
  </code></pre>
  
  <p>Here is error stack trace:</p>
  
  <pre><code>java.lang.AssertionError: Status 
  Expected :200
  Actual   :404
  </code></pre>
  
  <p>I can get what is wrong here.<br>
  <strong><em>How to fix test for controller?</em></strong></p>