|
|
@@ -9,11 +9,18 @@ import org.junit.jupiter.api.Test;
|
|
|
import org.mockito.ArgumentCaptor;
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
+import static org.mockito.ArgumentMatchers.any;
|
|
|
import static org.mockito.ArgumentMatchers.eq;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
+import static org.mockito.Mockito.when;
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
|
class ReSubmitApprovalServiceTest {
|
|
|
@@ -78,4 +85,41 @@ class ReSubmitApprovalServiceTest {
|
|
|
assertEquals("system-user", captor.getValue().getUserId());
|
|
|
assertEquals("dept-request", captor.getValue().getDeptId());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void shouldPaginateSummaryRecordsWithCurrentPage() {
|
|
|
+ YDClient ydClient = mock(YDClient.class);
|
|
|
+ WHConf whConf = new WHConf();
|
|
|
+ whConf.setYidaAppType("APP");
|
|
|
+ whConf.setYidaSystemToken("TOKEN");
|
|
|
+
|
|
|
+ ReSubmitApprovalService service = new ReSubmitApprovalService();
|
|
|
+ ReflectionTestUtils.setField(service, "ydClient", ydClient);
|
|
|
+ ReflectionTestUtils.setField(service, "whConf", whConf);
|
|
|
+
|
|
|
+ when(ydClient.queryData(any(YDParam.class), eq(YDConf.FORM_QUERY.retrieve_search_form)))
|
|
|
+ .thenAnswer(invocation -> {
|
|
|
+ YDParam param = invocation.getArgument(0);
|
|
|
+ com.malk.server.dingtalk.DDR_New response =
|
|
|
+ new com.malk.server.dingtalk.DDR_New();
|
|
|
+ List<Map> rows = new ArrayList<>();
|
|
|
+ int size = param.getCurrentPage() == 1 ? 100 : 1;
|
|
|
+ for (int index = 0; index < size; index++) {
|
|
|
+ rows.add(Collections.singletonMap(
|
|
|
+ "formInstanceId",
|
|
|
+ param.getCurrentPage() + "-" + index));
|
|
|
+ }
|
|
|
+ response.setData(rows);
|
|
|
+ return response;
|
|
|
+ });
|
|
|
+
|
|
|
+ List<Map> rows = service.queryAll("FORM-SUMMARY", Collections.emptyMap());
|
|
|
+
|
|
|
+ assertEquals(101, rows.size());
|
|
|
+ ArgumentCaptor<YDParam> captor = ArgumentCaptor.forClass(YDParam.class);
|
|
|
+ verify(ydClient, org.mockito.Mockito.times(2))
|
|
|
+ .queryData(captor.capture(), eq(YDConf.FORM_QUERY.retrieve_search_form));
|
|
|
+ assertEquals(1, captor.getAllValues().get(0).getCurrentPage());
|
|
|
+ assertEquals(2, captor.getAllValues().get(1).getCurrentPage());
|
|
|
+ }
|
|
|
}
|