|
@@ -3,6 +3,8 @@ package com.malk.minglei.controller;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.malk.minglei.dto.ApiResponse;
|
|
import com.malk.minglei.dto.ApiResponse;
|
|
|
|
|
+import com.malk.minglei.dto.DepartmentUserIdsResponse;
|
|
|
|
|
+import com.malk.minglei.dto.DepartmentUserQueryRequest;
|
|
|
import com.malk.minglei.dto.YidaProcessStartRequest;
|
|
import com.malk.minglei.dto.YidaProcessStartRequest;
|
|
|
import com.malk.minglei.service.yida.MingleiDocumentService;
|
|
import com.malk.minglei.service.yida.MingleiDocumentService;
|
|
|
import com.malk.minglei.service.yida.YidaProcessService;
|
|
import com.malk.minglei.service.yida.YidaProcessService;
|
|
@@ -10,6 +12,8 @@ import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
@@ -43,4 +47,37 @@ class YidaProcessControllerTest {
|
|
|
assertEquals(true, body.get("isSuccess"));
|
|
assertEquals(true, body.get("isSuccess"));
|
|
|
assertEquals("process-instance-1", ((Map<?, ?>) body.get("result")).get("processInstanceId"));
|
|
assertEquals("process-instance-1", ((Map<?, ?>) body.get("result")).get("processInstanceId"));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void listDepartmentUserIdsLeavesResultUnchangedWhenUserIdsIsEmpty() {
|
|
|
|
|
+ MingleiDocumentService mingleiDocumentService = mock(MingleiDocumentService.class);
|
|
|
|
|
+ given(mingleiDocumentService.listDepartmentUserIds(Arrays.asList(10L), 0))
|
|
|
|
|
+ .willReturn(Arrays.asList("department-user-1", "department-user-2"));
|
|
|
|
|
+ DepartmentUserQueryRequest request = new DepartmentUserQueryRequest();
|
|
|
|
|
+ request.setDepartmentId("10");
|
|
|
|
|
+ request.setType(Integer.valueOf(0));
|
|
|
|
|
+ request.setUserIds(Collections.<String>emptyList());
|
|
|
|
|
+
|
|
|
|
|
+ ResponseEntity<DepartmentUserIdsResponse> response = new YidaProcessController(
|
|
|
|
|
+ mock(YidaProcessService.class), mingleiDocumentService).listDepartmentUserIds(request);
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(Arrays.asList("department-user-1", "department-user-2"), response.getBody().getResult());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void listDepartmentUserIdsAppendsSpecifiedUsersAfterDepartmentUsers() {
|
|
|
|
|
+ MingleiDocumentService mingleiDocumentService = mock(MingleiDocumentService.class);
|
|
|
|
|
+ given(mingleiDocumentService.listDepartmentUserIds(Arrays.asList(10L), 0))
|
|
|
|
|
+ .willReturn(Arrays.asList("department-user-1", "department-user-2"));
|
|
|
|
|
+ DepartmentUserQueryRequest request = new DepartmentUserQueryRequest();
|
|
|
|
|
+ request.setDepartmentId("10");
|
|
|
|
|
+ request.setType(Integer.valueOf(0));
|
|
|
|
|
+ request.setUserIds(Arrays.asList("specified-user-1", "department-user-1"));
|
|
|
|
|
+
|
|
|
|
|
+ ResponseEntity<DepartmentUserIdsResponse> response = new YidaProcessController(
|
|
|
|
|
+ mock(YidaProcessService.class), mingleiDocumentService).listDepartmentUserIds(request);
|
|
|
|
|
+
|
|
|
|
|
+ assertEquals(Arrays.asList("department-user-1", "department-user-2", "specified-user-1", "department-user-1"),
|
|
|
|
|
+ response.getBody().getResult());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|