-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathEventsApiPayloadDumpTest.java
342 lines (314 loc) · 14.4 KB
/
EventsApiPayloadDumpTest.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
package test_locally.sample_json_generation;
import com.slack.api.app_backend.events.payload.*;
import com.slack.api.model.Message;
import com.slack.api.model.event.*;
import lombok.extern.slf4j.Slf4j;
import org.junit.Ignore;
import org.junit.Test;
import util.sample_json_generation.ObjectToJsonDumper;
import util.sample_json_generation.SampleObjects;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import static util.ObjectInitializer.initProperties;
@Slf4j
public class EventsApiPayloadDumpTest {
ObjectToJsonDumper dumper = new ObjectToJsonDumper("../json-logs/samples/events");
@Ignore
@Test
public void dumpAll() throws Exception {
// See also: test_with_remote_apis.EventsApiTest in bolt-servlet
// The disabled ones are generated by the tests.
List<EventsApiPayload<?>> payloads = Arrays.asList(
new AppHomeOpenedPayload(),
buildAppMentionPayload(),
new AppRequestedPayload(),
new AppRateLimitedPayload(),
new AppUninstalledPayload(),
new CallRejectedPayload(),
// new ChannelArchivePayload(),
// new ChannelCreatedPayload(),
new ChannelDeletedPayload(),
new ChannelHistoryChangedPayload(),
new ChannelIdChangedPayload(),
// new ChannelLeftPayload(),
// new ChannelRenamePayload(),
new ChannelSharedPayload(),
// new ChannelUnarchivePayload(),
new ChannelUnsharedPayload(),
// new DndUpdatedPayload(),
// new DndUpdatedUserPayload(),
new EmailDomainChangedPayload(),
//new EmojiChangedPayload(),
new FileChangePayload(),
// new FileCreatedPayload(),
// new FileDeletedPayload(),
// new FilePublicPayload(),
// new FileSharedPayload(),
// new FileUnsharedPayload(),
new GoodbyePayload(),
new GridMigrationFinishedPayload(),
new GridMigrationStartedPayload(),
// new GroupArchivePayload(),
new GroupClosePayload(),
new GroupDeletedPayload(),
new GroupHistoryChangedPayload(),
// new GroupLeftPayload(),
new GroupOpenPayload(),
// new GroupRenamePayload(),
// new GroupUnarchivePayload(),
new ImClosePayload(),
new ImCreatedPayload(),
new ImHistoryChangedPayload(),
new ImOpenPayload(),
buildInviteRequestedPayload(),
buildLinkSharedPayload(),
// new MemberJoinedChannelPayload(),
// new MemberLeftChannelPayload(),
buildMessagePayload(),
buildMessageBotPayload(),
buildMessageChangedPayload(),
buildMessageDeletedPayload(),
buildMessageEkmAccessDeniedPayload(),
buildMessageFileSharePayload(),
buildMessageMePayload(),
buildMessageRepliedPayload(),
buildMessageThreadBroadcastPayload(),
new MessageChannelJoinPayload(),
new MessageChannelArchivePayload(),
new MessageChannelUnarchivePayload(),
new MessageChannelLeavePayload(),
new MessageChannelNamePayload(),
new MessageChannelPurposePayload(),
// buildPinAddedPayload(),
// buildPinRemovedPayload(),
// new ReactionAddedPayload(),
// new ReactionRemovedPayload(),
buildResourcesAddedPayload(),
buildResourcesRemovedPayload(),
buildScopeDeniedPayload(),
buildScopeGrantedPayload(),
// buildStarAddedPayload(),
// buildStarRemovedPayload(),
// buildSubteamCreatedPayload(),
// buildSubteamMembersChangedPayload(),
// new SubteamSelfAddedPayload(),
// new SubteamSelfRemovedPayload(),
// buildSubteamUpdatedPayload(),
new TeamDomainChangePayload(),
new TeamJoinPayload(),
new TeamRenamePayload(),
buildTeamAccessGrantedPayload(),
buildTeamAccessRevokedPayload(),
buildTokensRevokedPayload(),
new UserChangePayload(),
new UserHuddleChangedPayload(),
new UserProfileChangedPayload(),
new UserStatusChangedPayload(),
buildUserResourceDeniedPayload(),
buildUserResourceGrantedPayload(),
new UserResourceRemovedPayload(),
new MessageGroupTopicPayload(),
new MessageChannelTopicPayload(),
new MessageChannelPostingPermissionsPayload(),
new WorkflowStepExecutePayload(),
new WorkflowDeletedPayload(),
new WorkflowPublishedPayload(),
new WorkflowUnpublishedPayload(),
new WorkflowStepDeletedPayload()
);
for (EventsApiPayload<?> payload : payloads) {
try {
Field authedUsers = payload.getClass().getDeclaredField("authedUsers");
if (authedUsers != null) {
authedUsers.setAccessible(true);
authedUsers.set(payload, Arrays.asList(""));
}
} catch (Exception e) {
}
try {
Field authedTeams = payload.getClass().getDeclaredField("authedTeams");
if (authedTeams != null) {
authedTeams.setAccessible(true);
authedTeams.set(payload, Arrays.asList(""));
}
} catch (Exception e) {
}
try {
Field authorizations = payload.getClass().getDeclaredField("authorizations");
if (authorizations != null) {
authorizations.setAccessible(true);
authorizations.set(payload, Arrays.asList(initProperties(new Authorization())));
}
} catch (Exception e) {
}
initProperties(payload);
dumper.dump(payload.getClass().getSimpleName(), payload);
}
}
private AppMentionPayload buildAppMentionPayload() {
AppMentionPayload payload = new AppMentionPayload();
AppMentionEvent event = new AppMentionEvent();
event.setBlocks(SampleObjects.Blocks);
payload.setEvent(event);
return payload;
}
private TeamAccessGrantedPayload buildTeamAccessGrantedPayload() {
TeamAccessGrantedPayload payload = new TeamAccessGrantedPayload();
payload.setEvent(new TeamAccessGrantedEvent());
payload.getEvent().setTeamIds(Arrays.asList(""));
return payload;
}
private TeamAccessRevokedPayload buildTeamAccessRevokedPayload() {
TeamAccessRevokedPayload payload = new TeamAccessRevokedPayload();
payload.setEvent(new TeamAccessRevokedEvent());
payload.getEvent().setTeamIds(Arrays.asList(""));
return payload;
}
private UserResourceGrantedPayload buildUserResourceGrantedPayload() {
UserResourceGrantedPayload payload = new UserResourceGrantedPayload();
payload.setEvent(new UserResourceGrantedEvent());
payload.getEvent().setScopes(Arrays.asList(""));
return payload;
}
private UserResourceDeniedPayload buildUserResourceDeniedPayload() {
UserResourceDeniedPayload payload = new UserResourceDeniedPayload();
payload.setEvent(new UserResourceDeniedEvent());
payload.getEvent().setScopes(Arrays.asList(""));
return payload;
}
private TokensRevokedPayload buildTokensRevokedPayload() {
TokensRevokedPayload payload = new TokensRevokedPayload();
payload.setEvent(new TokensRevokedEvent());
payload.getEvent().setTokens(new TokensRevokedEvent.Tokens());
payload.getEvent().getTokens().setBot(Arrays.asList(""));
payload.getEvent().getTokens().setOauth(Arrays.asList(""));
return payload;
}
private ScopeGrantedPayload buildScopeGrantedPayload() {
ScopeGrantedPayload payload = new ScopeGrantedPayload();
payload.setEvent(new ScopeGrantedEvent());
payload.getEvent().setScopes(Arrays.asList(""));
return payload;
}
private ScopeDeniedPayload buildScopeDeniedPayload() {
ScopeDeniedPayload payload = new ScopeDeniedPayload();
payload.setEvent(new ScopeDeniedEvent());
payload.getEvent().setScopes(Arrays.asList(""));
return payload;
}
private ResourcesRemovedPayload buildResourcesRemovedPayload() {
ResourcesRemovedPayload payload = new ResourcesRemovedPayload();
payload.setEvent(new ResourcesRemovedEvent());
ResourcesRemovedEvent.ResourceItem resource = new ResourcesRemovedEvent.ResourceItem();
resource.setResource(new ResourcesRemovedEvent.Resource());
resource.setScopes(Arrays.asList(""));
payload.getEvent().setResources(Arrays.asList(initProperties(resource)));
return payload;
}
private ResourcesAddedPayload buildResourcesAddedPayload() {
ResourcesAddedPayload payload = new ResourcesAddedPayload();
payload.setEvent(new ResourcesAddedEvent());
ResourcesAddedEvent.ResourceItem resource = new ResourcesAddedEvent.ResourceItem();
resource.setResource(new ResourcesAddedEvent.Resource());
resource.setScopes(Arrays.asList(""));
payload.getEvent().setResources(Arrays.asList(initProperties(resource)));
return payload;
}
private LinkSharedPayload buildLinkSharedPayload() {
LinkSharedPayload payload = new LinkSharedPayload();
payload.setEvent(new LinkSharedEvent());
payload.getEvent().setLinks(Arrays.asList(initProperties(new LinkSharedEvent.Link())));
return payload;
}
private MessagePayload buildMessagePayload() {
MessagePayload payload = new MessagePayload();
payload.setEvent(new MessageEvent());
payload.getEvent().setAttachments(SampleObjects.Attachments);
payload.getEvent().setBlocks(SampleObjects.Blocks);
return payload;
}
private MessageBotPayload buildMessageBotPayload() {
MessageBotPayload payload = new MessageBotPayload();
payload.setEvent(new MessageBotEvent());
payload.getEvent().setAttachments(SampleObjects.Attachments);
payload.getEvent().setBlocks(SampleObjects.Blocks);
return payload;
}
private MessageChangedPayload buildMessageChangedPayload() {
MessageChangedPayload payload = new MessageChangedPayload();
MessageChangedEvent event = new MessageChangedEvent();
MessageChangedEvent.Message message = new MessageChangedEvent.Message();
message.setAttachments(SampleObjects.Attachments);
message.setBlocks(SampleObjects.Blocks);
event.setMessage(message);
event.setPreviousMessage(new MessageChangedEvent.PreviousMessage());
event.getPreviousMessage().setMessage(message);
payload.setEvent(event);
return payload;
}
private MessageFileSharePayload buildMessageFileSharePayload() {
MessageFileSharePayload payload = new MessageFileSharePayload();
MessageFileShareEvent event = new MessageFileShareEvent();
event.setAttachments(SampleObjects.Attachments);
event.setBlocks(SampleObjects.Blocks);
event.setFiles(SampleObjects.Files);
payload.setEvent(event);
return payload;
}
private MessageDeletedPayload buildMessageDeletedPayload() {
MessageDeletedPayload payload = new MessageDeletedPayload();
MessageDeletedEvent event = new MessageDeletedEvent();
MessageDeletedEvent.Message message = new MessageDeletedEvent.Message();
message.setAttachments(SampleObjects.Attachments);
message.setBlocks(SampleObjects.Blocks);
event.setPreviousMessage(message);
payload.setEvent(event);
return payload;
}
private MessageEkmAccessDeniedPayload buildMessageEkmAccessDeniedPayload() {
MessageEkmAccessDeniedPayload payload = new MessageEkmAccessDeniedPayload();
MessageEkmAccessDeniedEvent event = new MessageEkmAccessDeniedEvent();
event.setAttachments(SampleObjects.Attachments);
event.setBlocks(SampleObjects.Blocks);
payload.setEvent(event);
return payload;
}
private MessageMePayload buildMessageMePayload() {
MessageMePayload payload = new MessageMePayload();
MessageMeEvent event = new MessageMeEvent();
payload.setEvent(event);
return payload;
}
private MessageThreadBroadcastPayload buildMessageThreadBroadcastPayload() {
MessageThreadBroadcastPayload payload = new MessageThreadBroadcastPayload();
MessageThreadBroadcastEvent event = new MessageThreadBroadcastEvent();
event.setRoot(new Message.MessageRoot());
event.setAttachments(SampleObjects.Attachments);
event.setBlocks(SampleObjects.Blocks);
payload.setEvent(event);
return payload;
}
private InviteRequestedPayload buildInviteRequestedPayload() {
InviteRequestedPayload payload = new InviteRequestedPayload();
InviteRequestedEvent event = new InviteRequestedEvent();
InviteRequestedEvent.InviteRequest inviteRequest = new InviteRequestedEvent.InviteRequest();
inviteRequest.setChannelIds(Arrays.asList(""));
inviteRequest.setRequesterIds(Arrays.asList(""));
inviteRequest.setTeam(new InviteRequestedEvent.Team());
event.setInviteRequest(inviteRequest);
payload.setEvent(event);
return payload;
}
private MessageRepliedPayload buildMessageRepliedPayload() {
MessageRepliedPayload payload = new MessageRepliedPayload();
MessageRepliedEvent event = new MessageRepliedEvent();
MessageRepliedEvent.Message message = initProperties(new MessageRepliedEvent.Message());
message.setPinnedTo(Arrays.asList(""));
message.setAttachments(SampleObjects.Attachments);
message.setBlocks(SampleObjects.Blocks);
event.setMessage(message);
payload.setEvent(event);
return payload;
}
}