Repository navigation
Expand file tree
/
Copy pathUserTest.java
More file actions
105 lines (90 loc) · 2.95 KB
/
Copy pathUserTest.java
File metadata and controls
105 lines (90 loc) · 2.95 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package io.getstream.client;
import io.getstream.core.models.Data;
import io.getstream.core.models.ProfileData;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
class UserTest {
private static final String apiKey = "gp6e8sxxzud6";
private static final String secret = "7j7exnksc4nxy399fdxvjqyqsqdahax3nfgtp27pumpc7sfm9um688pzpxjpjbf2";
@Test
void get() {
Data[] result = new Data[1];
assertDoesNotThrow(() -> {
Client client = Client.builder(apiKey, secret)
.build();
String userID = "get-user";
User user = client.user(userID);
user.getOrCreate().join();
result[0] = user.get().join();
});
}
@Test
void delete() {
assertDoesNotThrow(() -> {
Client client = Client.builder(apiKey, secret)
.build();
String userID = "delete-user";
User user = client.user(userID);
user.getOrCreate().join();
user.delete().join();
});
}
@Test
void getOrCreate() {
Data[] result = new Data[1];
assertDoesNotThrow(() -> {
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);
}
result[0] = user.getOrCreate().join();
});
}
@Test
void create() {
Data[] result = new Data[1];
assertDoesNotThrow(() -> {
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);
}
result[0] = user.create().join();
});
}
@Test
void update() {
Data[] result = new Data[1];
assertDoesNotThrow(() -> {
Client client = Client.builder(apiKey, secret)
.build();
String userID = "update-user";
User user = client.user(userID);
user.getOrCreate().join();
result[0] = user.update(new Data().set("key", "value")).join();
});
}
@Test
void profile() {
ProfileData[] result = new ProfileData[1];
assertDoesNotThrow(() -> {
Client client = Client.builder(apiKey, secret)
.build();
String userID = "new-profile-user";
User user = client.user(userID);
user.getOrCreate().join();
result[0] = user.profile().join();
});
}
}