|
|
|
@ -7,9 +7,17 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import ${basePackage}.frame.base.Token;
|
|
|
|
|
import ${basePackage}.frame.utils.IDgenerator;
|
|
|
|
|
import ${basePackage}.module.system.mgr.TokensManager;
|
|
|
|
|
import ${basePackage}.module.system.req.*;
|
|
|
|
|
import ${basePackage}.module.system.rsp.*;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
@ -37,6 +45,7 @@ public class TokensTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreate() {
|
|
|
|
|
TokensCreateRequest request = new TokensCreateRequest();
|
|
|
|
|
request.setToken(IDgenerator.nextUUID());
|
|
|
|
|
request.setUserId(1L);
|
|
|
|
|
request.setUserName("用户名称");
|
|
|
|
|
request.setLoginTime(new Date());
|
|
|
|
@ -49,7 +58,7 @@ public class TokensTest {
|
|
|
|
|
request.setTerminalIp("终端地址");
|
|
|
|
|
request.setTerminalInfo("终端信息");
|
|
|
|
|
|
|
|
|
|
TokensCreateResponse response = tokensManager.create(request,token);
|
|
|
|
|
TokensCreateResponse response = tokensManager.create(request, token);
|
|
|
|
|
|
|
|
|
|
assertTrue(!response.hasError());
|
|
|
|
|
}
|
|
|
|
@ -59,6 +68,7 @@ public class TokensTest {
|
|
|
|
|
|
|
|
|
|
//创建数据
|
|
|
|
|
TokensCreateRequest createRequest = new TokensCreateRequest();
|
|
|
|
|
createRequest.setToken(IDgenerator.nextUUID());
|
|
|
|
|
createRequest.setUserId(1L);
|
|
|
|
|
createRequest.setUserName("用户名称");
|
|
|
|
|
createRequest.setLoginTime(new Date());
|
|
|
|
@ -71,14 +81,14 @@ public class TokensTest {
|
|
|
|
|
createRequest.setTerminalIp("终端地址");
|
|
|
|
|
createRequest.setTerminalInfo("终端信息");
|
|
|
|
|
|
|
|
|
|
TokensCreateResponse createResponse = tokensManager.create(createRequest,token);
|
|
|
|
|
TokensCreateResponse createResponse = tokensManager.create(createRequest, token);
|
|
|
|
|
|
|
|
|
|
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
|
|
|
|
//删除数据
|
|
|
|
|
TokensDeleteRequest request = new TokensDeleteRequest();
|
|
|
|
|
request.setId(createResponse.getId());
|
|
|
|
|
${basePackage}.module.system.req.TokensDeleteRequest request = new ${basePackage}.module.system.req.TokensDeleteRequest();
|
|
|
|
|
request.setToken(createRequest.getToken());
|
|
|
|
|
|
|
|
|
|
TokensDeleteResponse response = tokensManager.delete(request,token);
|
|
|
|
|
TokensDeleteResponse response = tokensManager.delete(request, token);
|
|
|
|
|
|
|
|
|
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
|
|
|
}
|
|
|
|
@ -87,6 +97,7 @@ public class TokensTest {
|
|
|
|
|
public void testUpdate() {
|
|
|
|
|
//创建数据
|
|
|
|
|
TokensCreateRequest createRequest = new TokensCreateRequest();
|
|
|
|
|
createRequest.setToken(IDgenerator.nextUUID());
|
|
|
|
|
createRequest.setUserId(1L);
|
|
|
|
|
createRequest.setUserName("用户名称");
|
|
|
|
|
createRequest.setLoginTime(new Date());
|
|
|
|
@ -118,7 +129,7 @@ public class TokensTest {
|
|
|
|
|
request.setTerminalIp("终端地址");
|
|
|
|
|
request.setTerminalInfo("终端信息");
|
|
|
|
|
|
|
|
|
|
TokensUpdateResponse response = tokensManager.update(request,token);
|
|
|
|
|
TokensUpdateResponse response = tokensManager.update(request, token);
|
|
|
|
|
|
|
|
|
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
|
|
|
|
}
|
|
|
|
@ -138,7 +149,7 @@ public class TokensTest {
|
|
|
|
|
request.setTerminalIp("终端地址");
|
|
|
|
|
request.setTerminalInfo("终端信息");
|
|
|
|
|
|
|
|
|
|
TokensFindResponse response = tokensManager.find(request,token);
|
|
|
|
|
TokensFindResponse response = tokensManager.find(request, token);
|
|
|
|
|
|
|
|
|
|
assertTrue(!response.hasError());
|
|
|
|
|
}
|
|
|
|
@ -147,6 +158,7 @@ public class TokensTest {
|
|
|
|
|
public void testGet() {
|
|
|
|
|
//创建数据
|
|
|
|
|
TokensCreateRequest createRequest = new TokensCreateRequest();
|
|
|
|
|
createRequest.setToken(IDgenerator.nextUUID());
|
|
|
|
|
createRequest.setUserId(1L);
|
|
|
|
|
createRequest.setUserName("用户名称");
|
|
|
|
|
createRequest.setLoginTime(new Date());
|
|
|
|
@ -167,7 +179,7 @@ public class TokensTest {
|
|
|
|
|
TokensGetRequest request = new TokensGetRequest();
|
|
|
|
|
request.setId(createResponse.getId());
|
|
|
|
|
|
|
|
|
|
TokensGetResponse response = tokensManager.get(request,token);
|
|
|
|
|
TokensGetResponse response = tokensManager.get(request, token);
|
|
|
|
|
|
|
|
|
|
assertTrue(!response.hasError() && response.getTokens() != null);
|
|
|
|
|
}
|
|
|
|
|