刘光辉
16 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
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
package jnpf.dmsController;
 
import jnpf.dmsService.DmsDanganXiaohuiShenqingTongguoService;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
public class DmsDanganXiaohuiShenqingControllerTest {
 
    private MockMvc mockMvc;
    private DmsDanganXiaohuiShenqingTongguoService tongguoService;
 
    @Before
    public void setUp() {
        tongguoService = mock(DmsDanganXiaohuiShenqingTongguoService.class);
        mockMvc = MockMvcBuilders.standaloneSetup(new DmsDanganXiaohuiShenqingController(tongguoService)).build();
    }
 
    @Test
    public void tongguoPassesSnakeCaseFlowParametersToService() throws Exception {
        mockMvc.perform(post("/biz/dangan/xiaohui/tongguo")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content("{\"flow_id\":\"flow-1\",\"task_id\":\"task-1\"}"))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.code").value(200))
                .andExpect(jsonPath("$.msg").value("档案销毁申请通过处理成功"));
 
        verify(tongguoService).tongguo("flow-1", "task-1");
    }
 
    @Test
    public void tongguoAcceptsCamelCaseFlowParameters() throws Exception {
        mockMvc.perform(post("/biz/dangan/xiaohui/tongguo")
                        .contentType(MediaType.APPLICATION_JSON)
                        .content("{\"flowId\":\"flow-1\",\"taskId\":\"task-1\"}"))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$.code").value(200));
 
        verify(tongguoService).tongguo("flow-1", "task-1");
    }
}