PolicyPageTest.java 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. package page;
  2. import com.github.javafaker.Faker;
  3. import io.qameta.allure.Description;
  4. import io.qameta.allure.Story;
  5. import io.restassured.path.json.JsonPath;
  6. import io.restassured.response.Response;
  7. import org.testng.Reporter;
  8. import org.testng.annotations.BeforeClass;
  9. import org.testng.annotations.Test;
  10. import util.JDBCUtils;
  11. import java.util.*;
  12. import static org.testng.Assert.*;
  13. public class PolicyPageTest {
  14. PolicyPage policyPage=new PolicyPage();
  15. LoginPage loginPage=LoginPage.getInstance();
  16. Faker fake=new Faker(Locale.CHINA);
  17. @BeforeClass
  18. public void beforeClass(){
  19. loginPage.getToken();
  20. }
  21. @Test
  22. @Description("正常测试用例:【申报通知】筛选关键字")
  23. @Story("政策文库")
  24. public void policyKeywordSearchSuccess(){
  25. try{
  26. HashMap<String,Object> map=new HashMap<>();
  27. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  28. map.put("keyWord","佛山市");
  29. Response response=policyPage.policySearch(map);
  30. assertEquals((int)response.path("code"),200);
  31. assertEquals(response.path("message"),"操作成功");
  32. JsonPath jsonPath=new JsonPath(response.asString());
  33. List<String> title=jsonPath.get("data.hits.title");
  34. title.forEach(string -> {
  35. assertTrue(string.contains("佛山市"));
  36. });
  37. assertTrue(((int)response.path("data.total"))>0);
  38. }catch (AssertionError e){
  39. Reporter.log("PolicyPageTest.policyKeywordSearchSuccess:【申报通知】筛选关键字,断言失败!");
  40. throw e;
  41. }
  42. }
  43. @Test
  44. @Description("异常测试用例:【申报通知】关键字为空,筛选出所有数据")
  45. @Story("政策文库")
  46. public void policyKeywordEmptySearchSuccess(){
  47. try{
  48. HashMap<String,Object> map=new HashMap<>();
  49. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  50. map.put("keyWord","");
  51. Response response=policyPage.policySearch(map);
  52. assertEquals((int)response.path("code"),200);
  53. assertEquals(response.path("message"),"操作成功");
  54. assertTrue((int)response.path("data.total")!=0);
  55. JsonPath jsonPath=new JsonPath(response.asString());
  56. List<String> time=jsonPath.get("data.hits.dispatchDate");
  57. boolean b=false;
  58. for(int i=0;i<time.size()-1;i++){
  59. if(Integer.parseInt(time.get(i).replace("-",""))>=Integer.parseInt(time.get(i+1).replace("-",""))){
  60. b=true;
  61. }else {
  62. b=false;
  63. }
  64. }
  65. assertTrue(b);
  66. assertTrue(((int)response.path("data.total"))>0);
  67. }catch (AssertionError e){
  68. Reporter.log("PolicyPageTest.policyKeywordEmptySearchSuccess:【申报通知】关键字为空,筛选出所有数据,断言失败!");
  69. throw e;
  70. }
  71. }
  72. @Test
  73. @Description("异常测试用例:【申报通知】不存在的政策关键词,筛选结果为空")
  74. @Story("政策文库")
  75. public void policyKeywordFalseSearchSuccess(){
  76. try{
  77. HashMap<String,Object> map=new HashMap<>();
  78. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  79. map.put("keyWord","null!");
  80. Response response=policyPage.policySearch(map);
  81. assertEquals((int)response.path("code"),200);
  82. assertEquals(response.path("message"),"操作成功");
  83. assertTrue((int)response.path("data.total")==0);
  84. }catch (AssertionError e){
  85. Reporter.log("PolicyPageTest.policyKeywordFalseSearchSuccess:【申报通知】不存在的政策关键词,筛选结果为空,断言失败!");
  86. throw e;
  87. }
  88. }
  89. @Test
  90. @Description("正常测试用例:【申报通知】筛选申报状态=申报中的政策")
  91. @Story("政策文库")
  92. public void policyApplyStartSearchSuccess(){
  93. try{
  94. HashMap<String,Object> map=new HashMap<>();
  95. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  96. map.put("applyStatus","1");
  97. Response response=policyPage.policySearch(map);
  98. assertEquals((int)response.path("code"),200);
  99. assertEquals(response.path("message"),"操作成功");
  100. JsonPath jsonPath=new JsonPath(response.asString());
  101. List<Integer> title=jsonPath.get("data.hits.minRemainDay");
  102. title.forEach(string -> {
  103. assertTrue(string>=0);
  104. });
  105. assertTrue((int)response.path("data.total")>0);
  106. }catch (AssertionError e){
  107. Reporter.log("PolicyPageTest.policyApplyStartSearchSuccess:【申报通知】筛选申报状态=申报中的政策,筛选结果为空,断言失败!");
  108. throw e;
  109. }
  110. }
  111. @Test
  112. @Description("正常测试用例:【申报通知】筛选申报状态=已截止的政策")
  113. @Story("政策文库")
  114. public void policyApplyFinshSearchSuccess(){
  115. try{
  116. HashMap<String,Object> map=new HashMap<>();
  117. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  118. map.put("applyStatus","2");
  119. Response response=policyPage.policySearch(map);
  120. assertEquals((int)response.path("code"),200);
  121. assertEquals(response.path("message"),"操作成功");
  122. JsonPath jsonPath=new JsonPath(response.asString());
  123. List<Integer> title=jsonPath.get("data.hits.minRemainDay");
  124. title.forEach(string -> {
  125. assertTrue(string<=0);
  126. });
  127. assertTrue((int)response.path("data.total")>0);
  128. }catch (AssertionError e){
  129. Reporter.log("PolicyPageTest.policyApplyFinshSearchSuccess:【申报通知】筛选申报状态=已截止的政策,断言失败!");
  130. throw e;
  131. }
  132. }
  133. // @Test
  134. // @Description("正常测试用例:【申报通知】筛选:截止日期降序")
  135. // @Story("政策文库")
  136. // public void policyRemainDayDescSearchSuccess(){
  137. // try{
  138. // HashMap<String,Object> map=new HashMap<>();
  139. // map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  140. // map.put("sortType","1");
  141. // Response response=policyPage.policySearch(map);
  142. // assertEquals((int)response.path("code"),200);
  143. // assertEquals(response.path("message"),"操作成功");
  144. // JsonPath jsonPath=new JsonPath(response.asString());
  145. // List<Integer> time=jsonPath.get("data.hits.minRemainDay");
  146. // boolean b=false;
  147. // for(int i=0;i<time.size()-1;i++){
  148. // if(time.get(i)<=time.get(i+1)){
  149. // b=true;
  150. // }else {
  151. // b=false;
  152. // }
  153. // }
  154. // assertTrue(b);
  155. // assertTrue((int)response.path("data.total")>0);
  156. // }catch (AssertionError e){
  157. // Reporter.log("PolicyPageTest.policyRemainDayDescSearchSuccess:【申报通知】筛选:截止日期降序,断言失败!");
  158. // throw e;
  159. // }
  160. // }
  161. @Test
  162. @Description("正常测试用例:【申报通知】筛选扶持方式")
  163. @Story("政策文库")
  164. public void policySupportSearchSuccess(){
  165. try{
  166. HashMap<String,Object> map=new HashMap<>();
  167. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  168. HashMap<Object,Object> uuid=policyPage.getSupportUuid();
  169. String sup1=(String)uuid.get("资金扶持");
  170. String sup2=(String)uuid.get("称号认定");
  171. map.put("uuidList",new Object[]{sup1,sup2});
  172. Response response=policyPage.policySearch(map);
  173. assertEquals((int)response.path("code"),200);
  174. assertEquals(response.path("message"),"操作成功");
  175. JsonPath jsonPath=new JsonPath(response.asString());
  176. List<List<HashMap<String,Object>>> project=jsonPath.get("data.hits.projects");
  177. project.forEach(projects->{
  178. ArrayList<String> supportMethods=new ArrayList<>();
  179. List<String> supportMethodList=new ArrayList<>();
  180. ArrayList<String> supportMethodUUID=new ArrayList<>();
  181. for(HashMap<String,Object> map1:projects){
  182. for(String str1:((String)map1.get("supportMethods")).split(",")){
  183. supportMethods.add(str1);
  184. }
  185. for(String str:(List<String>)map1.get("supportMethodList")){
  186. supportMethodList.add(str);
  187. }
  188. for(String str1:((String)map1.get("supportMethodUUID")).split(",")){
  189. supportMethodUUID.add(str1);
  190. }
  191. }
  192. assertTrue(supportMethods.contains("资金扶持") && supportMethods.contains("称号认定"));
  193. assertTrue(supportMethodUUID.contains(sup1) && supportMethodUUID.contains(sup2));
  194. assertTrue(supportMethodList.contains("资金扶持") && supportMethodList.contains("称号认定"));
  195. });
  196. assertTrue((int)response.path("data.total")>0);
  197. }catch (AssertionError e){
  198. Reporter.log("PolicyPageTest.policySupportSearchSuccess:【申报通知】筛选扶持方式,断言失败!");
  199. throw e;
  200. }
  201. }
  202. @Test
  203. @Description("正常测试用例:【政策文件】筛选关键字")
  204. @Story("政策文库")
  205. public void policyFileKeywordSearchSuccess(){
  206. try{
  207. HashMap<String,Object> map=new HashMap<>();
  208. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  209. map.put("keyWord","佛山市");
  210. map.put("fileType",1);
  211. Response response=policyPage.policySearch(map);
  212. assertEquals((int)response.path("code"),200);
  213. assertEquals(response.path("message"),"操作成功");
  214. JsonPath jsonPath=new JsonPath(response.asString());
  215. List<String> title=jsonPath.get("data.hits.title");
  216. title.forEach(string -> {
  217. assertTrue(string.contains("佛山市"));
  218. });
  219. assertTrue((int)response.path("data.total")>0);
  220. }catch (AssertionError e){
  221. Reporter.log("PolicyPageTest.policyFileKeywordSearchSuccess:【政策文件】筛选关键字,断言失败!");
  222. throw e;
  223. }
  224. }
  225. @Test
  226. @Description("异常测试用例:【政策文件】关键字为空,筛选出所有数据")
  227. @Story("政策文库")
  228. public void policyFileKeywordEmptySearchSuccess(){
  229. try{
  230. HashMap<String,Object> map=new HashMap<>();
  231. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  232. map.put("keyWord","");
  233. map.put("fileType",1);
  234. Response response=policyPage.policySearch(map);
  235. assertEquals((int)response.path("code"),200);
  236. assertEquals(response.path("message"),"操作成功");
  237. assertTrue((int)response.path("data.total")!=0);
  238. JsonPath jsonPath=new JsonPath(response.asString());
  239. List<String> time=jsonPath.get("data.hits.dispatchDate");
  240. boolean b=false;
  241. for(int i=0;i<time.size()-1;i++){
  242. if(Integer.parseInt(time.get(i).replace("-",""))>=Integer.parseInt(time.get(i+1).replace("-",""))){
  243. b=true;
  244. }else {
  245. b=false;
  246. }
  247. }
  248. assertTrue(b);
  249. assertTrue((int)response.path("data.total")>0);
  250. }catch (AssertionError e){
  251. Reporter.log("PolicyPageTest.policyFileKeywordEmptySearchSuccess:【政策文件】关键字为空,筛选出所有数据,断言失败!");
  252. throw e;
  253. }
  254. }
  255. @Test
  256. @Description("异常测试用例:【政策文件】不存在的政策关键词,筛选结果为空")
  257. @Story("政策文库")
  258. public void policyFileKeywordFalseSearchSuccess(){
  259. try{
  260. HashMap<String,Object> map=new HashMap<>();
  261. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  262. map.put("keyWord","null!");
  263. map.put("fileType",1);
  264. Response response=policyPage.policySearch(map);
  265. assertEquals((int)response.path("code"),200);
  266. assertEquals(response.path("message"),"操作成功");
  267. assertTrue((int)response.path("data.total")==0);
  268. }catch (AssertionError e){
  269. Reporter.log("PolicyPageTest.policyFileKeywordFalseSearchSuccess:【政策文件】不存在的政策关键词,筛选结果为空,断言失败!");
  270. throw e;
  271. }
  272. }
  273. @Test
  274. @Description("正常测试用例:【公示公告】筛选关键字")
  275. @Story("政策文库")
  276. public void noticeKeywordSearchSuccess(){
  277. try{
  278. HashMap<String,Object> map=new HashMap<>();
  279. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  280. map.put("keyWord","佛山市");
  281. map.put("fileType",2);
  282. Response response=policyPage.policySearch(map);
  283. assertEquals((int)response.path("code"),200);
  284. assertEquals(response.path("message"),"操作成功");
  285. JsonPath jsonPath=new JsonPath(response.asString());
  286. List<String> title=jsonPath.get("data.hits.title");
  287. title.forEach(string -> {
  288. assertTrue(string.contains("佛山市"));
  289. });
  290. assertTrue((int)response.path("data.total")>0);
  291. }catch (AssertionError e){
  292. Reporter.log("PolicyPageTest.noticeKeywordSearchSuccess:【公示公告】筛选关键字,断言失败!");
  293. throw e;
  294. }
  295. }
  296. @Test
  297. @Description("异常测试用例:【政策文件】关键字为空,筛选出所有数据")
  298. @Story("政策文库")
  299. public void noticeKeywordEmptySearchSuccess(){
  300. try{
  301. HashMap<String,Object> map=new HashMap<>();
  302. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  303. map.put("keyWord","");
  304. map.put("fileType",2);
  305. Response response=policyPage.policySearch(map);
  306. assertEquals((int)response.path("code"),200);
  307. assertEquals(response.path("message"),"操作成功");
  308. assertTrue((int)response.path("data.total")!=0);
  309. JsonPath jsonPath=new JsonPath(response.asString());
  310. List<String> time=jsonPath.get("data.hits.dispatchDate");
  311. boolean b=false;
  312. for(int i=0;i<time.size()-1;i++){
  313. if(Integer.parseInt(time.get(i).replace("-",""))>=Integer.parseInt(time.get(i+1).replace("-",""))){
  314. b=true;
  315. }else {
  316. b=false;
  317. }
  318. }
  319. assertTrue(b);
  320. assertTrue((int)response.path("data.total")>0);
  321. }catch (AssertionError e){
  322. Reporter.log("PolicyPageTest.noticeKeywordEmptySearchSuccess:【政策文件】关键字为空,筛选出所有数据,断言失败!");
  323. throw e;
  324. }
  325. }
  326. @Test
  327. @Description("异常测试用例:【政策文件】不存在的政策关键词,筛选结果为空")
  328. @Story("政策文库")
  329. public void noticeKeywordFalseSearchSuccess(){
  330. try{
  331. HashMap<String,Object> map=new HashMap<>();
  332. map.put("_file", "/apijson/page/policyPage/queryPolicyByES.json");
  333. map.put("keyWord","null!");
  334. map.put("fileType",2);
  335. Response response=policyPage.policySearch(map);
  336. assertEquals((int)response.path("code"),200);
  337. assertEquals(response.path("message"),"操作成功");
  338. assertTrue((int)response.path("data.total")==0);
  339. }catch (AssertionError e){
  340. Reporter.log("PolicyPageTest.noticeKeywordFalseSearchSuccess:【政策文件】不存在的政策关键词,筛选结果为空,断言失败!");
  341. throw e;
  342. }
  343. }
  344. @Test
  345. @Description("正常测试用例:根据政策id查询政策详情")
  346. @Story("政策文库")
  347. public void enterPolicyDetailSuccess(){
  348. try{
  349. HashMap<String,Object> policymap=policyPage.getPolicyList().get(0);
  350. HashMap<String,Object> body=new HashMap<>();
  351. body.put("_file","/apijson/page/policyPage/pcpPolicyDetailGetPolicyById.json");
  352. body.put("id",policymap.get("id"));
  353. Response response=policyPage.getPolicyDetail(body);
  354. assertEquals((int)response.path("code"),200);
  355. assertEquals(response.path("message"),"操作成功");
  356. assertEquals(response.path("data.id"),policymap.get("id"));
  357. assertEquals(response.path("data.declare_date"),policymap.get("declareDate"));
  358. assertEquals(response.path("data.fw_department"),policymap.get("department"));
  359. assertEquals(response.path("data.city"),policymap.get("city"));
  360. assertEquals(response.path("data.title"),policymap.get("title"));
  361. assertTrue(response.path("data.projectNum")==(Integer)((List<HashMap<String,Object>>)policymap.get("projects")).size());
  362. }catch (AssertionError e){
  363. Reporter.log("PolicyPageTest.enterPolicyDetailSuccess:根据政策id查询政策详情,断言失败!");
  364. throw e;
  365. }
  366. }
  367. @Test
  368. @Description("异常测试用例:政策不存在为空,接口报错")
  369. @Story("政策文库")
  370. public void policyIdFailSearchFail(){
  371. try{
  372. HashMap<String,Object> body=new HashMap<>();
  373. body.put("_file","/apijson/page/policyPage/pcpPolicyDetailGetPolicyById.json");
  374. body.put("id",0);
  375. Response response=policyPage.getPolicyDetail(body);
  376. assertEquals((int)response.path("code"),500);
  377. }catch (AssertionError e){
  378. Reporter.log("PolicyPageTest.policyIdFailSearchFail:政策不存在为空,接口报错,断言失败!");
  379. throw e;
  380. }
  381. }
  382. @Test
  383. @Description("正常测试用例:根据id查询项目数据")
  384. @Story("政策文库")
  385. public void enterPolicyProjectSuccess(){
  386. try{
  387. HashMap<String,Object> policymap=policyPage.getPolicyList().get(0);
  388. HashMap<String,Object> body=new HashMap<>();
  389. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetPolicyInterpretation.json");
  390. body.put("id",policymap.get("id"));
  391. Response response=policyPage.getProject(body);
  392. ArrayList<HashMap<String,Object>> projectsList1=(ArrayList<HashMap<String,Object>>)policymap.get("projects");
  393. assertEquals((int)response.path("code"),200);
  394. assertEquals(response.path("message"),"操作成功");
  395. ArrayList<HashMap<String,Object>> projectsList2=response.path("data");
  396. Collections.sort(projectsList2, new Comparator<HashMap<String, Object>>() {
  397. @Override
  398. public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) {
  399. return Integer.compare(Integer.parseInt(""+o1.get("declareDate")),Integer.parseInt(""+o2.get("declareDate")));
  400. }
  401. });
  402. for(int i=0;i<projectsList1.size();i++){
  403. if((Integer) projectsList1.get(i).get("remainDay")==0){
  404. assertEquals(projectsList2.get(i).get("declareDate")+"","0");
  405. }
  406. if((Integer) projectsList1.get(i).get("remainDay")<0){
  407. assertEquals(projectsList2.get(i).get("declareDate"),"已截止");
  408. }
  409. if ((Integer) projectsList1.get(i).get("remainDay")>0){
  410. assertTrue((Integer) projectsList2.get(i).get("declareDate")>0);
  411. }
  412. assertEquals(projectsList2.get(i).get("id"),(projectsList1.get(i).get("id")));
  413. assertEquals(projectsList2.get(i).get("subtitle"),projectsList1.get(i).get("subtitle"));
  414. // assertEquals(projectsList2.get(i).get("subtitleDescribe"),projectsList1.get(i).get("supportStandard"));
  415. assertFalse(((List)projectsList1.get(i).get("supportMethodList")).retainAll((List)projectsList2.get(i).get("supportMode")));
  416. }
  417. }catch (AssertionError e){
  418. Reporter.log("PolicyPageTest.enterPolicyProjectSuccess:根据id查询项目数据,断言失败!");
  419. throw e;
  420. }
  421. }
  422. @Test
  423. @Description("正常测试用例:查询项目详情")
  424. @Story("政策文库")
  425. public void getPolicyProjectDetailSuccess(){
  426. try{
  427. List<Object[]> projectid= JDBCUtils.queryMulti("select id,zhengceid,subtitle from oa_formal_file where status='1' limit 0,100");
  428. HashMap<String,Object> body=new HashMap<>();
  429. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetProjectDetails.json");
  430. body.put("projectId",projectid.get(0)[0]);
  431. Response response=policyPage.getProjectDetail(body);
  432. assertEquals((int)response.path("code"),200);
  433. assertEquals(response.path("message"),"操作成功");
  434. assertTrue(response.path("data.id")==projectid.get(0)[0]);
  435. assertTrue(response.path("data.zhengceid")==projectid.get(0)[1]);
  436. assertEquals(response.path("data.subtitle"),projectid.get(0)[2]);
  437. }catch (AssertionError e){
  438. Reporter.log("PolicyPageTest.getPolicyProjectDetailSuccess:查询项目详情,断言失败!");
  439. throw e;
  440. }
  441. }
  442. @Test
  443. @Description("正常测试用例:根据政策id获取政策文件")
  444. @Story("政策文库")
  445. public void getPolicyFileSuccess(){
  446. try{
  447. List<Integer> id= policyPage.getAllzhengceId();
  448. HashMap<String,Object> body=new HashMap<>();
  449. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetDeclarationNotice.json");
  450. body.put("id",id.get(0));
  451. Response response=policyPage.getPolicyFile(body);
  452. assertEquals((int)response.path("code"),200);
  453. assertEquals(response.path("message"),"操作成功");
  454. assertTrue(((String)response.path("data")).length()>0);
  455. }catch (AssertionError e){
  456. Reporter.log("PolicyPageTest.getPolicyFileSuccess:根据政策id获取政策文件,断言失败!");
  457. throw e;
  458. }
  459. }
  460. @Test
  461. @Description("正常测试用例:根据政策id获取相关文件")
  462. @Story("政策文库")
  463. public void getRelevantFileSuccess(){
  464. try{
  465. List<Object[]> id= JDBCUtils.queryMulti("select id from oa_zhengce where status='1' and id in(select DISTINCT(fid) from oa_zhengce_attachment);");
  466. HashMap<String,Object> body=new HashMap<>();
  467. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetRelevantFile.json");
  468. body.put("id",id.get(0)[0]);
  469. Response response=policyPage.getRevevanFile(body);
  470. assertEquals((int)response.path("code"),200);
  471. assertEquals(response.path("message"),"操作成功");
  472. assertTrue(((List)response.path("data")).size()>=2);
  473. List<HashMap<String,Object>> list=response.path("data");
  474. assertEquals(list.get(0).get("type"),1);
  475. }catch (AssertionError e){
  476. Reporter.log("PolicyPageTest.getRelevantFileSuccess:根据政策id获取相关文件,断言失败!");
  477. throw e;
  478. }
  479. }
  480. @Test
  481. @Description("正常测试用例:订阅成功")
  482. @Story("政策文库")
  483. public void subsribeSuccess(){
  484. try{
  485. System.out.println("用户id:"+loginPage.getMember_id());
  486. List<Integer> yidingyue= policyPage.getYidingyue();
  487. List<Integer> allzhengce= policyPage.getAllzhengceId();
  488. allzhengce.removeAll(yidingyue);
  489. HashMap<String,Object> body=new HashMap<>();
  490. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailSetSubscribe.json");
  491. body.put("zid",allzhengce.get(0));
  492. body.put("mId",loginPage.getMember_id());
  493. Response response=policyPage.subscribeSuccess(body);
  494. assertEquals((int)response.path("code"),200);
  495. assertEquals(response.path("message"),"操作成功");
  496. assertTrue(response.path("data")==null);
  497. }catch (AssertionError e){
  498. Reporter.log("PolicyPageTest.subsribeSuccess:订阅成功,断言失败!");
  499. throw e;
  500. }
  501. }
  502. @Test
  503. @Description("正常测试用例:取消订阅成功")
  504. @Story("政策文库")
  505. public void cancelSubsribeSuccess(){
  506. try{
  507. List<Integer> yidingyue= policyPage.getYidingyue();
  508. HashMap<String,Object> body=new HashMap<>();
  509. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailSetSubscribe.json");
  510. body.put("zid",yidingyue.get(0));
  511. body.put("mId",loginPage.getMember_id());
  512. body.put("type",1);
  513. Response response=policyPage.subscribeSuccess(body);
  514. assertEquals((int)response.path("code"),200);
  515. assertEquals(response.path("message"),"操作成功");
  516. assertTrue(response.path("data")==null);
  517. }catch (AssertionError e){
  518. Reporter.log("PolicyPageTest.cancelSubsribeSuccess:取消订阅成功,断言失败!");
  519. throw e;
  520. }
  521. }
  522. @Test
  523. @Description("正常测试用例:获取联系信息")
  524. @Story("政策文库")
  525. public void getContactSuccess(){
  526. try{
  527. List<Object[]> contact= JDBCUtils.queryMulti("select id,zhengceid,type,contact_unit,contact_name,contact_phone,contact_address,email,remark from oa_zhengce_contact");
  528. HashMap<String,Object> body=new HashMap<>();
  529. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailGetReportNotice.json");
  530. body.put("id",contact.get(0)[1]);
  531. Response response=policyPage.getContact(body);
  532. assertEquals((int)response.path("code"),200);
  533. assertEquals(response.path("message"),"操作成功");
  534. JsonPath jsonPath=new JsonPath(response.asString());
  535. List<HashMap<String,Object>> rp=jsonPath.get("data.contact");
  536. 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]+"';");
  537. for(int i=0;i<rp.size();i++) {
  538. assertEquals(rp.get(i).get("id"), result.get(i)[0]);
  539. assertEquals(rp.get(i).get("zhengceid"), result.get(i)[1]);
  540. assertEquals(rp.get(i).get("type"), result.get(i)[2]);
  541. assertEquals(rp.get(i).get("contactUnit"), result.get(i)[3]);
  542. assertEquals(rp.get(i).get("contactName"), result.get(i)[4]);
  543. assertEquals(rp.get(i).get("contactPhone"), result.get(i)[5]);
  544. assertEquals(rp.get(i).get("contactAddress"), result.get(i)[6]);
  545. assertEquals(rp.get(i).get("email"), result.get(i)[7]);
  546. assertEquals(rp.get(i).get("remark"), result.get(i)[8]);
  547. }
  548. }catch (AssertionError e){
  549. Reporter.log("PolicyPageTest.getContactSuccess:获取联系信息,断言失败!");
  550. throw e;
  551. }
  552. }
  553. @Test
  554. @Description("正常测试用例:判断政策已申报")
  555. @Story("政策文库")
  556. public void isdeclareTure(){
  557. try{
  558. List<Object[]> declareid=JDBCUtils.queryMulti("select zhengce_id from oa_member_declare where member_id='"+loginPage.getMember_id()+"';");
  559. HashMap<String,Object> body=new HashMap<>();
  560. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailHasAddDeclare.json");
  561. body.put("memberId",loginPage.getMember_id());
  562. body.put("fieldId",declareid.get(0)[0]);
  563. Response response=policyPage.isDeclare(body);
  564. assertEquals((int)response.path("code"),200);
  565. assertEquals(response.path("message"),"操作成功");
  566. HashMap<String,Boolean> map=response.path("data");
  567. assertTrue(map.get("isDeclared"));
  568. }catch (AssertionError e){
  569. Reporter.log("PolicyPageTest.isdeclareTure:判断政策已申报,断言失败!");
  570. throw e;
  571. }
  572. }
  573. @Test
  574. @Description("正常测试用例:判断政策未申报")
  575. @Story("政策文库")
  576. public void isdeclareFalse(){
  577. try{
  578. List<Integer> policyid=policyPage.getAllzhengceId();
  579. List<Object[]> declareid=JDBCUtils.queryMulti("select zhengce_id from oa_member_declare where member_id='"+loginPage.getMember_id()+"';");
  580. for(Object[] o:declareid){
  581. policyid.remove(o[0]);
  582. }
  583. HashMap<String,Object> body=new HashMap<>();
  584. body.put("_file", "/apijson/page/policyPage/pcpPolicyDetailHasAddDeclare.json");
  585. body.put("memberId",loginPage.getMember_id());
  586. body.put("fieldId",policyid.get(0));
  587. Response response=policyPage.isDeclare(body);
  588. assertEquals((int)response.path("code"),200);
  589. assertEquals(response.path("message"),"操作成功");
  590. HashMap<String,Boolean> map=response.path("data");
  591. assertFalse(map.get("isDeclared"));
  592. }catch (AssertionError e){
  593. Reporter.log("PolicyPageTest.isdeclareFalse:判断政策未申报,断言失败!");
  594. throw e;
  595. }
  596. }
  597. @Test
  598. @Description("正常测试用例:纳入申报计划成功")
  599. @Story("政策文库")
  600. public void addDeclarePlanSuccess(){
  601. try{
  602. List<Integer> projectid=policyPage.getAllprohectId();
  603. List<Integer> declareplanid=policyPage.getDeclarePlanId();
  604. projectid.removeAll(declareplanid);
  605. HashMap<String,Object> body=new HashMap<>();
  606. body.put("_file", "/apijson/page/policyPage/pcpDeclaremanagerXcxAddDeclarePlan.json");
  607. body.put("memberId",loginPage.getMember_id());
  608. body.put("formalId",projectid.get(0));
  609. body.put("type",0);
  610. Response response=policyPage.addDeclarePlan(body);
  611. assertEquals((int)response.path("code"),200);
  612. assertEquals(response.path("message"),"操作成功");
  613. assertEquals(response.path("data"),"纳入成功");
  614. }catch (AssertionError e){
  615. Reporter.log("PolicyPageTest.addDeclarePlanSuccess:纳入申报计划成功,断言失败!");
  616. throw e;
  617. }
  618. }
  619. @Test
  620. @Description("正常测试用例:取消纳入申报计划成功")
  621. @Story("政策文库")
  622. public void cancelDeclarePlanSuccess(){
  623. try{
  624. List<Integer> declareplanid=policyPage.getDeclarePlanId();
  625. HashMap<String,Object> body=new HashMap<>();
  626. body.put("_file", "/apijson/page/policyPage/pcpDeclaremanagerXcxAddDeclarePlan.json");
  627. body.put("memberId",loginPage.getMember_id());
  628. body.put("formalId",declareplanid.get(0));
  629. body.put("type",1);
  630. Response response=policyPage.addDeclarePlan(body);
  631. assertEquals((int)response.path("code"),200);
  632. assertEquals(response.path("message"),"操作成功");
  633. assertEquals(response.path("data"),"取消纳入成功");
  634. }catch (AssertionError e){
  635. Reporter.log("PolicyPageTest.cancelDeclarePlanSuccess:取消纳入申报计划成功,断言失败!");
  636. throw e;
  637. }
  638. }
  639. @Test
  640. @Description("正常测试用例:获取搜索历史关键字")
  641. @Story("政策文库")
  642. public void getSearchHistorySuccess(){
  643. try{
  644. 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;");
  645. HashMap<String,Object> body=new HashMap<>();
  646. body.put("_file", "/apijson/page/policyPage/pcpLibrarysearchGetMemberSearchHistory.json");
  647. body.put("memberId",loginPage.getMember_id());
  648. Response response=policyPage.getSearchHistory(body);
  649. assertEquals((int)response.path("code"),200);
  650. assertEquals(response.path("message"),"操作成功");
  651. List<HashMap<String,Object>> list=response.path("data");
  652. for (int i=0;i<list.size();i++){
  653. assertEquals(list.get(i).get("keyword"),sql.get(i)[0]);
  654. }
  655. }catch (AssertionError e){
  656. Reporter.log("PolicyPageTest.getSearchHistorySuccess:获取搜索历史关键字,断言失败!");
  657. throw e;
  658. }
  659. }
  660. @Test
  661. @Description("正常测试用例:清空搜索历史关键字")
  662. @Story("政策文库")
  663. public void clearSearchHistorySuccess(){
  664. try{
  665. 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;");
  666. HashMap<String,Object> body=new HashMap<>();
  667. body.put("_file", "/apijson/page/policyPage/pcpLibrarysearchDeleteMemberSearchHistory.json");
  668. body.put("ids",sql.get(0)[0]+","+sql.get(1)[0]);
  669. Response response=policyPage.clearSearchHistory(body);
  670. assertEquals((int)response.path("code"),200);
  671. assertEquals(response.path("message"),"操作成功");
  672. assertEquals(response.path("data"),"删除成功");
  673. }catch (AssertionError e){
  674. Reporter.log("PolicyPageTest.clearSearchHistorySuccess:清空搜索历史关键字,断言失败!");
  675. throw e;
  676. }
  677. }
  678. }