cleanup
This commit is contained in:
@@ -4,6 +4,7 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
@@ -34,6 +35,7 @@ public class Task extends IdEntity {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "USER_ID")
|
||||
public User getUser() {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class AccountServiceTest {
|
||||
accountService = new AccountService();
|
||||
accountService.setUserDao(mockUserDao);
|
||||
|
||||
ShiroTestUtils.mockSubject(new ShiroUser(1L, "foo", "Foo"));
|
||||
ShiroTestUtils.mockSubject(new ShiroUser(3L, "foo", "Foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -7,6 +7,7 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
@@ -14,7 +15,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* 团队.
|
||||
* 开发团队.
|
||||
*
|
||||
* @author calvin
|
||||
*/
|
||||
@@ -35,6 +36,7 @@ public class Team extends IdEntity {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@OneToOne
|
||||
@JoinColumn(name = "MASTER_ID")
|
||||
public User getMaster() {
|
||||
|
||||
@@ -106,6 +106,8 @@ public class User extends IdEntity {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
//JSR303规则
|
||||
@NotEmpty
|
||||
//多对多定义
|
||||
@ManyToMany
|
||||
@JoinTable(name = "SS_USER_ROLE", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
|
||||
@@ -115,8 +117,6 @@ public class User extends IdEntity {
|
||||
@OrderBy("id ASC")
|
||||
//缓存策略
|
||||
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
||||
//JSR303规则
|
||||
@NotEmpty
|
||||
public List<Role> getRoleList() {
|
||||
return roleList;
|
||||
}
|
||||
|
||||
+5
-4
@@ -6,11 +6,11 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springside.examples.showcase.entity.User;
|
||||
import org.springside.examples.showcase.repository.jpa.UserDao;
|
||||
import org.springside.examples.showcase.service.AccountService;
|
||||
import org.springside.examples.showcase.service.ServiceException;
|
||||
import org.springside.examples.showcase.service.ShiroDbRealm.ShiroUser;
|
||||
import org.springside.modules.test.security.shiro.ShiroTestUtils;
|
||||
|
||||
public class AccountServiceTest {
|
||||
@@ -22,7 +22,7 @@ public class AccountServiceTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
ShiroTestUtils.mockSubject("foo");
|
||||
ShiroTestUtils.mockSubject(new ShiroUser("foo", "Foo"));
|
||||
|
||||
accountService = new AccountService();
|
||||
accountService.setUserDao(mockUserDao);
|
||||
@@ -48,9 +48,10 @@ public class AccountServiceTest {
|
||||
//保存超级管理用户抛出异常.
|
||||
try {
|
||||
accountService.saveUser(admin);
|
||||
fail("expected ServicExcepton not be thrown");
|
||||
fail("expected ServicExcepton should be thrown");
|
||||
} catch (ServiceException e) {
|
||||
//expected exception
|
||||
}
|
||||
Mockito.verify(mockUserDao, Mockito.never()).delete(1L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import com.google.common.collect.Maps;
|
||||
*
|
||||
* ConstraintViolation中包含propertyPath, message 和invalidValue等信息.
|
||||
* 提供了各种convert方法,适合不同的i18n需求:
|
||||
* 1. List<message>
|
||||
* 2. List<propertyPath + separator + message>
|
||||
* 1. List<String>, String内容为message
|
||||
* 2. List<String>, String内容为propertyPath + separator + message
|
||||
* 3. Map<propertyPath, message>
|
||||
*
|
||||
* 详情见wiki: https://github.com/springside/springside4/wiki/HibernateValidator
|
||||
|
||||
Reference in New Issue
Block a user