parent
2d6b60a644
commit
a572ac900d
@ -1,25 +0,0 @@
|
|||||||
package ${basePackage}.module.${moduleName}.mgr;
|
|
||||||
|
|
||||||
import ${basePackage}.module.${moduleName}.req.*;
|
|
||||||
import ${basePackage}.module.${moduleName}.rsp.*;
|
|
||||||
import ${basePackage}.frame.base.Token;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Api接口
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2018-10-23
|
|
||||||
*/
|
|
||||||
public interface ApiManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Api#example
|
|
||||||
*
|
|
||||||
* @param request 请求对象
|
|
||||||
* @param token 令牌
|
|
||||||
* @return 响应
|
|
||||||
*/
|
|
||||||
ApiExampleResponse example(ApiExampleRequest request, Token token);
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package ${basePackage}.module.${moduleName}.mgr;
|
|
||||||
|
|
||||||
import ${basePackage}.module.${moduleName}.req.*;
|
|
||||||
import ${basePackage}.module.${moduleName}.rsp.*;
|
|
||||||
import ${basePackage}.frame.base.Token;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Api接口
|
|
||||||
*
|
|
||||||
* @author wangbing
|
|
||||||
* @version 0.0.1
|
|
||||||
* @since 2018-10-23
|
|
||||||
*/
|
|
||||||
@Transactional
|
|
||||||
@Service
|
|
||||||
public class ApiManagerImpl implements ApiManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Api#example
|
|
||||||
*
|
|
||||||
* @param request 请求对象
|
|
||||||
* @param token 令牌
|
|
||||||
* @return 响应
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ApiExampleResponse example(ApiExampleRequest request, Token token) {
|
|
||||||
return new ApiExampleResponse();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,129 @@
|
|||||||
|
package ${basePackage}.system;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ${basePackage}.module.system.mgr.ResourceManager;
|
||||||
|
import ${basePackage}.module.system.req.*;
|
||||||
|
import ${basePackage}.module.system.rsp.*;
|
||||||
|
import ${basePackage}.frame.base.Token;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ResourceTest - - 资源测试用例
|
||||||
|
*
|
||||||
|
* @author author
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 2019-12-19
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@Transactional
|
||||||
|
public class ResourceTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Token token;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceManager resourceManager;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreate() {
|
||||||
|
ResourceCreateRequest request = new ResourceCreateRequest();
|
||||||
|
request.setValue("资源内容");
|
||||||
|
request.setComment("资源描述");
|
||||||
|
request.setResourceType("code");
|
||||||
|
request.setValid(true);
|
||||||
|
|
||||||
|
ResourceCreateResponse response = resourceManager.create(request,token);
|
||||||
|
|
||||||
|
assertTrue(!response.hasError());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDelete() {
|
||||||
|
|
||||||
|
//创建数据
|
||||||
|
ResourceCreateRequest createRequest = new ResourceCreateRequest();
|
||||||
|
createRequest.setValue("资源内容");
|
||||||
|
createRequest.setComment("资源描述");
|
||||||
|
createRequest.setResourceType("code");
|
||||||
|
createRequest.setValid(true);
|
||||||
|
|
||||||
|
ResourceCreateResponse createResponse = resourceManager.create(createRequest,token);
|
||||||
|
|
||||||
|
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
||||||
|
//删除数据
|
||||||
|
ResourceDeleteRequest request = new ResourceDeleteRequest();
|
||||||
|
request.setId(createResponse.getId());
|
||||||
|
|
||||||
|
ResourceDeleteResponse response = resourceManager.delete(request,token);
|
||||||
|
|
||||||
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
//创建数据
|
||||||
|
ResourceCreateRequest createRequest = new ResourceCreateRequest();
|
||||||
|
createRequest.setValue("资源内容");
|
||||||
|
createRequest.setComment("资源描述");
|
||||||
|
createRequest.setResourceType("code");
|
||||||
|
createRequest.setValid(true);
|
||||||
|
|
||||||
|
ResourceCreateResponse createResponse = resourceManager.create(createRequest, token);
|
||||||
|
|
||||||
|
assertTrue(!createResponse.hasError());
|
||||||
|
|
||||||
|
//更新数据
|
||||||
|
ResourceUpdateRequest request = new ResourceUpdateRequest();
|
||||||
|
request.setId(createResponse.getId());
|
||||||
|
request.setValue("资源内容");
|
||||||
|
request.setComment("资源描述");
|
||||||
|
request.setResourceType("code");
|
||||||
|
request.setValid(true);
|
||||||
|
|
||||||
|
ResourceUpdateResponse response = resourceManager.update(request,token);
|
||||||
|
|
||||||
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFind() {
|
||||||
|
ResourceFindRequest request = new ResourceFindRequest();
|
||||||
|
request.setValue("资源内容");
|
||||||
|
request.setComment("资源描述");
|
||||||
|
request.setResourceType("code");
|
||||||
|
request.setValid(true);
|
||||||
|
|
||||||
|
ResourceFindResponse response = resourceManager.find(request,token);
|
||||||
|
|
||||||
|
assertTrue(!response.hasError());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGet() {
|
||||||
|
//创建数据
|
||||||
|
ResourceCreateRequest createRequest = new ResourceCreateRequest();
|
||||||
|
createRequest.setValue("资源内容");
|
||||||
|
createRequest.setComment("资源描述");
|
||||||
|
createRequest.setResourceType("code");
|
||||||
|
createRequest.setValid(true);
|
||||||
|
|
||||||
|
ResourceCreateResponse createResponse = resourceManager.create(createRequest, token);
|
||||||
|
|
||||||
|
assertTrue(!createResponse.hasError());
|
||||||
|
|
||||||
|
//获得数据
|
||||||
|
ResourceGetRequest request = new ResourceGetRequest();
|
||||||
|
request.setId(createResponse.getId());
|
||||||
|
|
||||||
|
ResourceGetResponse response = resourceManager.get(request,token);
|
||||||
|
|
||||||
|
assertTrue(!response.hasError() && response.getResource() != null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,172 @@
|
|||||||
|
package ${basePackage}.system;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import ${basePackage}.module.system.mgr.TokensManager;
|
||||||
|
import ${basePackage}.module.system.req.*;
|
||||||
|
import ${basePackage}.module.system.rsp.*;
|
||||||
|
import ${basePackage}.frame.base.Token;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TokensTest - - 通行证测试用例
|
||||||
|
*
|
||||||
|
* @author author
|
||||||
|
* @version 0.0.1
|
||||||
|
* @since 2019-12-19
|
||||||
|
*/
|
||||||
|
@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.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.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);
|
||||||
|
//删除数据
|
||||||
|
TokensDeleteRequest request = new TokensDeleteRequest();
|
||||||
|
request.setId(createResponse.getId());
|
||||||
|
|
||||||
|
TokensDeleteResponse response = tokensManager.delete(request,token);
|
||||||
|
|
||||||
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdate() {
|
||||||
|
//创建数据
|
||||||
|
TokensCreateRequest createRequest = new TokensCreateRequest();
|
||||||
|
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.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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue