Authored by zhaoyue

Mod file location

... ... @@ -3,7 +3,7 @@ git add --all src/*
git add --all lib/*
git add push.sh
git add pom.xml
git commit -m "Add assert verify "
git commit -m "Mod file location "
git push origin master
git status
git pull
... ...
package com.xkl;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoyue on 2017/3/11.
*/
public class QrCodeTest {
public static final String URL_GETQR_WITHTOKEN = Constants.URL_PREFIX + "/qrcode/getQrWithToken";
public static final String URL_GETQR_WITHOPNEID = Constants.URL_PREFIX + "/qrcode/getQrWithOpenId";
/**
* 使用openid得到qrcode
*/
@Test
public void testGetQrWithOpenid() {
Map<String, String> params = new HashMap<String, String>();
params.put("openId", Constants.USR_OPENID);
params.put("openIdType", Constants.USR_OPENID_TYPE);
params.put("t", HttpTools.getNow());
params.put("type", Constants.KEY_ID);
params.put("sign", HttpTools.getSign(params));
String response = HttpTools.requestByMap(URL_GETQR_WITHOPNEID, "GET", params);
System.out.println(response);
Assert.assertTrue(hasQrCode(response));
}
/**
* 使用token得到qrcode
*/
@Test
public void testGetQrWithToken() {
String token = TokenTest.loginAndGetToken(Constants.USR_ACC, Constants.USR_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("t", HttpTools.getNow());
params.put("type", Constants.KEY_ID);
params.put("sign", HttpTools.getSign(params));
String response = HttpTools.requestByMapWithToken(URL_GETQR_WITHTOKEN, "GET", params, token);
System.out.println(response);
Assert.assertTrue(hasQrCode(response));
}
private boolean hasQrCode(String responseStr) {
try {
JSONObject res = new JSONObject(responseStr);
String qrcode = res.getJSONObject("content").getString("qrcode");
Assert.assertNotEquals("qrcode", "");
Assert.assertNotEquals("qrcode", null);
} catch (Exception e) {
return false;
}
return true;
}
}
package com.xkl;
package com.xkl.datashare;
import com.xkl.Constants;
import com.xkl.HttpTools;
import com.xkl.RtnCodeTools;
import org.junit.Assert;
import org.junit.Test;
... ...
... ... @@ -75,7 +75,7 @@ public class Data {
report.put("pulse", 79);
report.put("report_date", System.currentTimeMillis()); // physical examination time of this report
report.put("respiratory_rate", 18);
report.put("sex", 0); // 0 is male; 1 is female
report.put("sex", "0"); // 0 is male; 1 is female
report.put("stable", "99999");
report.put("weight", 45);
report.put("title", "AMP无创健康评估报告"); // report title
... ...
... ... @@ -36,12 +36,17 @@ public class ReportTest {
@Test
public void testAddReport() {
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
// 程序自动生成json报告。
String report = Data.AMP_REPORT;
// 从本地加载json报告。
// 从本地加载json报告。
// String report = Data.readTxtFile("C:\\Users\\zhaoyue\\Desktop\\report.txt");
System.out.print(report);
JSONObject rpJson = new JSONObject(report.trim());
// System.out.print(report);
String token = loginAndGetToken(Constants.ADMIN_ACCOUNT, Constants.ADMIN_PWD);
Map<String, String> params = new HashMap<String, String>();
params.put("json_report", report);
String response = HttpTools.requestByMapWithToken(URL_REPORT, "POST", params, token);
Assert.assertTrue(RtnCodeTools.verifyCode(response, Constants.CODE_SUCC));
... ...