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.
131 lines
4.2 KiB
131 lines
4.2 KiB
5 years ago
|
package ${basePackage}.system;
|
||
|
|
||
|
import ${basePackage}.frame.auth.Token;
|
||
|
import ${basePackage}.module.system.mgr.ProfilesManager;
|
||
|
import ${basePackage}.module.system.req.ProfilesCreateRequest;
|
||
|
import ${basePackage}.module.system.req.ProfilesDeleteRequest;
|
||
|
import ${basePackage}.module.system.req.ProfilesFindRequest;
|
||
|
import ${basePackage}.module.system.req.ProfilesGetRequest;
|
||
|
import ${basePackage}.module.system.req.ProfilesUpdateRequest;
|
||
|
import ${basePackage}.module.system.rsp.ProfilesCreateResponse;
|
||
|
import ${basePackage}.module.system.rsp.ProfilesDeleteResponse;
|
||
|
import ${basePackage}.module.system.rsp.ProfilesFindResponse;
|
||
|
import ${basePackage}.module.system.rsp.ProfilesGetResponse;
|
||
|
import ${basePackage}.module.system.rsp.ProfilesUpdateResponse;
|
||
|
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 static junit.framework.TestCase.assertTrue;
|
||
|
|
||
|
/**
|
||
|
* ProfilesTest - - 系统配置测试用例
|
||
|
*
|
||
|
* @author author
|
||
|
* @version 0.0.1
|
||
|
* @since 2020-05-24
|
||
|
*/
|
||
|
@RunWith(SpringRunner.class)
|
||
|
@SpringBootTest
|
||
|
@Transactional
|
||
|
public class ProfilesTest {
|
||
|
|
||
|
@Autowired
|
||
|
private Token token;
|
||
|
|
||
|
@Autowired
|
||
|
private ProfilesManager profilesManager;
|
||
|
|
||
|
@Test
|
||
|
public void testCreate() {
|
||
|
ProfilesCreateRequest request = new ProfilesCreateRequest();
|
||
|
request.setActive("环境");
|
||
|
request.setKey("键");
|
||
|
request.setValue("值");
|
||
|
|
||
|
ProfilesCreateResponse response = profilesManager.create(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError());
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testDelete() {
|
||
|
|
||
|
//创建数据
|
||
|
ProfilesCreateRequest createRequest = new ProfilesCreateRequest();
|
||
|
createRequest.setActive("环境");
|
||
|
createRequest.setKey("键");
|
||
|
createRequest.setValue("值");
|
||
|
|
||
|
ProfilesCreateResponse createResponse = profilesManager.create(createRequest,token);
|
||
|
|
||
|
assertTrue(!createResponse.hasError() && createResponse.getId() > 0);
|
||
|
//删除数据
|
||
|
ProfilesDeleteRequest request = new ProfilesDeleteRequest();
|
||
|
request.setId(createResponse.getId());
|
||
|
|
||
|
ProfilesDeleteResponse response = profilesManager.delete(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testUpdate() {
|
||
|
//创建数据
|
||
|
ProfilesCreateRequest createRequest = new ProfilesCreateRequest();
|
||
|
createRequest.setActive("环境");
|
||
|
createRequest.setKey("键");
|
||
|
createRequest.setValue("值");
|
||
|
|
||
|
ProfilesCreateResponse createResponse = profilesManager.create(createRequest, token);
|
||
|
|
||
|
assertTrue(!createResponse.hasError());
|
||
|
|
||
|
//更新数据
|
||
|
ProfilesUpdateRequest request = new ProfilesUpdateRequest();
|
||
|
request.setId(createResponse.getId());
|
||
|
request.setActive("环境");
|
||
|
request.setKey("键");
|
||
|
request.setValue("值");
|
||
|
|
||
|
ProfilesUpdateResponse response = profilesManager.update(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError() && response.getResult() == 1L);
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testFind() {
|
||
|
ProfilesFindRequest request = new ProfilesFindRequest();
|
||
|
request.setActive("环境");
|
||
|
request.setKey("键");
|
||
|
|
||
|
ProfilesFindResponse response = profilesManager.find(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError());
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void testGet() {
|
||
|
//创建数据
|
||
|
ProfilesCreateRequest createRequest = new ProfilesCreateRequest();
|
||
|
createRequest.setActive("环境");
|
||
|
createRequest.setKey("键");
|
||
|
createRequest.setValue("值");
|
||
|
|
||
|
ProfilesCreateResponse createResponse = profilesManager.create(createRequest, token);
|
||
|
|
||
|
assertTrue(!createResponse.hasError());
|
||
|
|
||
|
//获得数据
|
||
|
ProfilesGetRequest request = new ProfilesGetRequest();
|
||
|
request.setId(createResponse.getId());
|
||
|
|
||
|
ProfilesGetResponse response = profilesManager.get(request,token);
|
||
|
|
||
|
assertTrue(!response.hasError() && response.getProfiles() != null);
|
||
|
}
|
||
|
}
|