### Question:
FacebookController { @RequestMapping(value = "/api/facebook", method = {RequestMethod.POST}, consumes = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) @ResponseStatus(HttpStatus.OK) public void updateFacebookUser(@RequestBody FacebookUserDto user, HttpServletRequest request, HttpServletResponse response) { user.setRoles(new String[]{PlatformConstants.DEFAULT_USER_ROLE}); if (log.isDebugEnabled()) { log.debug(user.toString()); } FutureCallback<UserIdentifier> callback = new FutureCallback<>(); user.setPassword(RandomStringUtils.randomAlphabetic(15)); try { commandBus.dispatch(new GenericCommandMessage<>( new CreateFacebookUserCommand(new UserIdentifier(user.getId()), user)), callback ); } catch (StructuralCommandValidationFailedException e) { log.error(e.getMessage(), e); } UserIdentifier userIdentifier; try { userIdentifier = callback.get(); if (userIdentifier != null) { UserDetails userDetails = userDetailsService.loadUserByUsername(user.getEmail()); if (userDetails != null) { try { apiAuthenticationSuccessHandler.onAuthenticationSuccess(request, response, new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities())); } catch (IOException e) { log.error(e.getMessage(), e); throw new AuthenticationServiceException("Could not authenticate user", e); } catch (ServletException e) { log.error(e.getMessage(), e); throw new AuthenticationServiceException("Could not authenticate user", e); } } else { if (log.isDebugEnabled()) { log.debug("Could not find Facebook user with username: " + user.getEmail()); } } } } catch (InterruptedException e) { log.error(e.getMessage(), e); } catch (ExecutionException e) { log.error(e.getMessage(), e); } } @Autowired  FacebookController(CommandBus commandBus,
                              UserDetailsService userDetailsService,
                              ApiAuthenticationSuccessHandler apiAuthenticationSuccessHandler); @RequestMapping(value = "/api/facebook", method = {RequestMethod.POST}, consumes = ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON_VALUE) @ResponseStatus(HttpStatus.OK) void updateFacebookUser(@RequestBody FacebookUserDto user, HttpServletRequest request, HttpServletResponse response);  }### Answer:
@Test public void testUpdateFacebookUser() throws Exception { log.info("Testing FacebookController.updateFacebookUser..."); final String emailAndUsername = "facebook@user.com"; final String id = "1111111111111111"; FutureCallback<UserIdentifier> callback = new FutureCallback<>(); callback.onSuccess(new UserIdentifier(id)); assertNotNull("Future result cannot be null", callback.get()); doAnswer(invocationOnMock -> { ((FutureCallback<UserIdentifier>) invocationOnMock.getArguments()[1]).onSuccess(new UserIdentifier(id)); return null; }).when(commandBus).dispatch(anyObject(), anyObject()); FacebookUserDto dto = new FacebookUserDto(); dto.setEmail(emailAndUsername); dto.setFirst_name("Facebook"); dto.setGender("Male"); dto.setId(id); dto.setLast_name("User"); dto.setName("Facebook User"); dto.setVerified(true); dto.setLocale("US"); FacebookProfilePicture fpp = new FacebookProfilePicture(); FacebookProfilePictureData fppd = new FacebookProfilePictureData(); fppd.setUrl("image/url"); fpp.setData(fppd); dto.setPicture(fpp); this.mockMvc.perform(post("/api/facebook") .content(convertObjectToJsonBytes(dto)) .contentType(ApplicationMediaType.APPLICATION_BEARCHOKE_V1_JSON)) .andDo(print()) .andExpect(status().isOk()); log.info("Testing FacebookController.updateFacebookUser SUCCESSFUL"); }