Search in sources :

Example 1 with AccountManager

use of org.springframework.samples.mvc31.crudcontroller.AccountManager in project spring-mvc-31-demo by rstoyanchev.

the class AccountControllerTests method testSaveFail.

@Test
public void testSaveFail() {
    Account account = new Account();
    BindingResult result = new BeanPropertyBindingResult(account, "account");
    AccountManager mgr = createMock(AccountManager.class);
    mgr.saveOrUpdate(account);
    replay(mgr);
    AccountController contrlr = new AccountController(mgr);
    String view = contrlr.save(account, result);
    assertEquals("redirect:accounts", view);
    verify(mgr);
}
Also used : Account(org.springframework.samples.mvc31.crudcontroller.Account) BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) StubAccountManager(org.springframework.samples.mvc31.crudcontroller.StubAccountManager) AccountManager(org.springframework.samples.mvc31.crudcontroller.AccountManager) AccountController(org.springframework.samples.mvc31.crudcontroller.AccountController) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Account (org.springframework.samples.mvc31.crudcontroller.Account)1 AccountController (org.springframework.samples.mvc31.crudcontroller.AccountController)1 AccountManager (org.springframework.samples.mvc31.crudcontroller.AccountManager)1 StubAccountManager (org.springframework.samples.mvc31.crudcontroller.StubAccountManager)1 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)1 BindingResult (org.springframework.validation.BindingResult)1