-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathIndexControllerTest.java
32 lines (27 loc) · 1.19 KB
/
IndexControllerTest.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
package com.cengenes.kotlin.api.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class IndexControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void it_should_redirect_to_swagger_ui() throws Exception {
//when and then
mockMvc.perform(get("/"))
.andDo(print())
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("/swagger-ui.html"));
}
}