forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryTest.java
More file actions
53 lines (42 loc) · 1.7 KB
/
BinaryTest.java
File metadata and controls
53 lines (42 loc) · 1.7 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
45
46
47
48
49
50
51
52
53
package com.ringcentral;
import com.ringcentral.definitions.Attachment;
import com.ringcentral.definitions.CreateUserProfileImageRequest;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class BinaryTest {
@Test
public void uploadProfileImage() 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"));
rc.restapi().account().extension().profileImage().post(new
CreateUserProfileImageRequest()
.image(new Attachment()
.filename("test.png")
.contentType("image/png")
.content(Files.readAllBytes(Paths.get("./src/test/resources/test.png")))
));
rc.revoke();
}
@Test
public void downloadProfileImage() 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"));
byte[] bytes =
rc.restapi().account().extension().profileImage("90x90").get();
Assert.assertNotNull(bytes);
Assert.assertTrue(bytes.length > 0);
byte[] bytes2 = rc.restapi().account().extension().profileImage().list();
Assert.assertNotNull(bytes2);
Assert.assertTrue(bytes2.length > 0);
rc.revoke();
}
}