-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathAbstractClientInternalRequestTest.java
59 lines (50 loc) · 2.04 KB
/
AbstractClientInternalRequestTest.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.tencentcloudapi.unit.common;
import com.tencentcloudapi.common.AbstractClient;
import com.tencentcloudapi.common.AbstractModel;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import org.junit.Before;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.reflect.Whitebox;
import java.util.HashMap;
class Client extends AbstractClient {
public Client(String endpoint, String version, Credential credential, String region) {
super(endpoint, version, credential, region);
}
public Client(String endpoint, String version, Credential credential, String region, ClientProfile profile) {
super(endpoint, version, credential, region, profile);
}
}
public class AbstractClientInternalRequestTest {
private Credential credential;
private ClientProfile clientProfile;
private String endpoint = "example.com";
private String version = "v1";
private String region = "ap-guangzhou";
@Before
public void setUp() {
credential =
new Credential(
System.getenv("TENCENTCLOUD_SECRET_ID"), System.getenv("TENCENTCLOUD_SECRET_KEY"), "123e4567-e89b-12d3-a456-426614174000");
clientProfile = new ClientProfile();
}
@Test
public void testAbstractInternalRequest() throws Exception {
clientProfile.setBackupEndpoint("example.com");
Client client = new Client(endpoint, version, credential, region, clientProfile);
AbstractModel req = new AbstractModel() {
@Override
protected void toMap(HashMap<String, String> map, String prefix) {
}
};
String actionName = "ActionName";
Client client1 = PowerMockito.spy(client);
PowerMockito.doReturn(null).when(client1, "internalRequestRaw", req, actionName);
try {
Whitebox.invokeMethod(client1, "internalRequest", req, actionName);
} catch (Exception e) {
System.out.println(e);
}
}
}