use of org.mx.dal.service.GeneralDictAccessor in project main by JohnPeng739.
the class TestRole method testRoleCrud.
@Test
public void testRoleCrud() {
GeneralDictAccessor service = context.getBean("generalDictAccessor", GeneralDictAccessor.class);
assertNotNull(service);
RoleManageService roleService = context.getBean(RoleManageService.class);
assertNotNull(service);
try {
assertEquals(0, service.count(Role.class));
// insert
testInsertRole(service, roleService);
// edit
testEditRole(service, roleService);
// delete
testDeleteRole(service);
} catch (Exception ex) {
ex.printStackTrace();
fail(ex.getMessage());
}
}
use of org.mx.dal.service.GeneralDictAccessor in project main by JohnPeng739.
the class TestUser method testAllocateAccount.
@Test
public void testAllocateAccount() {
GeneralDictAccessor service = context.getBean("generalDictAccessor", GeneralDictAccessor.class);
assertNotNull(service);
UserManageService userService = context.getBean(UserManageService.class);
assertNotNull(service);
AccountManageService accountManageService = context.getBean(AccountManageService.class);
assertNotNull(accountManageService);
try {
testInsertUser(service, userService);
testEditUser(service, userService);
assertEquals(3, service.count(User.class));
User john = service.getById(joshId, User.class);
assertNotNull(john);
assertEquals(0, service.count(Account.class));
// 用户不存在
AccountManageService.AccountInfo accountInfo = AccountManageService.AccountInfo.valueOf("john---", "password", "desc", "", "asdfasd", Arrays.asList(), true);
try {
userService.allocateAccount(accountInfo);
fail("here need a exception");
} catch (UserInterfaceRbacErrorException ex) {
assertEquals(UserInterfaceRbacErrorException.RbacErrors.USER_NOT_FOUND.getErrorCode(), ex.getErrorCode());
}
// 正常创建
accountInfo = AccountManageService.AccountInfo.valueOf("John.Peng", "edmund!@#123", "desc", "", john.getId(), Arrays.asList(), true);
Account account = userService.allocateAccount(accountInfo);
assertNotNull(account);
assertEquals(3, service.count(User.class));
assertEquals(1, service.count(Account.class));
account = service.getByCode("John.Peng", Account.class);
assertNotNull(account);
assertNotNull(account.getOwner());
assertEquals(john, account.getOwner());
assertEquals(DigestUtils.md5("edmund!@#123"), account.getPassword());
assertEquals(john.getFullName(), account.getName());
assertEquals("desc", account.getDesc());
assertEquals(0, account.getRoles().size());
// 账户已存在
try {
userService.allocateAccount(accountInfo);
fail("here need a exception");
} catch (UserInterfaceRbacErrorException ex) {
assertEquals(UserInterfaceRbacErrorException.RbacErrors.ACCOUNT_HAS_EXIST.getErrorCode(), ex.getErrorCode());
}
} catch (Exception ex) {
ex.printStackTrace();
fail(ex.getMessage());
}
}
Aggregations