高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
@isTest
public class NFM501HttpCallMockEx implements HttpCalloutMock {
        // 实现这个接口方法
        public HTTPResponse respond(HTTPRequest request) {
            // 创建一个假的回应
            if (request.getEndpoint().contains('test/v1/token')) {
                System.debug('------------------------------------------------------');
                HttpResponse response = new HttpResponse();
                response.setHeader('Content-Type', 'application/x-www-form-urlencoded');
                response.setBody('12345678');
                response.setStatus('OK');
                response.setStatusCode(0);
                // response.setStatusCode(200);
                return response;
            } else if (request.getEndpoint().contains('test/v1/info/page')) {
                HttpResponse response = new HttpResponse();
                response.setHeader('Content-Type', 'application/x-www-form-urlencoded');
                response.setBody('{"code":"0","data":{"cursorMark":"60d01dde42ec7ed48d3730d6","list1":[{"agentRelationName":[],"agentRelationWay":[],"agentUnit":[],"areaCity":"惠州市","areaCountry":"","areaProvince":"广东省","biddingType":"0","bidingAcquireTime":"","bidingEndTime":"","budget":[{"amount":"250000.00","unit":"元"}],"infoFile":["http://cusdata.qianlima.com/vip/info/download/V2/eyJhbGciOiJIUzI1NiJ9.eyJpbmZvSWQiOiIyMjczMjgxOTAiLCJhcHBLZXkiOiIwNzBmMDBiZi02NGYxLTQ3MjAtYThkOC1iYmUxYWE5NzZkMjIiLCJhcHBTZWNyZXQiOiI2N0JCMkJBRkM4QUEwQkEwQ0FCQjM3Q0JGNTBFQzI5MiIsImZpbGVVcmwiOiI0QjY2Mzg2MzY4MzI0MTQyNzY2MjU5NEI0QTc0NEM1NzcxNkI2RjcyNkI1MTNEM0QifQ.3UTAGOde4plSKFKf_DV1sBWXJbdsz7zN8a1KZZys6bo"],"infoId":"227328190","infoPublishTime":"2021-06-21 09:41:26","infoQianlimaUrl":"http://www.qianlima.com/zb/detail/20210621_227328190.html","infoTitle":"皮肤镜图像处理工作站调研公告","infoType":"0","infoTypeSegment":"3","isElectronic":"0","keywords":"图像处理","openBidingTime":"","projectId":"38_99df2844cf784982acdc61d00d7a7dbb","target":null,"tenderBeginTime":"","tenderEndTime":"","winnerAmount":[],"xmNumber":"CD-1624266167710","zhaoBiaoUnit":["惠州市第一人民医院"],"zhaoRelationName":["范梅红"],"zhaoRelationWay":["0752-2883625"],"zhongBiaoUnit":[],"zhongRelationName":[],"zhongRelationWay":[]}]},"msg":"正确返回数据"}');
                response.setStatus('OK');
                response.setStatusCode(0);
                // response.setStatusCode(200);
                return response;
            } else if (request.getEndpoint().contains('test/v1/info/detailHtml')) {
                HttpResponse NFM502responseBody = new HttpResponse();
                NFM502responseBody.setHeader('Content-Type', 'application/x-www-form-urlencoded');
                NFM502responseBody.setBody('ssss');
                Blob responseBody502 = Blob.valueOf(String.valueOf(NFM502responseBody));
                NFM502responseBody.setStatusCode(0);
                return NFM502responseBody;
            } else {
                HttpResponse NFM503response = new HttpResponse();
                NFM503response.getHeader('Content-Disposition');
                NFM503response.setBody('aaaaa');
                Blob responseBody503 = Blob.valueOf(String.valueOf(NFM503response));
                NFM503response.setStatusCode(0);
                return NFM503response;
            }
        }
    
}