22
33import org .testng .annotations .Test ;
44
5+ import static org .assertj .core .api .Assertions .assertThat ;
6+
57/**
68 * @author <a href="https://github.com/binarywang">Binary Wang</a>
79 * created on 2020-07-11
@@ -15,40 +17,29 @@ public void testToJson() {
1517 .serviceId ("345" )
1618 .serviceIntroduction ("租借服务" )
1719 .timeRange (new TimeRange ("20230901011023" , "20230930235959" ,"开始时间" ,"结束时间" ))
20+ .device (new Device ("deviceId" ,"deviceId" ,"212323232" ))
1821 .build ();
19- System .out .println (request .toJson ());
20- /* {
21- "out_order_no":"QLS202005201058000201",
22- "appid":"123",
23- "service_id":"345",
24- "service_introduction":"租借服务",
25- "time_range":{
26- "start_time":"OnAccept",
27- "end_time":"20200520225840"
28- },
29- "location":{
30- "start_location":"山",
31- "end_location":"山"
32- },
33- "risk_fund":{
34- "name":"DEPOSIT",
35- "amount":200,
36- "description":"丢失偿还费用2元/台"
37- },
38- "attach":"",
39- "notify_url":"/pay/notify/payScore",
40- "openid":"",
41- "need_user_confirm":true,
42- "profit_sharing":false,
43- "post_payments":[
44- {
45- "name":"租借服务",
46- "amount":100,
47- "description":"服务费:1元/台",
48- "count":1
49- }
50- ],
51- "total_amount":0
52- }*/
22+ String json = request .toJson ();
23+ System .out .println (json );
24+
25+ String expectedJson = "{\" out_order_no\" :\" QLS202005201058000201\" ,\" appid\" :\" 123\" ,\" service_id\" :\" 345\" ,\" service_introduction\" :\" 租借服务\" ,\" time_range\" :{\" start_time\" :\" 20230901011023\" ,\" end_time\" :\" 20230930235959\" ,\" start_time_remark\" :\" 开始时间\" ,\" end_time_remark\" :\" 结束时间\" },\" device\" :{\" start_device_id\" :\" deviceId\" ,\" end_device_id\" :\" deviceId\" ,\" materiel_no\" :\" 212323232\" }}" ;
26+ assertThat (request .toJson ()).isEqualTo (expectedJson );
27+ // {
28+ // "out_order_no": "QLS202005201058000201",
29+ // "appid": "123",
30+ // "service_id": "345",
31+ // "service_introduction": "租借服务",
32+ // "time_range": {
33+ // "start_time": "20230901011023",
34+ // "end_time": "20230930235959",
35+ // "start_time_remark": "开始时间",
36+ // "end_time_remark": "结束时间"
37+ // },
38+ // "device": {
39+ // "start_device_id": "deviceId",
40+ // "end_device_id": "deviceId",
41+ // "materiel_no": "212323232"
42+ // }
43+ // }
5344 }
5445}
0 commit comments