RequestAccountController { @RequestMapping(value = "requests/submitAccountRequest", method = RequestMethod.POST) public String submitAccountRequest(Model model, Principal principal) throws QuadrigaStorageException { String userId = principal.getName(); if (userId == null || userId.trim().isEmpty()) return "requests/error"; int iRequestStatus = userManager.addAccountRequest(userId); model.addAttribute("requestStatus", iRequestStatus); model.addAttribute("username", principal.getName()); return "requests/accountRequested"; }  IUserManager getUserManager(); void setUserManager(IUserManager userManager); @RequestMapping(value = "requests/submitAccountRequest", method = RequestMethod.POST) String submitAccountRequest(Model model, Principal principal);  }
@Test public void testSubmitAccountRequest() throws QuadrigaStorageException { String result = requestAccountController.submitAccountRequest(model, principleNoUsername); assertEquals(result, "requests/error"); Mockito.when(userManager.addAccountRequest(Mockito.anyString())).thenReturn(1); result = requestAccountController.submitAccountRequest(model, principalUsername); assertEquals(result, "requests/accountRequested"); assertEquals(model.get("requestStatus"), 1); assertEquals(model.get("username"), "jdoe"); Mockito.when(userManager.addAccountRequest(Mockito.anyString())).thenReturn(0); result = requestAccountController.submitAccountRequest(model, principalUsername); assertEquals(result, "requests/accountRequested"); assertEquals(model.get("requestStatus"), 0); assertEquals(model.get("username"), "jdoe"); }