package ${domain}.wsys; import ${domain}.frame.auth.Token; import ${domain}.module.wsys.mgr.ProfilesManager; import ${domain}.module.wsys.req.ProfilesCreateRequest; import ${domain}.module.wsys.req.ProfilesDeleteRequest; import ${domain}.module.wsys.req.ProfilesFindRequest; import ${domain}.module.wsys.req.ProfilesUpdateRequest; import ${domain}.module.wsys.rsp.ProfilesCreateResponse; import ${domain}.module.wsys.rsp.ProfilesDeleteResponse; import ${domain}.module.wsys.rsp.ProfilesFindResponse; import ${domain}.module.wsys.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()); } }