|
|
@@ -1,5 +1,8 @@
|
|
|
package com.uas.platform.b2b;
|
|
|
|
|
|
+import com.uas.platform.b2b.model.Enterprise;
|
|
|
+import com.uas.platform.b2b.model.User;
|
|
|
+import com.uas.platform.b2b.support.SystemSession;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -12,6 +15,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
/**
|
|
|
* Spring MVC 测试基类,所有测试类继承自这个类就可以直接写单元测试
|
|
|
* @author stg
|
|
|
@@ -36,4 +42,21 @@ public class BaseJunitTest {
|
|
|
public void setup() {
|
|
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化用户信息
|
|
|
+ * @param userUU
|
|
|
+ * @param enUU
|
|
|
+ */
|
|
|
+ protected void initSystemSession(Long userUU, Long enUU) {
|
|
|
+ User user = new User();
|
|
|
+ user.setUserUU(userUU);
|
|
|
+ Enterprise enterprise = new Enterprise();
|
|
|
+ enterprise.setUu(enUU);
|
|
|
+ Set<Enterprise> enterprises = new HashSet<>();
|
|
|
+ enterprises.add(enterprise);
|
|
|
+ user.setEnterprises(enterprises);
|
|
|
+ user.setEnterprise(enterprise);
|
|
|
+ SystemSession.setUser(user);
|
|
|
+ }
|
|
|
}
|