-
-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathSlackSlashCommandTest.java
More file actions
61 lines (54 loc) · 2.26 KB
/
SlackSlashCommandTest.java
File metadata and controls
61 lines (54 loc) · 2.26 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
package example.jbot.slack;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import me.ramswaroop.jbot.core.slack.SlackProperties;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* @author ramswaroop
* @version 05/08/2016
*/
@ActiveProfiles("slack")
@RunWith(SpringRunner.class)
@WebMvcTest(SlackSlashCommand.class)
public class SlackSlashCommandTest {
@Autowired
private MockMvc mvc;
@MockBean
private SlackProperties slackProperties;
@Test
public void onReceiveSlashCommand_When_IncorrectToken_Should_ReturnSorryRichMessage() throws Exception {
mvc.perform(MockMvcRequestBuilders.post("/slash-command?" +
"token={token}&" +
"team_id={team_id}&" +
"team_domain={team_domain}&" +
"channel_id={channel_id}&" +
"channel_name={channel_name}&" +
"user_id={user_id}&" +
"user_name={user_name}&" +
"command={command}&" +
"text={text}&" +
"response_url={response_url}&",
"incorrect_token",
"any_team_id",
"any_domain",
"UHASHB8JB",
"test-channel",
"UNJSD9OKM",
"uname",
"/command",
"help",
"http://example.com")
.contentType(MediaType.APPLICATION_FORM_URLENCODED))
.andExpect(status().isOk())
.andExpect(jsonPath("$.text").value("Sorry! You're not lucky enough to use our slack command."));
}
}