package jnpf.dmsController;
|
|
import jnpf.dmsEntity.wenjianbianhao.DmsFlowEventType;
|
import jnpf.dmsEntity.wenjianbianhao.form.DmsFlowEventForm;
|
import jnpf.dmsEntity.banben.form.DmsWenjianBanbenQueryForm;
|
import jnpf.dmsEntity.banben.vo.DmsWenjianBanbenQueryVO;
|
import jnpf.dmsEntity.banben.vo.DmsWenjianZhongxinBanbenVO;
|
import jnpf.dmsService.DmsWenjianBanbenService;
|
import jnpf.exception.DataException;
|
import jnpf.flowable.WorkFlowApi;
|
import jnpf.flowable.entity.TaskEntity;
|
import jnpf.util.context.SpringContext;
|
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.Test;
|
import org.springframework.context.support.StaticApplicationContext;
|
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.when;
|
|
class DmsWenjianBanbenControllerTest {
|
|
@BeforeAll
|
static void setUpSpringContext() {
|
SpringContext.setApplicationContext(new StaticApplicationContext());
|
}
|
|
private final DmsWenjianBanbenService service = mock(DmsWenjianBanbenService.class);
|
private final jnpf.dmsService.DmsApprovedFlowService approvedFlow = mock(jnpf.dmsService.DmsApprovedFlowService.class);
|
private final DmsWenjianBanbenController controller =
|
new DmsWenjianBanbenController(service, approvedFlow);
|
|
@Test
|
void queryByFileAndVersionDelegatesRequestValues() throws DataException {
|
DmsWenjianBanbenQueryForm form = new DmsWenjianBanbenQueryForm();
|
form.setWenjianId("file-1");
|
form.setBanbenhao("D(01)");
|
when(service.getByWenjianIdAndBanbenhao("file-1", "D(01)"))
|
.thenReturn(new DmsWenjianBanbenQueryVO());
|
|
controller.getByWenjianIdAndBanbenhao(form);
|
|
verify(service).getByWenjianIdAndBanbenhao("file-1", "D(01)");
|
}
|
|
@Test
|
void fileCenterVersionDelegatesBusinessVersionId() throws DataException {
|
DmsWenjianZhongxinBanbenVO result = new DmsWenjianZhongxinBanbenVO();
|
result.setWenjianZhongxinBanbenId("file-center-version-1");
|
when(service.getWenjianZhongxinBanben("version-1")).thenReturn(result);
|
|
controller.getWenjianZhongxinBanben("version-1");
|
|
verify(service).getWenjianZhongxinBanben("version-1");
|
}
|
|
@Test
|
void revisionEventUsesApprovedFlowOrchestrator() throws DataException {
|
DmsFlowEventForm form = form(DmsFlowEventType.END);
|
controller.syncRevisionAuditFlowEvent(form);
|
verify(approvedFlow).sync(form, "xiuding_shenhe");
|
}
|
|
@Test
|
void newEventUsesApprovedFlowOrchestrator() throws DataException {
|
DmsFlowEventForm form = form(DmsFlowEventType.START);
|
controller.syncNewAuditFlowEvent(form);
|
verify(approvedFlow).sync(form, "xinzeng_shenhe");
|
}
|
|
private DmsFlowEventForm form(DmsFlowEventType eventType) {
|
DmsFlowEventForm form = new DmsFlowEventForm();
|
form.setFlowId("flow-1");
|
form.setTaskId("task-1");
|
form.setEventType(eventType);
|
return form;
|
}
|
}
|