123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 |
- package page;
- import com.github.javafaker.Faker;
- import io.qameta.allure.Description;
- import io.qameta.allure.Story;
- import io.restassured.path.json.JsonPath;
- import io.restassured.response.Response;
- import org.testng.Reporter;
- import org.testng.annotations.BeforeClass;
- import org.testng.annotations.Test;
- import util.JDBCUtils;
- import java.util.*;
- import static org.testng.Assert.*;
- public class PolicyPageTest {
- PolicyPage policyPage=new PolicyPage();
- LoginPage loginPage=LoginPage.getInstance();
- Faker fake=new Faker(Locale.CHINA);
- @BeforeClass
- public void beforeClass(){
- loginPage.getToken();
- }
- @Test
- @Description("正常测试用例:【申报通知】筛选关键字")
- @Story("政策文库")
- public void policyKeywordSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","佛山市");
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<String> title=jsonPath.get("data.hits.title");
- title.forEach(string -> {
- assertTrue(string.contains("佛山市"));
- });
- assertTrue(((int)response.path("data.total"))>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyKeywordSearchSuccess:【申报通知】筛选关键字,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:【申报通知】关键字为空,筛选出所有数据")
- @Story("政策文库")
- public void policyKeywordEmptySearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","");
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue((int)response.path("data.total")!=0);
- JsonPath jsonPath=new JsonPath(response.asString());
- List<String> time=jsonPath.get("data.hits.dispatchDate");
- boolean b=false;
- for(int i=0;i<time.size()-1;i++){
- if(Integer.parseInt(time.get(i).replace("-",""))>=Integer.parseInt(time.get(i+1).replace("-",""))){
- b=true;
- }else {
- b=false;
- }
- }
- assertTrue(b);
- assertTrue(((int)response.path("data.total"))>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyKeywordEmptySearchSuccess:【申报通知】关键字为空,筛选出所有数据,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:【申报通知】不存在的政策关键词,筛选结果为空")
- @Story("政策文库")
- public void policyKeywordFalseSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","null!");
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue((int)response.path("data.total")==0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyKeywordFalseSearchSuccess:【申报通知】不存在的政策关键词,筛选结果为空,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:【申报通知】筛选申报状态=申报中的政策")
- @Story("政策文库")
- public void policyApplyStartSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("applyStatus","1");
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<Integer> title=jsonPath.get("data.hits.minRemainDay");
- title.forEach(string -> {
- assertTrue(string>=0);
- });
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyApplyStartSearchSuccess:【申报通知】筛选申报状态=申报中的政策,筛选结果为空,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:【申报通知】筛选申报状态=已截止的政策")
- @Story("政策文库")
- public void policyApplyFinshSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("applyStatus","2");
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<Integer> title=jsonPath.get("data.hits.minRemainDay");
- title.forEach(string -> {
- assertTrue(string<=0);
- });
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyApplyFinshSearchSuccess:【申报通知】筛选申报状态=已截止的政策,断言失败!");
- throw e;
- }
- }
- // @Test
- // @Description("正常测试用例:【申报通知】筛选:截止日期降序")
- // @Story("政策文库")
- // public void policyRemainDayDescSearchSuccess(){
- // try{
- // HashMap<String,Object> map=new HashMap<>();
- // map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- // map.put("sortType","1");
- // Response response=policyPage.policySearch(map);
- // assertEquals((int)response.path("code"),200);
- // assertEquals(response.path("message"),"操作成功");
- // JsonPath jsonPath=new JsonPath(response.asString());
- // List<Integer> time=jsonPath.get("data.hits.minRemainDay");
- // boolean b=false;
- // for(int i=0;i<time.size()-1;i++){
- // if(time.get(i)<=time.get(i+1)){
- // b=true;
- // }else {
- // b=false;
- // }
- // }
- // assertTrue(b);
- // assertTrue((int)response.path("data.total")>0);
- // }catch (AssertionError e){
- // Reporter.log("PolicyPageTest.policyRemainDayDescSearchSuccess:【申报通知】筛选:截止日期降序,断言失败!");
- // throw e;
- // }
- // }
- @Test
- @Description("正常测试用例:【申报通知】筛选扶持方式")
- @Story("政策文库")
- public void policySupportSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- HashMap<Object,Object> uuid=policyPage.getSupportUuid();
- String sup1=(String)uuid.get("资金扶持");
- String sup2=(String)uuid.get("称号认定");
- map.put("uuidList",new Object[]{sup1,sup2});
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<List<HashMap<String,Object>>> project=jsonPath.get("data.hits.projects");
- project.forEach(projects->{
- ArrayList<String> supportMethods=new ArrayList<>();
- List<String> supportMethodList=new ArrayList<>();
- ArrayList<String> supportMethodUUID=new ArrayList<>();
- for(HashMap<String,Object> map1:projects){
- for(String str1:((String)map1.get("supportMethods")).split(",")){
- supportMethods.add(str1);
- }
- for(String str:(List<String>)map1.get("supportMethodList")){
- supportMethodList.add(str);
- }
- for(String str1:((String)map1.get("supportMethodUUID")).split(",")){
- supportMethodUUID.add(str1);
- }
- }
- assertTrue(supportMethods.contains("资金扶持") && supportMethods.contains("称号认定"));
- assertTrue(supportMethodUUID.contains(sup1) && supportMethodUUID.contains(sup2));
- assertTrue(supportMethodList.contains("资金扶持") && supportMethodList.contains("称号认定"));
- });
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policySupportSearchSuccess:【申报通知】筛选扶持方式,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:【政策文件】筛选关键字")
- @Story("政策文库")
- public void policyFileKeywordSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","佛山市");
- map.put("fileType",1);
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<String> title=jsonPath.get("data.hits.title");
- title.forEach(string -> {
- assertTrue(string.contains("佛山市"));
- });
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyFileKeywordSearchSuccess:【政策文件】筛选关键字,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:【政策文件】关键字为空,筛选出所有数据")
- @Story("政策文库")
- public void policyFileKeywordEmptySearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","");
- map.put("fileType",1);
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue((int)response.path("data.total")!=0);
- JsonPath jsonPath=new JsonPath(response.asString());
- List<String> time=jsonPath.get("data.hits.dispatchDate");
- boolean b=false;
- for(int i=0;i<time.size()-1;i++){
- if(Integer.parseInt(time.get(i).replace("-",""))>=Integer.parseInt(time.get(i+1).replace("-",""))){
- b=true;
- }else {
- b=false;
- }
- }
- assertTrue(b);
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyFileKeywordEmptySearchSuccess:【政策文件】关键字为空,筛选出所有数据,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:【政策文件】不存在的政策关键词,筛选结果为空")
- @Story("政策文库")
- public void policyFileKeywordFalseSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","null!");
- map.put("fileType",1);
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue((int)response.path("data.total")==0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyFileKeywordFalseSearchSuccess:【政策文件】不存在的政策关键词,筛选结果为空,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:【公示公告】筛选关键字")
- @Story("政策文库")
- public void noticeKeywordSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","佛山市");
- map.put("fileType",2);
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<String> title=jsonPath.get("data.hits.title");
- title.forEach(string -> {
- assertTrue(string.contains("佛山市"));
- });
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.noticeKeywordSearchSuccess:【公示公告】筛选关键字,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:【政策文件】关键字为空,筛选出所有数据")
- @Story("政策文库")
- public void noticeKeywordEmptySearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","");
- map.put("fileType",2);
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue((int)response.path("data.total")!=0);
- JsonPath jsonPath=new JsonPath(response.asString());
- List<String> time=jsonPath.get("data.hits.dispatchDate");
- boolean b=false;
- for(int i=0;i<time.size()-1;i++){
- if(Integer.parseInt(time.get(i).replace("-",""))>=Integer.parseInt(time.get(i+1).replace("-",""))){
- b=true;
- }else {
- b=false;
- }
- }
- assertTrue(b);
- assertTrue((int)response.path("data.total")>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.noticeKeywordEmptySearchSuccess:【政策文件】关键字为空,筛选出所有数据,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:【政策文件】不存在的政策关键词,筛选结果为空")
- @Story("政策文库")
- public void noticeKeywordFalseSearchSuccess(){
- try{
- HashMap<String,Object> map=new HashMap<>();
- map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
- map.put("keyWord","null!");
- map.put("fileType",2);
- Response response=policyPage.policySearch(map);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue((int)response.path("data.total")==0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.noticeKeywordFalseSearchSuccess:【政策文件】不存在的政策关键词,筛选结果为空,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:根据政策id查询政策详情")
- @Story("政策文库")
- public void enterPolicyDetailSuccess(){
- try{
- HashMap<String,Object> policymap=policyPage.getPolicyList().get(0);
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file","/apijson/page/policyPage/pcpPolicyDetailGetPolicyById.json");
- body.put("id",policymap.get("id"));
- Response response=policyPage.getPolicyDetail(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertEquals(response.path("data.id"),policymap.get("id"));
- assertEquals(response.path("data.declare_date"),policymap.get("declareDate"));
- assertEquals(response.path("data.fw_department"),policymap.get("department"));
- assertEquals(response.path("data.city"),policymap.get("city"));
- assertEquals(response.path("data.title"),policymap.get("title"));
- assertTrue(response.path("data.projectNum")==(Integer)((List<HashMap<String,Object>>)policymap.get("projects")).size());
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.enterPolicyDetailSuccess:根据政策id查询政策详情,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("异常测试用例:政策不存在为空,接口报错")
- @Story("政策文库")
- public void policyIdFailSearchFail(){
- try{
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file","/apijson/page/policyPage/pcpPolicyDetailGetPolicyById.json");
- body.put("id",0);
- Response response=policyPage.getPolicyDetail(body);
- assertEquals((int)response.path("code"),500);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.policyIdFailSearchFail:政策不存在为空,接口报错,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:根据id查询项目数据")
- @Story("政策文库")
- public void enterPolicyProjectSuccess(){
- try{
- HashMap<String,Object> policymap=policyPage.getPolicyList().get(0);
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetPolicyInterpretation.json");
- body.put("id",policymap.get("id"));
- Response response=policyPage.getProject(body);
- ArrayList<HashMap<String,Object>> projectsList1=(ArrayList<HashMap<String,Object>>)policymap.get("projects");
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- ArrayList<HashMap<String,Object>> projectsList2=response.path("data");
- Collections.sort(projectsList2, new Comparator<HashMap<String, Object>>() {
- @Override
- public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
- return Integer.compare(Integer.parseInt(""+o1.get("declareDate")),Integer.parseInt(""+o2.get("declareDate")));
- }
- });
- for(int i=0;i<projectsList1.size();i++){
- if((Integer) projectsList1.get(i).get("remainDay")==0){
- assertEquals(projectsList2.get(i).get("declareDate")+"","0");
- }
- if((Integer) projectsList1.get(i).get("remainDay")<0){
- assertEquals(projectsList2.get(i).get("declareDate"),"已截止");
- }
- if ((Integer) projectsList1.get(i).get("remainDay")>0){
- assertTrue((Integer) projectsList2.get(i).get("declareDate")>0);
- }
- assertEquals(projectsList2.get(i).get("id"),(projectsList1.get(i).get("id")));
- assertEquals(projectsList2.get(i).get("subtitle"),projectsList1.get(i).get("subtitle"));
- // assertEquals(projectsList2.get(i).get("subtitleDescribe"),projectsList1.get(i).get("supportStandard"));
- assertFalse(((List)projectsList1.get(i).get("supportMethodList")).retainAll((List)projectsList2.get(i).get("supportMode")));
- }
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.enterPolicyProjectSuccess:根据id查询项目数据,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:查询项目详情")
- @Story("政策文库")
- public void getPolicyProjectDetailSuccess(){
- try{
- List<Object[]> projectid= JDBCUtils.queryMulti("select id,zhengceid,subtitle from oa_formal_file where status='1' limit 0,100");
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetProjectDetails.json");
- body.put("projectId",projectid.get(0)[0]);
- Response response=policyPage.getProjectDetail(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue(response.path("data.id")==projectid.get(0)[0]);
- assertTrue(response.path("data.zhengceid")==projectid.get(0)[1]);
- assertEquals(response.path("data.subtitle"),projectid.get(0)[2]);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.getPolicyProjectDetailSuccess:查询项目详情,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:根据政策id获取政策文件")
- @Story("政策文库")
- public void getPolicyFileSuccess(){
- try{
- List<Integer> id= policyPage.getAllzhengceId();
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetDeclarationNotice.json");
- body.put("id",id.get(0));
- Response response=policyPage.getPolicyFile(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue(((String)response.path("data")).length()>0);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.getPolicyFileSuccess:根据政策id获取政策文件,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:根据政策id获取相关文件")
- @Story("政策文库")
- public void getRelevantFileSuccess(){
- try{
- List<Object[]> id= JDBCUtils.queryMulti("select id from oa_zhengce where status='1' and id in(select DISTINCT(fid) from oa_zhengce_attachment);");
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetRelevantFile.json");
- body.put("id",id.get(0)[0]);
- Response response=policyPage.getRevevanFile(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue(((List)response.path("data")).size()>=2);
- List<HashMap<String,Object>> list=response.path("data");
- assertEquals(list.get(0).get("type"),1);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.getRelevantFileSuccess:根据政策id获取相关文件,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:订阅成功")
- @Story("政策文库")
- public void subsribeSuccess(){
- try{
- System.out.println("用户id:"+loginPage.getMember_id());
- List<Integer> yidingyue= policyPage.getYidingyue();
- List<Integer> allzhengce= policyPage.getAllzhengceId();
- allzhengce.removeAll(yidingyue);
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailSetSubscribe.json");
- body.put("zid",allzhengce.get(0));
- body.put("mId",loginPage.getMember_id());
- Response response=policyPage.subscribeSuccess(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue(response.path("data")==null);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.subsribeSuccess:订阅成功,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:取消订阅成功")
- @Story("政策文库")
- public void cancelSubsribeSuccess(){
- try{
- List<Integer> yidingyue= policyPage.getYidingyue();
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailSetSubscribe.json");
- body.put("zid",yidingyue.get(0));
- body.put("mId",loginPage.getMember_id());
- body.put("type",1);
- Response response=policyPage.subscribeSuccess(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertTrue(response.path("data")==null);
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.cancelSubsribeSuccess:取消订阅成功,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:获取联系信息")
- @Story("政策文库")
- public void getContactSuccess(){
- try{
- List<Object[]> contact= JDBCUtils.queryMulti("select id,zhengceid,type,contact_unit,contact_name,contact_phone,contact_address,email,remark from oa_zhengce_contact");
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetReportNotice.json");
- body.put("id",contact.get(0)[1]);
- Response response=policyPage.getContact(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- JsonPath jsonPath=new JsonPath(response.asString());
- List<HashMap<String,Object>> rp=jsonPath.get("data.contact");
- List<Object[]> result= JDBCUtils.queryMulti("select id,zhengceid,type,contact_unit,contact_name,contact_phone,contact_address,email,remark from oa_zhengce_contact where zhengceid='"+contact.get(0)[1]+"';");
- for(int i=0;i<rp.size();i++) {
- assertEquals(rp.get(i).get("id"), result.get(i)[0]);
- assertEquals(rp.get(i).get("zhengceid"), result.get(i)[1]);
- assertEquals(rp.get(i).get("type"), result.get(i)[2]);
- assertEquals(rp.get(i).get("contactUnit"), result.get(i)[3]);
- assertEquals(rp.get(i).get("contactName"), result.get(i)[4]);
- assertEquals(rp.get(i).get("contactPhone"), result.get(i)[5]);
- assertEquals(rp.get(i).get("contactAddress"), result.get(i)[6]);
- assertEquals(rp.get(i).get("email"), result.get(i)[7]);
- assertEquals(rp.get(i).get("remark"), result.get(i)[8]);
- }
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.getContactSuccess:获取联系信息,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:判断政策已申报")
- @Story("政策文库")
- public void isdeclareTure(){
- try{
- List<Object[]> declareid=JDBCUtils.queryMulti("select zhengce_id from oa_member_declare where member_id='"+loginPage.getMember_id()+"';");
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailHasAddDeclare.json");
- body.put("memberId",loginPage.getMember_id());
- body.put("fieldId",declareid.get(0)[0]);
- Response response=policyPage.isDeclare(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- HashMap<String,Boolean> map=response.path("data");
- assertTrue(map.get("isDeclared"));
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.isdeclareTure:判断政策已申报,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:判断政策未申报")
- @Story("政策文库")
- public void isdeclareFalse(){
- try{
- List<Integer> policyid=policyPage.getAllzhengceId();
- List<Object[]> declareid=JDBCUtils.queryMulti("select zhengce_id from oa_member_declare where member_id='"+loginPage.getMember_id()+"';");
- for(Object[] o:declareid){
- policyid.remove(o[0]);
- }
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailHasAddDeclare.json");
- body.put("memberId",loginPage.getMember_id());
- body.put("fieldId",policyid.get(0));
- Response response=policyPage.isDeclare(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- HashMap<String,Boolean> map=response.path("data");
- assertFalse(map.get("isDeclared"));
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.isdeclareFalse:判断政策未申报,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:纳入申报计划成功")
- @Story("政策文库")
- public void addDeclarePlanSuccess(){
- try{
- List<Integer> projectid=policyPage.getAllprohectId();
- List<Integer> declareplanid=policyPage.getDeclarePlanId();
- projectid.removeAll(declareplanid);
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpDeclaremanagerXcxAddDeclarePlan.json");
- body.put("memberId",loginPage.getMember_id());
- body.put("formalId",projectid.get(0));
- body.put("type",0);
- Response response=policyPage.addDeclarePlan(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertEquals(response.path("data"),"纳入成功");
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.addDeclarePlanSuccess:纳入申报计划成功,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:取消纳入申报计划成功")
- @Story("政策文库")
- public void cancelDeclarePlanSuccess(){
- try{
- List<Integer> declareplanid=policyPage.getDeclarePlanId();
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpDeclaremanagerXcxAddDeclarePlan.json");
- body.put("memberId",loginPage.getMember_id());
- body.put("formalId",declareplanid.get(0));
- body.put("type",1);
- Response response=policyPage.addDeclarePlan(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertEquals(response.path("data"),"取消纳入成功");
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.cancelDeclarePlanSuccess:取消纳入申报计划成功,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:获取搜索历史关键字")
- @Story("政策文库")
- public void getSearchHistorySuccess(){
- try{
- List<Object[]> sql=JDBCUtils.queryMulti("select keyword from ims_ewei_shop_member_search_history where search_type='1' and user_id='"+loginPage.getMember_id()+"' order by create_time desc;");
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpLibrarysearchGetMemberSearchHistory.json");
- body.put("memberId",loginPage.getMember_id());
- Response response=policyPage.getSearchHistory(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- List<HashMap<String,Object>> list=response.path("data");
- for (int i=0;i<list.size();i++){
- assertEquals(list.get(i).get("keyword"),sql.get(i)[0]);
- }
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.getSearchHistorySuccess:获取搜索历史关键字,断言失败!");
- throw e;
- }
- }
- @Test
- @Description("正常测试用例:清空搜索历史关键字")
- @Story("政策文库")
- public void clearSearchHistorySuccess(){
- try{
- List<Object[]> sql=JDBCUtils.queryMulti("select keyword from ims_ewei_shop_member_search_history where search_type='1' and user_id='"+loginPage.getMember_id()+"' order by create_time desc;");
- HashMap<String,Object> body=new HashMap<>();
- body.put("_file", "/apijson/page/policyPage/pcpLibrarysearchDeleteMemberSearchHistory.json");
- body.put("ids",sql.get(0)[0]+","+sql.get(1)[0]);
- Response response=policyPage.clearSearchHistory(body);
- assertEquals((int)response.path("code"),200);
- assertEquals(response.path("message"),"操作成功");
- assertEquals(response.path("data"),"删除成功");
- }catch (AssertionError e){
- Reporter.log("PolicyPageTest.clearSearchHistorySuccess:清空搜索历史关键字,断言失败!");
- throw e;
- }
- }
- }
|