刘光辉
117 分钟以前 06f314545ac3514d7ce28939920866ae8188d31c
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
package jnpf.dmsController;
 
import jnpf.base.UserInfo;
import jnpf.dmsPermission.DmsCurrentIdentity;
import jnpf.dmsService.DmsApprovedDisableFlowService;
import jnpf.dmsService.DmsDisableOccupancyService;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.client.HttpServerErrorException;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
class DmsApprovedDisableControllerTest {
    @Test void unavailableDisableIsHttp502ForBothNativeFlowCallbacks() throws Exception {
        DmsCurrentIdentity identity=mock(DmsCurrentIdentity.class);
        DmsApprovedDisableFlowService service=mock(DmsApprovedDisableFlowService.class);
        DmsDisableOccupancyService occupancy=mock(DmsDisableOccupancyService.class);
        UserInfo user=new UserInfo();when(identity.requireUser()).thenReturn(user);when(identity.tenantId(user)).thenReturn("tenant");
        doThrow(new HttpServerErrorException(HttpStatus.BAD_GATEWAY,"DMS 文件中心 disable 接口尚未实现"))
                .when(service).onEvent(eq("tenant"),eq("flow"),eq("task"),anyString(),eq("end"));
        MockMvc mvc=MockMvcBuilders.standaloneSetup(new DmsApprovedDisableController(identity,service,occupancy)).build();
        for(String operation:new String[]{"chexiao","shixiao"}) {
            mvc.perform(post("/biz/wenjian/disable/"+operation+"/flow-event")
                    .contentType("application/json")
                    .content("{\"flow_id\":\"flow\",\"task_id\":\"task\",\"event_type\":\"end\"}"))
                    .andExpect(status().isBadGateway()).andExpect(jsonPath("$.code").value(502));
        }
        verifyNoInteractions(occupancy);
    }
}