You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
4.5 KiB
143 lines
4.5 KiB
5 years ago
|
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.base.Token;
|
||
|
import ${basePackage}.module.system.mgr.DeptManager;
|
||
|
import ${basePackage}.module.system.req.*;
|
||
|
import ${basePackage}.module.system.rsp.*;
|
||
|
|
||
|
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
|
||
|
public void testCreate() {
|
||
|
DeptCreateRequest request = new DeptCreateRequest();
|
||
|
request.setDeptCode("部门代码");
|
||
|
request.setDeptName("部门名称");
|
||
|
request.setDeptAlias("部门别名");
|
||
|
request.setSupCode("父部门代码");
|
||
|
request.setSupName("父部门名称");
|
||
|
request.setValid(true);
|
||
|
|
||
|
DeptCreateResponse response = deptManager.create(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError());
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testDelete() {
|
||
|
|
||
|
//创建数据
|
||
|
DeptCreateRequest createRequest = new DeptCreateRequest();
|
||
|
createRequest.setDeptCode("部门代码");
|
||
|
createRequest.setDeptName("部门名称");
|
||
|
createRequest.setDeptAlias("部门别名");
|
||
|
createRequest.setSupCode("父部门代码");
|
||
|
createRequest.setSupName("父部门名称");
|
||
|
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("部门代码");
|
||
|
createRequest.setDeptName("部门名称");
|
||
|
createRequest.setDeptAlias("部门别名");
|
||
|
createRequest.setSupCode("父部门代码");
|
||
|
createRequest.setSupName("父部门名称");
|
||
|
createRequest.setValid(true);
|
||
|
|
||
|
DeptCreateResponse createResponse = deptManager.create(createRequest, token);
|
||
|
|
||
|
assertTrue(!createResponse.hasError());
|
||
|
|
||
|
//更新数据
|
||
|
DeptUpdateRequest request = new DeptUpdateRequest();
|
||
|
request.setId(createResponse.getId());
|
||
|
request.setDeptCode("部门代码");
|
||
|
request.setDeptName("部门名称");
|
||
|
request.setDeptAlias("部门别名");
|
||
|
request.setSupCode("父部门代码");
|
||
|
request.setSupName("父部门名称");
|
||
|
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("部门代码");
|
||
|
request.setDeptName("部门名称");
|
||
|
request.setDeptAlias("部门别名");
|
||
|
request.setSupCode("父部门代码");
|
||
|
request.setSupName("父部门名称");
|
||
|
request.setValid(true);
|
||
|
|
||
|
DeptFindResponse response = deptManager.find(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError());
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testGet() {
|
||
|
//创建数据
|
||
|
DeptCreateRequest createRequest = new DeptCreateRequest();
|
||
|
createRequest.setDeptCode("部门代码");
|
||
|
createRequest.setDeptName("部门名称");
|
||
|
createRequest.setDeptAlias("部门别名");
|
||
|
createRequest.setSupCode("父部门代码");
|
||
|
createRequest.setSupName("父部门名称");
|
||
|
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);
|
||
|
}
|
||
|
}
|