Authored by zhaoyue

Mod file location

@@ -3,7 +3,7 @@ git add --all src/* @@ -3,7 +3,7 @@ git add --all src/*
3 git add --all lib/* 3 git add --all lib/*
4 git add push.sh 4 git add push.sh
5 git add pom.xml 5 git add pom.xml
6 -git commit -m "Add assert verify " 6 +git commit -m "Mod file location "
7 git push origin master 7 git push origin master
8 git status 8 git status
9 git pull 9 git pull
1 -package com.xkl;  
2 -  
3 -import org.json.JSONObject;  
4 -import org.junit.Assert;  
5 -import org.junit.Test;  
6 -  
7 -import java.util.HashMap;  
8 -import java.util.Map;  
9 -  
10 -/**  
11 - * Created by zhaoyue on 2017/3/11.  
12 - */  
13 -public class QrCodeTest {  
14 -  
15 - public static final String URL_GETQR_WITHTOKEN = Constants.URL_PREFIX + "/qrcode/getQrWithToken";  
16 - public static final String URL_GETQR_WITHOPNEID = Constants.URL_PREFIX + "/qrcode/getQrWithOpenId";  
17 -  
18 - /**  
19 - * 使用openid得到qrcode  
20 - */  
21 - @Test  
22 - public void testGetQrWithOpenid() {  
23 - Map<String, String> params = new HashMap<String, String>();  
24 - params.put("openId", Constants.USR_OPENID);  
25 - params.put("openIdType", Constants.USR_OPENID_TYPE);  
26 - params.put("t", HttpTools.getNow());  
27 - params.put("type", Constants.KEY_ID);  
28 - params.put("sign", HttpTools.getSign(params));  
29 - String response = HttpTools.requestByMap(URL_GETQR_WITHOPNEID, "GET", params);  
30 - System.out.println(response);  
31 - Assert.assertTrue(hasQrCode(response));  
32 - }  
33 -  
34 - /**  
35 - * 使用token得到qrcode  
36 - */  
37 - @Test  
38 - public void testGetQrWithToken() {  
39 - String token = TokenTest.loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD);  
40 - Map<String, String> params = new HashMap<String, String>();  
41 - params.put("t", HttpTools.getNow());  
42 - params.put("type", Constants.KEY_ID);  
43 - params.put("sign", HttpTools.getSign(params));  
44 - String response = HttpTools.requestByMapWithToken(URL_GETQR_WITHTOKEN, "GET", params, token);  
45 - System.out.println(response);  
46 - Assert.assertTrue(hasQrCode(response));  
47 - }  
48 -  
49 - private boolean hasQrCode(String responseStr) {  
50 - try {  
51 - JSONObject res = new JSONObject(responseStr);  
52 - String qrcode = res.getJSONObject("content").getString("qrcode");  
53 - Assert.assertNotEquals("qrcode", "");  
54 - Assert.assertNotEquals("qrcode", null);  
55 - } catch (Exception e) {  
56 - return false;  
57 - }  
58 - return true;  
59 - }  
60 -  
61 -}  
1 -package com.xkl; 1 +package com.xkl.datashare;
2 2
  3 +import com.xkl.Constants;
  4 +import com.xkl.HttpTools;
  5 +import com.xkl.RtnCodeTools;
3 import org.junit.Assert; 6 import org.junit.Assert;
4 import org.junit.Test; 7 import org.junit.Test;
5 8
@@ -75,7 +75,7 @@ public class Data { @@ -75,7 +75,7 @@ public class Data {
75 report.put("pulse", 79); 75 report.put("pulse", 79);
76 report.put("report_date", System.currentTimeMillis()); // physical examination time of this report 76 report.put("report_date", System.currentTimeMillis()); // physical examination time of this report
77 report.put("respiratory_rate", 18); 77 report.put("respiratory_rate", 18);
78 - report.put("sex", 0); // 0 is male; 1 is female 78 + report.put("sex", "0"); // 0 is male; 1 is female
79 report.put("stable", "99999"); 79 report.put("stable", "99999");
80 report.put("weight", 45); 80 report.put("weight", 45);
81 report.put("title", "AMP无创健康评估报告"); // report title 81 report.put("title", "AMP无创健康评估报告"); // report title
@@ -36,12 +36,17 @@ public class ReportTest { @@ -36,12 +36,17 @@ public class ReportTest {
36 36
37 @Test 37 @Test
38 public void testAddReport() { 38 public void testAddReport() {
39 - String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);  
40 - Map<String, String> params = new HashMap<String, String>();  
41 // 程序自动生成json报告。 39 // 程序自动生成json报告。
42 String report = Data.AMP_REPORT; 40 String report = Data.AMP_REPORT;
43 - // 从本地加载json报告。 41 +// 从本地加载json报告。
44 // String report = Data.readTxtFile("C:\\Users\\zhaoyue\\Desktop\\report.txt"); 42 // String report = Data.readTxtFile("C:\\Users\\zhaoyue\\Desktop\\report.txt");
  43 + System.out.print(report);
  44 + JSONObject rpJson = new JSONObject(report.trim());
  45 +// System.out.print(report);
  46 + String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
  47 + Map<String, String> params = new HashMap<String, String>();
  48 +
  49 +
45 params.put("json_report", report); 50 params.put("json_report", report);
46 String response = HttpTools.requestByMapWithToken(URL_REPORT, "POST", params, token); 51 String response = HttpTools.requestByMapWithToken(URL_REPORT, "POST", params, token);
47 Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.CODE_SUCC)); 52 Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.CODE_SUCC));