Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

import com.slack.api.Slack;
import com.slack.api.SlackConfig;
import com.slack.api.methods.MethodsConfig;
import com.slack.api.methods.MethodsCustomRateLimitResolver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import util.MockSlackApiServer;

import java.util.Optional;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static util.MockSlackApi.ValidToken;
Expand All @@ -21,6 +25,19 @@ public class TeamTest {
public void setup() throws Exception {
server.start();
config.setMethodsEndpointUrlPrefix(server.getMethodsEndpointPrefix());
MethodsConfig methodsConfig = new MethodsConfig();
methodsConfig.setCustomRateLimitResolver(new MethodsCustomRateLimitResolver() {
@Override
public Optional<Integer> getCustomAllowedRequestsPerMinute(String teamId, String methodName) {
return Optional.of(20);
}

@Override
public Optional<Integer> getCustomAllowedRequestsForChatPostMessagePerMinute(String teamId, String channel) {
return Optional.empty();
}
});
config.setMethodsConfig(methodsConfig);
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.slack.api.Slack;
import com.slack.api.SlackConfig;
import com.slack.api.methods.AsyncMethodsClient;
import com.slack.api.methods.MethodsConfig;
import com.slack.api.methods.MethodsCustomRateLimitResolver;
import com.slack.api.model.admin.AppConfig;
import org.junit.After;
import org.junit.Before;
Expand All @@ -11,6 +13,7 @@

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Optional;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -26,6 +29,19 @@ public class AdminApiAsyncTest {
public void setup() throws Exception {
server.start();
config.setMethodsEndpointUrlPrefix(server.getMethodsEndpointPrefix());
MethodsConfig methodsConfig = new MethodsConfig();
methodsConfig.setCustomRateLimitResolver(new MethodsCustomRateLimitResolver() {
@Override
public Optional<Integer> getCustomAllowedRequestsPerMinute(String teamId, String methodName) {
return Optional.of(50);
}

@Override
public Optional<Integer> getCustomAllowedRequestsForChatPostMessagePerMinute(String teamId, String channel) {
return Optional.empty();
}
});
config.setMethodsConfig(methodsConfig);
}

@After
Expand Down