title: Controller Unit test with MockMvc
body: <p>Fairly new to Java, as well as Mockito and MockMvc and unit tests in general. I am also new with springboot. My basic understanding is that for unit tests I only need to test the methods in the given file that is under testing.</p>
  <p>File needed to be tested:</p>
  <pre class="lang-java prettyprint-override"><code>@RestController 
  @RequestMapping(value = &quot;some string&quot;) 
  public class Controller{
  @AutoWired 
  private Service service;
  
  @GetMapping(path= &quot;some string&quot;)
  public List&lt;ObjectClass&gt; getAllDomainData(){
  return service.getAllDetails();
  }
  }
  </code></pre>
  <p>My test class</p>
  <pre class="lang-java prettyprint-override"><code>@WebMvcTest(Controller.class)
  public class ControllerTest{
  @MockBean
  private Service service;
  @AutoWired
  private WebApplicationContext webApplicationContext;
  @AutoWired
  private MockMvc mockMvc;
  
  @Test
  public void shouldCreateMockMvc(){ assertNotNull(mockMvc);}
  
  @Test
  public void getAllDetails() throws Exception {
  when(service.getAllDetails())
      .thenReturn(List.of(new ObjectClass()));
  }
  </code></pre>
  <p>This compiles and runs.... but is it testing what I need it to test to do a efficient Unit test on the file? Im just trying to learn, go easy on me please.</p>