Exemplo n.º 1
1
 @Test
 public void postAccountTest() throws Exception {
   mockMvc
       .perform(
           MockMvcRequestBuilders.post("/account")
               .contentType(MediaType.APPLICATION_FORM_URLENCODED)
               .param("name", accountForm.getName())
               .param("surname", accountForm.getSurname())
               .param("address", accountForm.getAddress())
               .param("phone", accountForm.getPhone().toString())
               .param("iban", accountForm.getIban().toString())
               .param("balance", accountForm.getBalance().toString())
               .param("currency", accountForm.getCurrency()))
       .andExpect(MockMvcResultMatchers.status().isOk())
       .andExpect(MockMvcResultMatchers.view().name("account"))
       .andExpect(MockMvcResultMatchers.model().attributeExists("currencies"))
       .andReturn();
 }
Exemplo n.º 2
0
 @Test
 public void postAccountExistsErrorTest() throws Exception {
   Mockito.doThrow(
           new AccountExistsException("Account already exists with iban : " + account.getIban()))
       .when(accountService)
       .createAccount(
           new Account(
               accountForm.getName(),
               accountForm.getSurname(),
               accountForm.getAddress(),
               accountForm.getPhone(),
               accountForm.getIban(),
               accountForm.getBalance(),
               accountForm.getCurrency()));
   accountController.createAccount(accountForm, bindingResult, model);
 }