Repository navigation
Expand file tree
/
Copy pathUserTest.java
More file actions
90 lines (75 loc) · 2.3 KB
/
Copy pathUserTest.java
File metadata and controls
90 lines (75 loc) · 2.3 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package io.getstream.client;
import io.getstream.core.models.Data;
import io.getstream.core.models.ProfileData;
import org.junit.Ignore;
import org.junit.Test;
public class UserTest {
private static final String apiKey =
System.getenv("STREAM_KEY") != null
? System.getenv("STREAM_KEY")
: System.getProperty("STREAM_KEY");
private static final String secret =
System.getenv("STREAM_SECRET") != null
? System.getenv("STREAM_SECRET")
: System.getProperty("STREAM_SECRET");
@Test
public void get() throws Exception {
Client client = Client.builder(apiKey, secret).build();
String userID = "get-user";
User user = client.user(userID);
user.getOrCreate().join();
Data result = user.get().join();
}
@Test
public void delete() throws Exception {
Client client = Client.builder(apiKey, secret).build();
String userID = "delete-user";
User user = client.user(userID);
user.getOrCreate().join();
user.delete().join();
}
@Test
public void getOrCreate() throws Exception {
Client client = Client.builder(apiKey, secret).build();
String userID = "get-or-create-user";
User user = client.user(userID);
try {
user.delete().join();
} catch (Exception ignored) {
// XXX: do nothing
System.out.println(ignored);
}
Data result = user.getOrCreate().join();
}
@Test
@Ignore
public void create() throws Exception {
Client client = Client.builder(apiKey, secret).build();
String userID = "create-user";
User user = client.user(userID);
try {
user.delete().join();
} catch (Exception ignored) {
// XXX: do nothing
System.out.println(ignored);
}
Data result = user.create().join();
}
@Test
public void update() throws Exception {
Client client = Client.builder(apiKey, secret).build();
String userID = "update-user";
User user = client.user(userID);
user.getOrCreate().join();
Data result = user.update(new Data().set("key", "value")).join();
}
@Test
@Ignore
public void profile() throws Exception {
Client client = Client.builder(apiKey, secret).build();
String userID = "new-profile-user";
User user = client.user(userID);
user.getOrCreate().join();
ProfileData result = user.profile().join();
}
}