Skip to content

Commit b01ebf0

Browse files
committed
chore: revert test changes
1 parent 1dbcba7 commit b01ebf0

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

slack-api-client/src/test/java/test_with_remote_apis/methods/canvases_Test.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import org.junit.BeforeClass;
2222
import org.junit.Test;
2323

24+
import java.util.Arrays;
2425
import java.util.List;
2526

26-
import static java.util.Collections.singletonList;
2727
import static org.hamcrest.CoreMatchers.containsString;
2828
import static org.hamcrest.CoreMatchers.is;
2929
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -52,7 +52,11 @@ public static void tearDown() throws InterruptedException {
5252
public void channel_canvases() throws Exception {
5353
MethodsClient client = slack.methods(botToken);
5454

55-
String channelId = createChannel(client);
55+
ConversationsCreateResponse newChannel = client.conversationsCreate(r -> r.name("test-" + System.currentTimeMillis()));
56+
assertThat(newChannel.getError(), is(nullValue()));
57+
String channelId = newChannel.getChannel().getId();
58+
59+
Thread.sleep(500L); // To avoid occasional 500 errors
5660

5761
ConversationsCanvasesCreateResponse creation = client.conversationsCanvasesCreate(r -> r
5862
.channelId(channelId)
@@ -68,7 +72,9 @@ public void channel_canvases() throws Exception {
6872
);
6973
assertThat(creation.getError(), is(nullValue()));
7074

71-
FilesInfoResponse details = verifyCanvasOps(client, creation.getCanvasId());
75+
String canvasId = creation.getCanvasId();
76+
List<String> userIds = Arrays.asList(client.authTest(r -> r).getUserId());
77+
FilesInfoResponse details = verifyCanvasOps(client, canvasId, channelId, userIds);
7278
ChatPostMessageResponse message = client.chatPostMessage(r -> r
7379
.channel(channelId)
7480
.text("Here you are: " + details.getFile().getPermalink())
@@ -95,8 +101,8 @@ public void standalone_canvases() throws Exception {
95101

96102
String canvasId = creation.getCanvasId();
97103
try {
98-
List<String> userIds = singletonList(client.authTest(r -> r).getUserId());
99-
verifyCanvasOps(client, canvasId);
104+
List<String> userIds = Arrays.asList(client.authTest(r -> r).getUserId());
105+
verifyCanvasOps(client, canvasId, null, userIds);
100106

101107
CanvasesAccessSetResponse set = client.canvasesAccessSet(r -> r
102108
.canvasId(canvasId)
@@ -116,11 +122,11 @@ public void standalone_canvases() throws Exception {
116122
}
117123
}
118124

119-
FilesInfoResponse verifyCanvasOps(MethodsClient client, String canvasId) throws Exception {
125+
FilesInfoResponse verifyCanvasOps(MethodsClient client, String canvasId, String channelId, List<String> userIds) throws Exception {
120126
CanvasesSectionsLookupResponse lookupResult = client.canvasesSectionsLookup(r -> r
121127
.canvasId(canvasId)
122128
.criteria(CanvasesSectionsLookupRequest.Criteria.builder()
123-
.sectionTypes(singletonList(CanvasDocumentSectionType.H2))
129+
.sectionTypes(Arrays.asList(CanvasDocumentSectionType.H2))
124130
.containsText("Before")
125131
.build()
126132
)
@@ -130,7 +136,7 @@ FilesInfoResponse verifyCanvasOps(MethodsClient client, String canvasId) throws
130136
String sectionId = lookupResult.getSections().get(0).getId();
131137
CanvasesEditResponse edit = client.canvasesEdit(r -> r
132138
.canvasId(canvasId)
133-
.changes(singletonList(CanvasDocumentChange.builder()
139+
.changes(Arrays.asList(CanvasDocumentChange.builder()
134140
.sectionId(sectionId)
135141
.operation(CanvasEditOperation.REPLACE)
136142
.documentContent(CanvasDocumentContent.builder().markdown("## After").build())
@@ -161,7 +167,11 @@ public void standalone_canvases_error() throws Exception {
161167
public void error_detail() throws Exception {
162168
MethodsClient client = slack.methods(botToken);
163169

164-
String channelId = createChannel(client);
170+
ConversationsCreateResponse newChannel = client.conversationsCreate(r1 -> r1.name("test-" + System.currentTimeMillis()));
171+
assertThat(newChannel.getError(), is(nullValue()));
172+
String channelId = newChannel.getChannel().getId();
173+
174+
Thread.sleep(500L); // To avoid occasional 500 errors
165175

166176
String invalidCanvasContent = "1. Text\n * Nested"; // mixing of ordered and unordered lists is not supported
167177
ConversationsCanvasesCreateResponse failedCreation = client.conversationsCanvasesCreate(r -> r
@@ -185,7 +195,7 @@ public void error_detail() throws Exception {
185195

186196
CanvasesEditResponse editFailingResponse = client.canvasesEdit(r -> r
187197
.canvasId(successfulCreation.getCanvasId())
188-
.changes(singletonList(CanvasDocumentChange.builder()
198+
.changes(Arrays.asList(CanvasDocumentChange.builder()
189199
.operation(CanvasEditOperation.REPLACE)
190200
.documentContent(CanvasDocumentContent.builder().markdown(invalidCanvasContent).build())
191201
.build()))
@@ -194,13 +204,4 @@ public void error_detail() throws Exception {
194204
assertThat(editFailingResponse.getError(), is("canvas_editing_failed"));
195205
assertThat(editFailingResponse.getDetail(), containsString("Unsupported list type"));
196206
}
197-
198-
private static String createChannel(MethodsClient client) throws Exception {
199-
ConversationsCreateResponse newChannel = client.conversationsCreate(r -> r.name("test-" + System.currentTimeMillis()));
200-
assertThat(newChannel.getError(), is(nullValue()));
201-
String channelId = newChannel.getChannel().getId();
202-
203-
Thread.sleep(500L); // To avoid occasional 500 errors
204-
return channelId;
205-
}
206207
}

0 commit comments

Comments
 (0)