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");
|
}
|
}
|