HelloController { @RequestMapping(value = "/hello/{name}", method = RequestMethod.GET) public HelloResponse sayHi(@PathVariable String name) throws ExecutionException, InterruptedException { Future<HelloResponse> future = commandDispatcher.dispatch(new HelloCommand(name)); return future.get(); }  @RequestMapping(value = "/hello/{name}", method = RequestMethod.GET) HelloResponse sayHi(@PathVariable String name); @RequestMapping(value = "/hello", method = RequestMethod.GET) HelloResponse sayHiAuthenticated(Principal principal);  }
@Test public void whenSayingHiWithoutName_shouldReturnWithUsername() throws Exception { ResultActions result = sayHi(); result.andExpect(status().is2xxSuccessful()); result.andExpect(jsonPath("$.message", equalTo("Hello authenticated user testuser"))); }