forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpEventTest.java
More file actions
44 lines (34 loc) · 1.36 KB
/
HttpEventTest.java
File metadata and controls
44 lines (34 loc) · 1.36 KB
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
package com.ringcentral;
import com.ringcentral.definitions.CreateInternalTextMessageRequest;
import com.ringcentral.definitions.PagerCallerInfoRequest;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class HttpEventTest {
@Test
public void afterHttpCall() throws IOException, RestException {
RestClient rc = new RestClient(
System.getenv("RINGCENTRAL_CLIENT_ID"),
System.getenv("RINGCENTRAL_CLIENT_SECRET"),
System.getenv("RINGCENTRAL_SERVER_URL")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));
final int[] count = {0};
rc.httpEventListeners.add((response, request) -> {
count[0] += 1;
String httpMessage = Utils.formatHttpMessage(response, request);
assertNotNull(httpMessage);
});
rc.restapi().account().extension().companyPager().post(
new CreateInternalTextMessageRequest()
.text("hello world")
.from(new PagerCallerInfoRequest().extensionId(rc.token.owner_id))
.to(new PagerCallerInfoRequest[]{
new PagerCallerInfoRequest().extensionId(rc.token.owner_id)
})
);
assertEquals(1, count[0]);
rc.revoke();
}
}