高章伟
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
@isTest
public class FiledDownloadHttpCallMock implements HttpCalloutMock {
    
    public HTTPResponse respond(HTTPRequest request) {
        // 创建一个假的回应
        System.debug('------------------------------------------------------');
        HttpResponse response = new HttpResponse();
        if(request.getEndpoint().contains('greaterthan12')){
            response.setHeader('Content-Length','18000005');//大于12M
        } else {
            response.setHeader('Content-Length','180522');//小于12M
        }
        response.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        
        response.setBody('{"access_token":"eyJhbGciOiJIUzUxMiJ9.eyJhcHBLZXkiOiIwNzBmMDBiZi02NGYxLTQ3MjAtYThkOC1iYmUxYWE5NzZkMjIiLCJhcHBTZWNyZXQiOiI2N0JCMkJBRkM4QUEwQkEwQ0FCQjM3Q0JGNTBFQzI5MiIsImV4cCI6MTYyNDM1OTkzNH0.IXcAshOMZ08Y_ik7o-Iu4EmUy6o0pI9jz4xcx7orpxn6dTUV7wXVWqmdRl3Ded64Pq7OYKB5Vf_FQFUbgeyYjg","code":"200","msg":"正确返回数据"}');
        response.setStatus('OK');
        response.setStatusCode(200);
        return response;
        // }
    }
}