parent
8a951729a2
commit
2aa6b1c95a
@ -1,49 +0,0 @@
|
|||||||
package ${basePackage}.action.api.${module};
|
|
||||||
|
|
||||||
import ${basePackage}.frame.auth.LocalData;
|
|
||||||
import ${basePackage}.module.${module}.mgr.${table.getCName()}Manager;
|
|
||||||
import ${basePackage}.module.${module}.req.*;
|
|
||||||
import ${basePackage}.module.${module}.rsp.*;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
public class ${table.getCName()}Api{
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ${table.getCName()}Manager ${table.getFName()}Manager;
|
|
||||||
|
|
||||||
<#if table.getCreate()>
|
|
||||||
public ${table.getCName()}CreateResponse create(${table.getCName()}CreateRequest request) {
|
|
||||||
return ${table.getFName()}Manager.create(request, LocalData.getToken());
|
|
||||||
}
|
|
||||||
</#if>
|
|
||||||
<#if table.getDelete()>
|
|
||||||
|
|
||||||
public ${table.getCName()}DeleteResponse delete(${table.getCName()}DeleteRequest request) {
|
|
||||||
return ${table.getFName()}Manager.delete(request, LocalData.getToken());
|
|
||||||
}
|
|
||||||
</#if>
|
|
||||||
<#if table.getUpdate()>
|
|
||||||
|
|
||||||
public ${table.getCName()}UpdateResponse update(${table.getCName()}UpdateRequest request) {
|
|
||||||
return ${table.getFName()}Manager.update(request, LocalData.getToken());
|
|
||||||
}
|
|
||||||
</#if>
|
|
||||||
<#if table.getFind()>
|
|
||||||
|
|
||||||
public ${table.getCName()}FindResponse find(${table.getCName()}FindRequest request) {
|
|
||||||
return ${table.getFName()}Manager.find(request, LocalData.getToken());
|
|
||||||
}
|
|
||||||
</#if>
|
|
||||||
<#if table.getGet()>
|
|
||||||
|
|
||||||
public ${table.getCName()}GetResponse get(${table.getCName()}GetRequest request) {
|
|
||||||
return ${table.getFName()}Manager.get(request, LocalData.getToken());
|
|
||||||
}
|
|
||||||
</#if>
|
|
||||||
<#if table.getSearch()>
|
|
||||||
|
|
||||||
public ${table.getCName()}SearchResponse search(${table.getCName()}SearchRequest request) {
|
|
||||||
return ${table.getFName()}Manager.search(request, LocalData.getToken());
|
|
||||||
}
|
|
||||||
</#if>
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package ${basePackage}.config;
|
|
||||||
|
|
||||||
import net.sf.ehcache.Cache;
|
|
||||||
import net.sf.ehcache.CacheManager;
|
|
||||||
import net.sf.ehcache.config.CacheConfiguration;
|
|
||||||
import net.sf.ehcache.config.DiskStoreConfiguration;
|
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
|
||||||
import org.springframework.cache.ehcache.EhCacheCacheManager;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableCaching
|
|
||||||
public class CacheConfig {
|
|
||||||
|
|
||||||
public static final String TOKEN_CACHE = "tokenCache";
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public EhCacheCacheManager getCacheManager() {
|
|
||||||
net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
|
|
||||||
// todo 需根据服务器物理内存配置
|
|
||||||
configuration.setMaxBytesLocalHeap("128M");
|
|
||||||
configuration.updateCheck(false);
|
|
||||||
configuration.addDiskStore(new DiskStoreConfiguration().path("java.io.tmpdir"));
|
|
||||||
CacheManager cacheManager = CacheManager.create(configuration);
|
|
||||||
|
|
||||||
// 添加token缓存
|
|
||||||
cacheManager.addCache(buildTokenCache());
|
|
||||||
return new EhCacheCacheManager(cacheManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建TokenCache
|
|
||||||
*
|
|
||||||
* @return 缓存
|
|
||||||
*/
|
|
||||||
private Cache buildTokenCache() {
|
|
||||||
CacheConfiguration config = new CacheConfiguration();
|
|
||||||
config.setMemoryStoreEvictionPolicy("LFU");//最少使用
|
|
||||||
config.setTimeToLiveSeconds(60 * 60);//最长有效时间
|
|
||||||
config.setTimeToIdleSeconds(60 * 60);//无访问最长有效时间
|
|
||||||
config.setName(TOKEN_CACHE);
|
|
||||||
return new Cache(config);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,137 +0,0 @@
|
|||||||
package ${basePackage}.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
|
||||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
|
|
||||||
import ${basePackage}.frame.auth.LocalData;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.frame.utils.CookieUtil;
|
|
||||||
import ${basePackage}.module.system.mgr.TokensManager;
|
|
||||||
import ${basePackage}.module.system.req.TokensBuildRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.TokensBuildResponse;
|
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
import javax.servlet.FilterChain;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.ServletRequest;
|
|
||||||
import javax.servlet.ServletResponse;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
|
||||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
||||||
|
|
||||||
@Value("${r'${web.url.auth.included}'}")
|
|
||||||
private String[] included;
|
|
||||||
@Value("${r'${web.url.auth.excluded}'}")
|
|
||||||
private String[] excluded;
|
|
||||||
@Value("${r'${spring.mvc.static-path-pattern}'}")
|
|
||||||
private String[] staticPath;
|
|
||||||
@Value("${r'${web.url.login}'}")
|
|
||||||
private String loginPage;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configure(WebSecurity web) throws Exception {
|
|
||||||
web.ignoring().mvcMatchers(staticPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
|
||||||
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
||||||
.and()
|
|
||||||
.addFilterBefore(new TokenFilter(), FilterSecurityInterceptor.class)// 过滤器用于处理Token
|
|
||||||
.authorizeRequests()
|
|
||||||
.antMatchers(excluded).permitAll()// 放行排除的URL
|
|
||||||
.antMatchers(included).access("@Authorization.hasPermission(request,authentication)")// 需要权限的URL
|
|
||||||
.and().cors()
|
|
||||||
.and().headers().frameOptions().disable()
|
|
||||||
.and().csrf().disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 此方法不要删除 用于屏蔽默认用户密码生成
|
|
||||||
* <p>
|
|
||||||
* 例如 Using generated security password: f6b42a66-71b1-4c31-b6a8-942838c81408
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
||||||
return super.authenticationManagerBean();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TokenFilter implements Filter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
|
||||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
|
||||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
|
||||||
String token = request.getParameter("token");
|
|
||||||
if (token == null || token.isEmpty()) {
|
|
||||||
token = CookieUtil.getCookieValue(request.getCookies(), "token");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 组装Token ~ 这边根据实际的业务组装Token
|
|
||||||
if (token != null) {
|
|
||||||
TokensManager tokensManager = LocalData.getBean(TokensManager.class);
|
|
||||||
TokensBuildRequest tokensBuildRequest = new TokensBuildRequest();
|
|
||||||
tokensBuildRequest.setToken(token);
|
|
||||||
TokensBuildResponse tokensBuildResponse = tokensManager.build(tokensBuildRequest, LocalData.getSysToken());
|
|
||||||
LocalData.setToken(tokensBuildResponse.getToken());
|
|
||||||
} else {
|
|
||||||
LocalData.setToken(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action
|
|
||||||
String servletPath = request.getServletPath().toLowerCase();
|
|
||||||
Pattern compile = Pattern.compile("^/(.+)\\.htm");
|
|
||||||
Matcher matcher = compile.matcher(servletPath);
|
|
||||||
if (matcher.find()) {
|
|
||||||
LocalData.setAction(matcher.group(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
filterChain.doFilter(servletRequest, servletResponse);
|
|
||||||
} catch (AccessDeniedException e) {
|
|
||||||
response.sendError(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
} catch (Exception e) {
|
|
||||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean("Authorization")
|
|
||||||
public Object getAuthorization() {
|
|
||||||
return new Object() {
|
|
||||||
public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
|
|
||||||
|
|
||||||
Token token_ = LocalData.getToken();
|
|
||||||
if (token_ == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String path = request.getServletPath();
|
|
||||||
if (token_.hasRes(path)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
package ${basePackage}.datainit;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.annotation.Rollback;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.DictItemManager;
|
|
||||||
import ${basePackage}.module.system.mgr.DictManager;
|
|
||||||
import ${basePackage}.module.system.req.DictCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictItemCreateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.DictCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemCreateResponse;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class DictInit {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DictManager dictManager;
|
|
||||||
@Autowired
|
|
||||||
private DictItemManager dictItemManager;
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Rollback(false)
|
|
||||||
public void init() {
|
|
||||||
{// 终端类型
|
|
||||||
createDict("TERMINAL_TYPE", "终端类型", new String[][]{
|
|
||||||
{"WEB", "游览器端"},
|
|
||||||
{"API", "接口端"},
|
|
||||||
{"PHONE", "手机端"},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
{// 错误日志结果
|
|
||||||
createDict("LOG_ERR_RESULT", "错误日志结果", new String[][]{
|
|
||||||
{"未处理", "未处理"},
|
|
||||||
{"已处理", "已处理"},
|
|
||||||
{"搁置", "搁置"},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
{// 资源类型
|
|
||||||
createDict("RES_TYPE", "资源类型", new String[][]{
|
|
||||||
{"网页地址", "网页地址"},
|
|
||||||
{"异步请求", "异步请求"},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
{// 用户状态
|
|
||||||
createDict("USER_STATUS", "用户状态", new String[][]{
|
|
||||||
{"正常", "正常"},
|
|
||||||
{"初始密码", "初始密码"},
|
|
||||||
{"锁定/注销", "锁定/注销"},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
{// 日志错误类型
|
|
||||||
createDict("LOG_ERR_TYPE", "日志错误类型", new String[][]{
|
|
||||||
{"系统错误", "系统错误"},
|
|
||||||
{"业务错误", "业务错误"},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
{// 文件类型
|
|
||||||
createDict("FILE_TYPE", "文件类型", new String[][]{
|
|
||||||
{"IMG", "图片"},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createDict(String name, String comment, String[][] items) {
|
|
||||||
DictCreateRequest dictCreateRequest = new DictCreateRequest();
|
|
||||||
dictCreateRequest.setDictName(name);
|
|
||||||
dictCreateRequest.setDictComment(comment);
|
|
||||||
dictCreateRequest.setVersion(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
||||||
dictCreateRequest.setValid(true);
|
|
||||||
DictCreateResponse dictCreateResponse = dictManager.create(dictCreateRequest, token);
|
|
||||||
assertTrue(!dictCreateResponse.hasError());
|
|
||||||
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
|
||||||
String[] item = items[i];
|
|
||||||
DictItemCreateRequest dictItemCreateRequest = new DictItemCreateRequest();
|
|
||||||
dictItemCreateRequest.setDictName(name);
|
|
||||||
dictItemCreateRequest.setKey(item[0]);
|
|
||||||
dictItemCreateRequest.setValue(item[1]);
|
|
||||||
dictItemCreateRequest.setSort(i);
|
|
||||||
dictItemCreateRequest.setValid(true);
|
|
||||||
DictItemCreateResponse dictItemCreateResponse = dictItemManager.create(dictItemCreateRequest, token);
|
|
||||||
assertTrue(!dictItemCreateResponse.hasError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,148 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.annotation.Rollback;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.DeptManager;
|
|
||||||
import ${basePackage}.module.system.req.DeptCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.DeptDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.DeptFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.DeptGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.DeptUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.DeptCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DeptDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DeptFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DeptGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DeptUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DeptTest - - 部门测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2019-12-27
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class DeptTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DeptManager deptManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Rollback(false)
|
|
||||||
public void testCreate() {
|
|
||||||
{
|
|
||||||
DeptCreateRequest request = new DeptCreateRequest();
|
|
||||||
request.setDeptCode("A00");
|
|
||||||
request.setDeptName("开发部");
|
|
||||||
request.setDeptAlias("开发部");
|
|
||||||
request.setValid(true);
|
|
||||||
DeptCreateResponse response = deptManager.create(request, token);
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
DeptCreateRequest request = new DeptCreateRequest();
|
|
||||||
request.setDeptCode("A00_B00");
|
|
||||||
request.setDeptName("开发部开发一组");
|
|
||||||
request.setDeptAlias("开发一组");
|
|
||||||
request.setValid(true);
|
|
||||||
DeptCreateResponse response = deptManager.create(request, token);
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
DeptCreateRequest createRequest = new DeptCreateRequest();
|
|
||||||
createRequest.setDeptCode("A00");
|
|
||||||
createRequest.setDeptName("开发部");
|
|
||||||
createRequest.setDeptAlias("开发部");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DeptCreateResponse createResponse = deptManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
DeptDeleteRequest request = new DeptDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
DeptDeleteResponse response = deptManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
DeptCreateRequest createRequest = new DeptCreateRequest();
|
|
||||||
createRequest.setDeptCode("A00");
|
|
||||||
createRequest.setDeptName("开发部");
|
|
||||||
createRequest.setDeptAlias("开发部");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DeptCreateResponse createResponse = deptManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
DeptUpdateRequest request = new DeptUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setDeptCode("A00");
|
|
||||||
request.setDeptName("开发部");
|
|
||||||
request.setDeptAlias("开发部");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DeptUpdateResponse response = deptManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
DeptFindRequest request = new DeptFindRequest();
|
|
||||||
request.setDeptCode("A00");
|
|
||||||
request.setDeptName("开发部");
|
|
||||||
request.setDeptAlias("开发部");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DeptFindResponse response = deptManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
DeptCreateRequest createRequest = new DeptCreateRequest();
|
|
||||||
createRequest.setDeptCode("A00");
|
|
||||||
createRequest.setDeptName("开发部");
|
|
||||||
createRequest.setDeptAlias("开发部");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DeptCreateResponse createResponse = deptManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
DeptGetRequest request = new DeptGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
DeptGetResponse response = deptManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getDept() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,138 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.DictItemManager;
|
|
||||||
import ${basePackage}.module.system.req.DictItemCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictItemDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictItemFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictItemGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictItemUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DictItemTest - - 字典项测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2017-01-01
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class DictItemTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DictItemManager dictItemManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
DictItemCreateRequest request = new DictItemCreateRequest();
|
|
||||||
request.setDictName("字典名称");
|
|
||||||
request.setKey("字典KEY");
|
|
||||||
request.setValue("字典VALUE");
|
|
||||||
request.setSort(1);
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DictItemCreateResponse response = dictItemManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
DictItemCreateRequest createRequest = new DictItemCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setKey("字典KEY");
|
|
||||||
createRequest.setValue("字典VALUE");
|
|
||||||
createRequest.setSort(1);
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictItemCreateResponse createResponse = dictItemManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
DictItemDeleteRequest request = new DictItemDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
DictItemDeleteResponse response = dictItemManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
DictItemCreateRequest createRequest = new DictItemCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setKey("字典KEY");
|
|
||||||
createRequest.setValue("字典VALUE");
|
|
||||||
createRequest.setSort(1);
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictItemCreateResponse createResponse = dictItemManager.create(createRequest, token);
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
DictItemUpdateRequest request = new DictItemUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setKey("字典KEY");
|
|
||||||
request.setValue("字典VALUE");
|
|
||||||
request.setSort(1);
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DictItemUpdateResponse response = dictItemManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
DictItemFindRequest request = new DictItemFindRequest();
|
|
||||||
request.setDictName("字典名称");
|
|
||||||
request.setKey("字典KEY");
|
|
||||||
request.setValue("字典VALUE");
|
|
||||||
request.setSort(1);
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DictItemFindResponse response = dictItemManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
DictItemCreateRequest createRequest = new DictItemCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setKey("字典KEY");
|
|
||||||
createRequest.setValue("字典VALUE");
|
|
||||||
createRequest.setSort(1);
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictItemCreateResponse createResponse = dictItemManager.create(createRequest, token);
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
DictItemGetRequest request = new DictItemGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
DictItemGetResponse response = dictItemManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getDictItem() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.DictItemManager;
|
|
||||||
import ${basePackage}.module.system.mgr.DictManager;
|
|
||||||
import ${basePackage}.module.system.req.DictCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictItemCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictLoadRequest;
|
|
||||||
import ${basePackage}.module.system.req.DictUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.DictCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictItemCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictLoadResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.DictUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DictTest - - 字典测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2017-01-01
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class DictTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private DictManager dictManager;
|
|
||||||
@Autowired
|
|
||||||
private DictItemManager dictItemManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
DictCreateRequest request = new DictCreateRequest();
|
|
||||||
request.setDictName("字典名称");
|
|
||||||
request.setDictComment("字典描述");
|
|
||||||
request.setVersion("字典版本号");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DictCreateResponse response = dictManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
DictCreateRequest createRequest = new DictCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setDictComment("字典描述");
|
|
||||||
createRequest.setVersion("字典版本号");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictCreateResponse createResponse = dictManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
DictDeleteRequest request = new DictDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
DictDeleteResponse response = dictManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
DictCreateRequest createRequest = new DictCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setDictComment("字典描述");
|
|
||||||
createRequest.setVersion("字典版本号");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictCreateResponse createResponse = dictManager.create(createRequest, token);
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
DictUpdateRequest request = new DictUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setDictName("字典名称");
|
|
||||||
request.setDictComment("字典描述");
|
|
||||||
request.setVersion("字典版本号");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DictUpdateResponse response = dictManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
DictFindRequest request = new DictFindRequest();
|
|
||||||
request.setDictName("字典名称");
|
|
||||||
request.setDictComment("字典描述");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
DictFindResponse response = dictManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
DictCreateRequest createRequest = new DictCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setDictComment("字典描述");
|
|
||||||
createRequest.setVersion("字典版本号");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictCreateResponse createResponse = dictManager.create(createRequest, token);
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
DictGetRequest request = new DictGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
DictGetResponse response = dictManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getDict() != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLoad() {
|
|
||||||
//创建数据
|
|
||||||
DictCreateRequest createRequest = new DictCreateRequest();
|
|
||||||
createRequest.setDictName("字典名称");
|
|
||||||
createRequest.setDictComment("字典描述");
|
|
||||||
createRequest.setVersion("字典版本号");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
DictCreateResponse createResponse = dictManager.create(createRequest, token);
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
|
|
||||||
DictItemCreateRequest dictItemCreateRequest = new DictItemCreateRequest();
|
|
||||||
dictItemCreateRequest.setDictName("字典名称");
|
|
||||||
dictItemCreateRequest.setKey("1");
|
|
||||||
dictItemCreateRequest.setValue("1");
|
|
||||||
dictItemCreateRequest.setSort(1);
|
|
||||||
dictItemCreateRequest.setValid(true);
|
|
||||||
DictItemCreateResponse dictItemCreateResponse = dictItemManager.create(dictItemCreateRequest, token);
|
|
||||||
assertTrue(!dictItemCreateResponse.hasError() && dictItemCreateResponse.getId() > 0);
|
|
||||||
|
|
||||||
//获取字典及字典项数据
|
|
||||||
DictLoadRequest request = new DictLoadRequest();
|
|
||||||
request.setDictName("字典名称");
|
|
||||||
|
|
||||||
DictLoadResponse response = dictManager.load(request, token);
|
|
||||||
assertTrue(!response.hasError() && response.getDict() != null && response.getDictItems().size() > 0);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.FileManager;
|
|
||||||
import ${basePackage}.module.system.req.FileCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.FileDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.FileFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.FileGetRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.FileCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.FileDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.FileFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.FileGetResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FileTest - - 字典测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2017-01-01
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class FileTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FileManager fileManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
FileCreateRequest request = new FileCreateRequest();
|
|
||||||
request.setName("字文件名称");
|
|
||||||
request.setFileType(null);
|
|
||||||
request.setUrl("http://example.com/a.zip");
|
|
||||||
request.setUrlDownload("http://example.com/a.zip");
|
|
||||||
request.setAttribute1("Attribute1");
|
|
||||||
request.setAttribute2("Attribute2");
|
|
||||||
request.setAttribute2("Attribute3");
|
|
||||||
|
|
||||||
FileCreateResponse response = fileManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
FileCreateRequest createRequest = new FileCreateRequest();
|
|
||||||
createRequest.setName("字文件名称");
|
|
||||||
createRequest.setFileType(null);
|
|
||||||
createRequest.setUrl("http://example.com/a.zip");
|
|
||||||
createRequest.setUrlDownload("http://example.com/a.zip");
|
|
||||||
createRequest.setAttribute1("Attribute1");
|
|
||||||
createRequest.setAttribute2("Attribute2");
|
|
||||||
createRequest.setAttribute2("Attribute3");
|
|
||||||
|
|
||||||
FileCreateResponse createResponse = fileManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
FileDeleteRequest request = new FileDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
FileDeleteResponse response = fileManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
FileFindRequest request = new FileFindRequest();
|
|
||||||
request.setName("字文件名称");
|
|
||||||
request.setFileType(null);
|
|
||||||
request.setAttribute1("Attribute1");
|
|
||||||
request.setAttribute2("Attribute2");
|
|
||||||
request.setAttribute2("Attribute3");
|
|
||||||
|
|
||||||
FileFindResponse response = fileManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
FileCreateRequest createRequest = new FileCreateRequest();
|
|
||||||
createRequest.setName("字文件名称");
|
|
||||||
createRequest.setFileType(null);
|
|
||||||
createRequest.setUrl("http://example.com/a.zip");
|
|
||||||
createRequest.setUrlDownload("http://example.com/a.zip");
|
|
||||||
createRequest.setAttribute1("Attribute1");
|
|
||||||
createRequest.setAttribute2("Attribute2");
|
|
||||||
createRequest.setAttribute2("Attribute3");
|
|
||||||
|
|
||||||
FileCreateResponse createResponse = fileManager.create(createRequest, token);
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
FileGetRequest request = new FileGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
FileGetResponse response = fileManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getFile() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,154 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.LogErrManager;
|
|
||||||
import ${basePackage}.module.system.req.LogErrCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.LogErrDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.LogErrFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.LogErrGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.LogErrUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.LogErrCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.LogErrDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.LogErrFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.LogErrGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.LogErrUpdateResponse;
|
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LogErrTest - - 错误日志测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2020-01-29
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class LogErrTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LogErrManager logErrManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
LogErrCreateRequest request = new LogErrCreateRequest();
|
|
||||||
request.setLogErrType("code");
|
|
||||||
request.setTitle("错误标题");
|
|
||||||
request.setContent("content");
|
|
||||||
request.setLogErrResult("code");
|
|
||||||
request.setAttribute1("属性1");
|
|
||||||
request.setAttribute2("属性2");
|
|
||||||
request.setAttribute3("属性3");
|
|
||||||
|
|
||||||
LogErrCreateResponse response = logErrManager.create(request,token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
LogErrCreateRequest createRequest = new LogErrCreateRequest();
|
|
||||||
createRequest.setLogErrType("code");
|
|
||||||
createRequest.setTitle("错误标题");
|
|
||||||
createRequest.setContent("content");
|
|
||||||
createRequest.setLogErrResult("code");
|
|
||||||
createRequest.setAttribute1("属性1");
|
|
||||||
createRequest.setAttribute2("属性2");
|
|
||||||
createRequest.setAttribute3("属性3");
|
|
||||||
|
|
||||||
LogErrCreateResponse createResponse = logErrManager.create(createRequest,token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
LogErrDeleteRequest request = new LogErrDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
LogErrDeleteResponse response = logErrManager.delete(request,token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
LogErrCreateRequest createRequest = new LogErrCreateRequest();
|
|
||||||
createRequest.setLogErrType("code");
|
|
||||||
createRequest.setTitle("错误标题");
|
|
||||||
createRequest.setContent("content");
|
|
||||||
createRequest.setLogErrResult("code");
|
|
||||||
createRequest.setAttribute1("属性1");
|
|
||||||
createRequest.setAttribute2("属性2");
|
|
||||||
createRequest.setAttribute3("属性3");
|
|
||||||
|
|
||||||
LogErrCreateResponse createResponse = logErrManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
LogErrUpdateRequest request = new LogErrUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setLogErrType("code");
|
|
||||||
request.setTitle("错误标题");
|
|
||||||
request.setContent("content");
|
|
||||||
request.setLogErrResult("code");
|
|
||||||
request.setAttribute1("属性1");
|
|
||||||
request.setAttribute2("属性2");
|
|
||||||
request.setAttribute3("属性3");
|
|
||||||
|
|
||||||
LogErrUpdateResponse response = logErrManager.update(request,token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
LogErrFindRequest request = new LogErrFindRequest();
|
|
||||||
request.setLogErrType("code");
|
|
||||||
request.setTitle("错误标题");
|
|
||||||
request.setLogErrResult("code");
|
|
||||||
request.setAttribute1("属性1");
|
|
||||||
request.setAttribute2("属性2");
|
|
||||||
request.setAttribute3("属性3");
|
|
||||||
|
|
||||||
LogErrFindResponse response = logErrManager.find(request,token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
LogErrCreateRequest createRequest = new LogErrCreateRequest();
|
|
||||||
createRequest.setLogErrType("code");
|
|
||||||
createRequest.setTitle("错误标题");
|
|
||||||
createRequest.setContent("content");
|
|
||||||
createRequest.setLogErrResult("code");
|
|
||||||
createRequest.setAttribute1("属性1");
|
|
||||||
createRequest.setAttribute2("属性2");
|
|
||||||
createRequest.setAttribute3("属性3");
|
|
||||||
|
|
||||||
LogErrCreateResponse createResponse = logErrManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
LogErrGetRequest request = new LogErrGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
LogErrGetResponse response = logErrManager.get(request,token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getLogErr() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.ResManager;
|
|
||||||
import ${basePackage}.module.system.req.ResCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.ResDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.ResFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.ResGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.ResUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.ResCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.ResDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.ResFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.ResGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.ResUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ResTest - - 资源测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2020-01-05
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class ResTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ResManager resManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
ResCreateRequest request = new ResCreateRequest();
|
|
||||||
request.setResCode("资源代码");
|
|
||||||
request.setResName("资源名称");
|
|
||||||
request.setResType("code");
|
|
||||||
request.setResValue("资源内容");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
ResCreateResponse response = resManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
ResCreateRequest createRequest = new ResCreateRequest();
|
|
||||||
createRequest.setResCode("资源代码");
|
|
||||||
createRequest.setResName("资源名称");
|
|
||||||
createRequest.setResType("code");
|
|
||||||
createRequest.setResValue("资源内容");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
ResCreateResponse createResponse = resManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
ResDeleteRequest request = new ResDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
ResDeleteResponse response = resManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
ResCreateRequest createRequest = new ResCreateRequest();
|
|
||||||
createRequest.setResCode("资源代码");
|
|
||||||
createRequest.setResName("资源名称");
|
|
||||||
createRequest.setResType("code");
|
|
||||||
createRequest.setResValue("资源内容");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
ResCreateResponse createResponse = resManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
ResUpdateRequest request = new ResUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setResCode("资源代码");
|
|
||||||
request.setResName("资源名称");
|
|
||||||
request.setResType("code");
|
|
||||||
request.setResValue("资源内容");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
ResUpdateResponse response = resManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
ResFindRequest request = new ResFindRequest();
|
|
||||||
request.setResCode("资源代码");
|
|
||||||
request.setResName("资源名称");
|
|
||||||
request.setResType("code");
|
|
||||||
request.setResValue("资源内容");
|
|
||||||
request.setSupCode("上级代码");
|
|
||||||
request.setSupName("上级名称");
|
|
||||||
request.setValid(true);
|
|
||||||
|
|
||||||
ResFindResponse response = resManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
ResCreateRequest createRequest = new ResCreateRequest();
|
|
||||||
createRequest.setResCode("资源代码");
|
|
||||||
createRequest.setResName("资源名称");
|
|
||||||
createRequest.setResType("code");
|
|
||||||
createRequest.setResValue("资源内容");
|
|
||||||
createRequest.setValid(true);
|
|
||||||
|
|
||||||
ResCreateResponse createResponse = resManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
ResGetRequest request = new ResGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
ResGetResponse response = resManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getRes() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,137 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.RoleResManager;
|
|
||||||
import ${basePackage}.module.system.req.RoleResCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleResDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleResFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleResGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleResUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleResCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleResDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleResFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleResGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleResUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RoleResTest - - 角色资源关系测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2020-01-05
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class RoleResTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleResManager roleResManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
RoleResCreateRequest request = new RoleResCreateRequest();
|
|
||||||
request.setRoleId(1L);
|
|
||||||
request.setRoleCode("角色代码");
|
|
||||||
request.setResId(1L);
|
|
||||||
request.setResCode("资源代码");
|
|
||||||
|
|
||||||
RoleResCreateResponse response = roleResManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
RoleResCreateRequest createRequest = new RoleResCreateRequest();
|
|
||||||
createRequest.setRoleId(1L);
|
|
||||||
createRequest.setRoleCode("角色代码");
|
|
||||||
createRequest.setResId(1L);
|
|
||||||
createRequest.setResCode("资源代码");
|
|
||||||
|
|
||||||
RoleResCreateResponse createResponse = roleResManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
RoleResDeleteRequest request = new RoleResDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
RoleResDeleteResponse response = roleResManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
RoleResCreateRequest createRequest = new RoleResCreateRequest();
|
|
||||||
createRequest.setRoleId(1L);
|
|
||||||
createRequest.setRoleCode("角色代码");
|
|
||||||
createRequest.setResId(1L);
|
|
||||||
createRequest.setResCode("资源代码");
|
|
||||||
|
|
||||||
RoleResCreateResponse createResponse = roleResManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
RoleResUpdateRequest request = new RoleResUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setRoleId(1L);
|
|
||||||
request.setRoleCode("角色代码");
|
|
||||||
request.setResId(1L);
|
|
||||||
request.setResCode("资源代码");
|
|
||||||
|
|
||||||
RoleResUpdateResponse response = roleResManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
RoleResFindRequest request = new RoleResFindRequest();
|
|
||||||
request.setRoleId(1L);
|
|
||||||
request.setRoleCode("角色代码");
|
|
||||||
request.setResId(1L);
|
|
||||||
request.setResCode("资源代码");
|
|
||||||
|
|
||||||
RoleResFindResponse response = roleResManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
RoleResCreateRequest createRequest = new RoleResCreateRequest();
|
|
||||||
createRequest.setRoleId(1L);
|
|
||||||
createRequest.setRoleCode("角色代码");
|
|
||||||
createRequest.setResId(1L);
|
|
||||||
createRequest.setResCode("资源代码");
|
|
||||||
|
|
||||||
RoleResCreateResponse createResponse = roleResManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
RoleResGetRequest request = new RoleResGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
RoleResGetResponse response = roleResManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getRoleRes() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,131 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.RoleManager;
|
|
||||||
import ${basePackage}.module.system.req.RoleCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.RoleUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.RoleUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RoleTest - - 角色测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2019-12-27
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class RoleTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleManager roleManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
RoleCreateRequest request = new RoleCreateRequest();
|
|
||||||
request.setCode("角色代码");
|
|
||||||
request.setName("角色名称");
|
|
||||||
request.setComment("角色描述");
|
|
||||||
|
|
||||||
RoleCreateResponse response = roleManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
RoleCreateRequest createRequest = new RoleCreateRequest();
|
|
||||||
createRequest.setCode("角色代码");
|
|
||||||
createRequest.setName("角色名称");
|
|
||||||
createRequest.setComment("角色描述");
|
|
||||||
|
|
||||||
RoleCreateResponse createResponse = roleManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
RoleDeleteRequest request = new RoleDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
RoleDeleteResponse response = roleManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
RoleCreateRequest createRequest = new RoleCreateRequest();
|
|
||||||
createRequest.setCode("角色代码");
|
|
||||||
createRequest.setName("角色名称");
|
|
||||||
createRequest.setComment("角色描述");
|
|
||||||
|
|
||||||
RoleCreateResponse createResponse = roleManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
RoleUpdateRequest request = new RoleUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setCode("角色代码");
|
|
||||||
request.setName("角色名称");
|
|
||||||
request.setComment("角色描述");
|
|
||||||
|
|
||||||
RoleUpdateResponse response = roleManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
RoleFindRequest request = new RoleFindRequest();
|
|
||||||
request.setCode("角色代码");
|
|
||||||
request.setName("角色名称");
|
|
||||||
request.setComment("角色描述");
|
|
||||||
|
|
||||||
RoleFindResponse response = roleManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
RoleCreateRequest createRequest = new RoleCreateRequest();
|
|
||||||
createRequest.setCode("角色代码");
|
|
||||||
createRequest.setName("角色名称");
|
|
||||||
createRequest.setComment("角色描述");
|
|
||||||
|
|
||||||
RoleCreateResponse createResponse = roleManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
RoleGetRequest request = new RoleGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
RoleGetResponse response = roleManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getRole() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,185 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.frame.utils.IDgenerator;
|
|
||||||
import ${basePackage}.module.system.mgr.TokensManager;
|
|
||||||
import ${basePackage}.module.system.req.TokensCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.TokensFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.TokensGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.TokensUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.TokensCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.TokensDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.TokensFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.TokensGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.TokensUpdateResponse;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TokensTest - - 通行证测试用例
|
|
||||||
*
|
|
||||||
* @author author
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2017-01-01
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class TokensTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TokensManager tokensManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
TokensCreateRequest request = new TokensCreateRequest();
|
|
||||||
request.setToken(IDgenerator.nextUUID());
|
|
||||||
request.setUserId(1L);
|
|
||||||
request.setUserName("用户名称");
|
|
||||||
request.setLoginTime(new Date());
|
|
||||||
request.setValidTime(new Date());
|
|
||||||
request.setValid(true);
|
|
||||||
request.setDeptId(1L);
|
|
||||||
request.setDeptCode("部门代码");
|
|
||||||
request.setDeptName("部门名称");
|
|
||||||
request.setTerminalType("code");
|
|
||||||
request.setTerminalIp("终端地址");
|
|
||||||
request.setTerminalInfo("终端信息");
|
|
||||||
|
|
||||||
TokensCreateResponse response = tokensManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
TokensCreateRequest createRequest = new TokensCreateRequest();
|
|
||||||
createRequest.setToken(IDgenerator.nextUUID());
|
|
||||||
createRequest.setUserId(1L);
|
|
||||||
createRequest.setUserName("用户名称");
|
|
||||||
createRequest.setLoginTime(new Date());
|
|
||||||
createRequest.setValidTime(new Date());
|
|
||||||
createRequest.setValid(true);
|
|
||||||
createRequest.setDeptId(1L);
|
|
||||||
createRequest.setDeptCode("部门代码");
|
|
||||||
createRequest.setDeptName("部门名称");
|
|
||||||
createRequest.setTerminalType("code");
|
|
||||||
createRequest.setTerminalIp("终端地址");
|
|
||||||
createRequest.setTerminalInfo("终端信息");
|
|
||||||
|
|
||||||
TokensCreateResponse createResponse = tokensManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
${basePackage}.module.system.req.TokensDeleteRequest request = new ${basePackage}.module.system.req.TokensDeleteRequest();
|
|
||||||
request.setToken(createRequest.getToken());
|
|
||||||
|
|
||||||
TokensDeleteResponse response = tokensManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
TokensCreateRequest createRequest = new TokensCreateRequest();
|
|
||||||
createRequest.setToken(IDgenerator.nextUUID());
|
|
||||||
createRequest.setUserId(1L);
|
|
||||||
createRequest.setUserName("用户名称");
|
|
||||||
createRequest.setLoginTime(new Date());
|
|
||||||
createRequest.setValidTime(new Date());
|
|
||||||
createRequest.setValid(true);
|
|
||||||
createRequest.setDeptId(1L);
|
|
||||||
createRequest.setDeptCode("部门代码");
|
|
||||||
createRequest.setDeptName("部门名称");
|
|
||||||
createRequest.setTerminalType("code");
|
|
||||||
createRequest.setTerminalIp("终端地址");
|
|
||||||
createRequest.setTerminalInfo("终端信息");
|
|
||||||
|
|
||||||
TokensCreateResponse createResponse = tokensManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
TokensUpdateRequest request = new TokensUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setUserId(1L);
|
|
||||||
request.setUserName("用户名称");
|
|
||||||
request.setLoginTime(new Date());
|
|
||||||
request.setValidTime(new Date());
|
|
||||||
request.setValid(true);
|
|
||||||
request.setDeptId(1L);
|
|
||||||
request.setDeptCode("部门代码");
|
|
||||||
request.setDeptName("部门名称");
|
|
||||||
request.setTerminalType("code");
|
|
||||||
request.setTerminalIp("终端地址");
|
|
||||||
request.setTerminalInfo("终端信息");
|
|
||||||
|
|
||||||
TokensUpdateResponse response = tokensManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
TokensFindRequest request = new TokensFindRequest();
|
|
||||||
request.setUserId(1L);
|
|
||||||
request.setUserName("用户名称");
|
|
||||||
request.setLoginTime(new Date());
|
|
||||||
request.setValidTime(new Date());
|
|
||||||
request.setValid(true);
|
|
||||||
request.setDeptId(1L);
|
|
||||||
request.setDeptCode("部门代码");
|
|
||||||
request.setDeptName("部门名称");
|
|
||||||
request.setTerminalType("code");
|
|
||||||
request.setTerminalIp("终端地址");
|
|
||||||
request.setTerminalInfo("终端信息");
|
|
||||||
|
|
||||||
TokensFindResponse response = tokensManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
TokensCreateRequest createRequest = new TokensCreateRequest();
|
|
||||||
createRequest.setToken(IDgenerator.nextUUID());
|
|
||||||
createRequest.setUserId(1L);
|
|
||||||
createRequest.setUserName("用户名称");
|
|
||||||
createRequest.setLoginTime(new Date());
|
|
||||||
createRequest.setValidTime(new Date());
|
|
||||||
createRequest.setValid(true);
|
|
||||||
createRequest.setDeptId(1L);
|
|
||||||
createRequest.setDeptCode("部门代码");
|
|
||||||
createRequest.setDeptName("部门名称");
|
|
||||||
createRequest.setTerminalType("code");
|
|
||||||
createRequest.setTerminalIp("终端地址");
|
|
||||||
createRequest.setTerminalInfo("终端信息");
|
|
||||||
|
|
||||||
TokensCreateResponse createResponse = tokensManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
TokensGetRequest request = new TokensGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
TokensGetResponse response = tokensManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getTokens() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.UserRoleManager;
|
|
||||||
import ${basePackage}.module.system.req.UserRoleCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserRoleDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserRoleFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserRoleGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserRoleUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.UserRoleCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserRoleDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserRoleFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserRoleGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserRoleUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UserRoleTest - - 用户角色授权测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2019-12-27
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class UserRoleTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserRoleManager userRoleManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
UserRoleCreateRequest request = new UserRoleCreateRequest();
|
|
||||||
request.setUserId(1L);
|
|
||||||
request.setRoleId(1L);
|
|
||||||
|
|
||||||
UserRoleCreateResponse response = userRoleManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
UserRoleCreateRequest createRequest = new UserRoleCreateRequest();
|
|
||||||
createRequest.setUserId(1L);
|
|
||||||
createRequest.setRoleId(1L);
|
|
||||||
|
|
||||||
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
UserRoleDeleteRequest request = new UserRoleDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
UserRoleDeleteResponse response = userRoleManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
UserRoleCreateRequest createRequest = new UserRoleCreateRequest();
|
|
||||||
createRequest.setUserId(1L);
|
|
||||||
createRequest.setRoleId(1L);
|
|
||||||
|
|
||||||
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
UserRoleUpdateRequest request = new UserRoleUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setUserId(1L);
|
|
||||||
request.setRoleId(1L);
|
|
||||||
|
|
||||||
UserRoleUpdateResponse response = userRoleManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
UserRoleFindRequest request = new UserRoleFindRequest();
|
|
||||||
request.setUserId(1L);
|
|
||||||
request.setRoleId(1L);
|
|
||||||
|
|
||||||
UserRoleFindResponse response = userRoleManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
UserRoleCreateRequest createRequest = new UserRoleCreateRequest();
|
|
||||||
createRequest.setUserId(1L);
|
|
||||||
createRequest.setRoleId(1L);
|
|
||||||
|
|
||||||
UserRoleCreateResponse createResponse = userRoleManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
UserRoleGetRequest request = new UserRoleGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
UserRoleGetResponse response = userRoleManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getUserRole() != null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
package ${basePackage}.system;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import ${basePackage}.frame.auth.Token;
|
|
||||||
import ${basePackage}.module.system.mgr.UserManager;
|
|
||||||
import ${basePackage}.module.system.req.UserCreateRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserDeleteRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserFindRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserGetRequest;
|
|
||||||
import ${basePackage}.module.system.req.UserUpdateRequest;
|
|
||||||
import ${basePackage}.module.system.rsp.UserCreateResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserDeleteResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserFindResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserGetResponse;
|
|
||||||
import ${basePackage}.module.system.rsp.UserUpdateResponse;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UserTest - - 用户测试用例
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2019-12-27
|
|
||||||
*/
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest
|
|
||||||
@Transactional
|
|
||||||
public class UserTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Token token;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserManager userManager;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreate() {
|
|
||||||
UserCreateRequest request = new UserCreateRequest();
|
|
||||||
request.setUserName("test");
|
|
||||||
request.setUserCode("");
|
|
||||||
request.setUserAlias("test");
|
|
||||||
request.setUserPwd("123456");
|
|
||||||
request.setUserStatus("code");
|
|
||||||
request.setDeptCode("A01");
|
|
||||||
|
|
||||||
UserCreateResponse response = userManager.create(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDelete() {
|
|
||||||
|
|
||||||
//创建数据
|
|
||||||
UserCreateRequest createRequest = new UserCreateRequest();
|
|
||||||
createRequest.setUserName("test");
|
|
||||||
createRequest.setUserCode("");
|
|
||||||
createRequest.setUserAlias("test");
|
|
||||||
createRequest.setUserPwd("123456");
|
|
||||||
createRequest.setUserStatus("code");
|
|
||||||
createRequest.setDeptCode("A01");
|
|
||||||
|
|
||||||
UserCreateResponse createResponse = userManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
||||||
//删除数据
|
|
||||||
UserDeleteRequest request = new UserDeleteRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
UserDeleteResponse response = userManager.delete(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdate() {
|
|
||||||
//创建数据
|
|
||||||
UserCreateRequest createRequest = new UserCreateRequest();
|
|
||||||
createRequest.setUserName("test");
|
|
||||||
createRequest.setUserCode("");
|
|
||||||
createRequest.setUserAlias("test");
|
|
||||||
createRequest.setUserPwd("123456");
|
|
||||||
createRequest.setUserStatus("code");
|
|
||||||
createRequest.setDeptCode("A01");
|
|
||||||
|
|
||||||
UserCreateResponse createResponse = userManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//更新数据
|
|
||||||
UserUpdateRequest request = new UserUpdateRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
request.setUserAlias("test");
|
|
||||||
request.setUserStatus("code");
|
|
||||||
request.setDeptCode("A01");
|
|
||||||
|
|
||||||
UserUpdateResponse response = userManager.update(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFind() {
|
|
||||||
UserFindRequest request = new UserFindRequest();
|
|
||||||
request.setUserName("test");
|
|
||||||
request.setUserCode("");
|
|
||||||
request.setUserAlias("test");
|
|
||||||
request.setUserStatus("code");
|
|
||||||
request.setDeptCode("A01");
|
|
||||||
|
|
||||||
UserFindResponse response = userManager.find(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGet() {
|
|
||||||
//创建数据
|
|
||||||
UserCreateRequest createRequest = new UserCreateRequest();
|
|
||||||
createRequest.setUserName("test");
|
|
||||||
createRequest.setUserCode("");
|
|
||||||
createRequest.setUserAlias("test");
|
|
||||||
createRequest.setUserPwd("123456");
|
|
||||||
createRequest.setUserStatus("code");
|
|
||||||
createRequest.setDeptCode("A01");
|
|
||||||
|
|
||||||
UserCreateResponse createResponse = userManager.create(createRequest, token);
|
|
||||||
|
|
||||||
assertTrue(!createResponse.hasError());
|
|
||||||
|
|
||||||
//获得数据
|
|
||||||
UserGetRequest request = new UserGetRequest();
|
|
||||||
request.setId(createResponse.getId());
|
|
||||||
|
|
||||||
UserGetResponse response = userManager.get(request, token);
|
|
||||||
|
|
||||||
assertTrue(!response.hasError() && response.getUser() != null);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue