From c7c3e8c8fde5ebea5f23e48e705c0bc877221249 Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Tue, 30 Sep 2025 17:07:33 +0300 Subject: [PATCH 1/9] wip: Initial support for multi-sort --- .../core/http/impl/util/RequestEncoder.java | 14 +++ .../http/impl/util/SortOrderGenerator.java | 28 +++++ .../crowdin/client/core/model/SortOrder.java | 16 +++ .../com/crowdin/client/tasks/TasksApi.java | 36 +++++-- .../crowdin/client/tasks/TasksApiTest.java | 92 +++++++++++++++- .../api/tasks/listTasksSortByIdAsc.json | 102 ++++++++++++++++++ .../api/tasks/listTasksSortByIdDesc.json | 102 ++++++++++++++++++ .../tasks/listTasksSortByIdDescTitleAsc.json | 102 ++++++++++++++++++ 8 files changed, 479 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/crowdin/client/core/http/impl/util/RequestEncoder.java create mode 100644 src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java create mode 100644 src/main/java/com/crowdin/client/core/model/SortOrder.java create mode 100644 src/test/resources/api/tasks/listTasksSortByIdAsc.json create mode 100644 src/test/resources/api/tasks/listTasksSortByIdDesc.json create mode 100644 src/test/resources/api/tasks/listTasksSortByIdDescTitleAsc.json diff --git a/src/main/java/com/crowdin/client/core/http/impl/util/RequestEncoder.java b/src/main/java/com/crowdin/client/core/http/impl/util/RequestEncoder.java new file mode 100644 index 000000000..d7d41223a --- /dev/null +++ b/src/main/java/com/crowdin/client/core/http/impl/util/RequestEncoder.java @@ -0,0 +1,14 @@ +package com.crowdin.client.core.http.impl.util; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +public class RequestEncoder { + public static String encodeSpaces(String url) { + try { + return URLEncoder.encode(url, "UTF-8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return null; + } + } +} diff --git a/src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java b/src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java new file mode 100644 index 000000000..276c36460 --- /dev/null +++ b/src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java @@ -0,0 +1,28 @@ +package com.crowdin.client.core.http.impl.util; + +import java.util.Map; +import java.util.stream.Collectors; + +import com.crowdin.client.core.model.SortOrder; + +public class SortOrderGenerator { + public static String generateSortParam(Map orderByMap) { + if (orderByMap == null || orderByMap.isEmpty()) { + return null; + } + + String sortParam = orderByMap.entrySet().stream() + .map(entry -> { + if (entry.getValue() == null) { + entry.setValue(SortOrder.ASC); + } + + return entry.getKey() + " " + entry.getValue().to(entry.getValue()); + }) + .collect(Collectors.joining(",")); + + return RequestEncoder.encodeSpaces(sortParam); + + + } +} diff --git a/src/main/java/com/crowdin/client/core/model/SortOrder.java b/src/main/java/com/crowdin/client/core/model/SortOrder.java new file mode 100644 index 000000000..edc73d6a5 --- /dev/null +++ b/src/main/java/com/crowdin/client/core/model/SortOrder.java @@ -0,0 +1,16 @@ +package com.crowdin.client.core.model; + +public enum SortOrder implements EnumConverter { + ASC, DESC; + + public static SortOrder from(String value) { + if (value == null) return ASC; + + return SortOrder.valueOf(value.toUpperCase()); + } + + @Override + public String to(SortOrder v) { + return (v != null ? v : ASC).name().toLowerCase(); + } +} diff --git a/src/main/java/com/crowdin/client/tasks/TasksApi.java b/src/main/java/com/crowdin/client/tasks/TasksApi.java index 65906802b..0a80b4932 100644 --- a/src/main/java/com/crowdin/client/tasks/TasksApi.java +++ b/src/main/java/com/crowdin/client/tasks/TasksApi.java @@ -4,14 +4,8 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.BooleanInt; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.DownloadLinkResponseObject; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.http.impl.util.SortOrderGenerator; +import com.crowdin.client.core.model.*; import com.crowdin.client.tasks.model.*; import java.util.EnumSet; @@ -52,6 +46,32 @@ public ResponseList listTasks(Long projectId, Integer limit, Integer offse return TaskResponseList.to(taskResponseList); } + /** + * @param projectId project identifier + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param status filter by status + * @param assigneeId filter by assignee id + * @param orderBy sort keys and strategy + * @return list of tasks + * @see + */ + public ResponseList listTasks(Long projectId, Integer limit, Integer offset, Status status, Integer assigneeId, Map orderBy) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "status", Optional.ofNullable(status), + "assigneeId", Optional.ofNullable(assigneeId), + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset), + "orderBy", Optional.ofNullable(SortOrderGenerator.generateSortParam(orderBy)) + ); + TaskResponseList taskResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/tasks", new HttpRequestConfig(queryParams), TaskResponseList.class); + return TaskResponseList.to(taskResponseList); + } + + /** * Lists tasks for a given project, filtered by multiple statuses. * diff --git a/src/test/java/com/crowdin/client/tasks/TasksApiTest.java b/src/test/java/com/crowdin/client/tasks/TasksApiTest.java index ff2a85124..44bd04f1a 100644 --- a/src/test/java/com/crowdin/client/tasks/TasksApiTest.java +++ b/src/test/java/com/crowdin/client/tasks/TasksApiTest.java @@ -1,10 +1,6 @@ package com.crowdin.client.tasks; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.PatchOperation; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; import com.crowdin.client.tasks.model.*; @@ -29,6 +25,9 @@ public class TasksApiTest extends TestClient { private final Long enterpriseProjectId = 13L; private final Long multiStatusProjectId = 14L; private final Long singleStatusProjectId = 15L; + private final Long tasksProjectIdSortByIdAsc = 16L; + private final Long tasksProjectIdSortByIdDesc = 17L; + private final Long tasksProjectIdSortByIdDescTitleAsc = 18L; private final Long taskId = 2L; private final Long prevTaskId = 1L; private final Status status = Status.TODO; @@ -55,6 +54,15 @@ public List getMocks() { }}), RequestMock.build(this.url + "/projects/" + singleStatusProjectId + "/tasks", HttpGet.METHOD_NAME, "api/tasks/singleStatusListTasks.json", new HashMap() {{ put("status", "in_progress"); + }}), + RequestMock.build(this.url + "/projects/" + tasksProjectIdSortByIdAsc + "/tasks", HttpGet.METHOD_NAME, "api/tasks/listTasksSortByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + tasksProjectIdSortByIdDesc + "/tasks", HttpGet.METHOD_NAME, "api/tasks/listTasksSortByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), + RequestMock.build(this.url + "/projects/" + tasksProjectIdSortByIdDescTitleAsc + "/tasks", HttpGet.METHOD_NAME, "api/tasks/listTasksSortByIdDescTitleAsc.json", new HashMap() {{ + put("orderBy", "id%20desc%2Ctitle%20asc"); }}) ); } @@ -72,6 +80,80 @@ public void listTasksTest() { assertListTasks(taskResponseList); } + @Test + public void listTasksTest_noSortDefined() { + TimeZone.setDefault(TimeZone.getTimeZone("GMT")); + ResponseList taskResponseList = this.getTasksApi().listTasks(projectId, null, null, null, null, null); + + assertNotNull(taskResponseList.getData().get(0).getData()); + assertEquals(1, taskResponseList.getData().size()); + + assertEquals(projectId, taskResponseList.getData().get(0).getData().getProjectId()); + + assertListTasks(taskResponseList); + } + + @Test + public void listTasksTest_testSortByIdDefault() { + Map orderBy = new LinkedHashMap<>(); + orderBy.put("id", null); + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdAsc, null, null, null, null, orderBy); + + assertNotNull(taskResponseList.getData().get(0).getData()); + assertEquals(2, taskResponseList.getData().size()); + + assertEquals(1, taskResponseList.getData().get(0).getData().getId()); + assertEquals(2, taskResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listTasksTest_testSortByIdAsc() { + Map orderBy = new LinkedHashMap<>(); + orderBy.put("id", SortOrder.ASC); + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdAsc, null, null, null, null, orderBy); + + assertNotNull(taskResponseList.getData().get(0).getData()); + assertEquals(2, taskResponseList.getData().size()); + + assertEquals(1, taskResponseList.getData().get(0).getData().getId()); + assertEquals(2, taskResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listTasksTest_testSortByIdDesc() { + Map orderBy = new LinkedHashMap<>(); + orderBy.put("id", SortOrder.DESC); + + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdDesc, null, null, null, null, orderBy); + + assertNotNull(taskResponseList.getData().get(0).getData()); + assertEquals(2, taskResponseList.getData().size()); + + assertEquals(2, taskResponseList.getData().get(0).getData().getId()); + assertEquals(1, taskResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listTasksTest_testSortByIdDescTitleAsc() { + Map orderBy = new LinkedHashMap<>(); + orderBy.put("id", SortOrder.DESC); + orderBy.put("title", null); + + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdDescTitleAsc, null, null, null, null, orderBy); + + assertNotNull(taskResponseList.getData().get(0).getData()); + assertEquals(2, taskResponseList.getData().size()); + + assertEquals(2, taskResponseList.getData().get(0).getData().getId()); + assertNotNull(taskResponseList.getData().get(0).getData().getTitle()); + assertEquals("French#1", taskResponseList.getData().get(0).getData().getTitle()); + + + assertEquals(1, taskResponseList.getData().get(1).getData().getId()); + assertNotNull(taskResponseList.getData().get(1).getData().getTitle()); + assertEquals("French#2", taskResponseList.getData().get(1).getData().getTitle()); + } + @Test public void listTasksTest_testSingleStatus() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); diff --git a/src/test/resources/api/tasks/listTasksSortByIdAsc.json b/src/test/resources/api/tasks/listTasksSortByIdAsc.json new file mode 100644 index 000000000..37c5b3da5 --- /dev/null +++ b/src/test/resources/api/tasks/listTasksSortByIdAsc.json @@ -0,0 +1,102 @@ +{ + "data": [ + { + "data": { + "id": 1, + "projectId": 12, + "creatorId": 6, + "type": 1, + "status": "todo", + "title": "French#1", + "assignees": [ + { + "id": 1, + "username": "john_smith", + "fullName": "john_smith", + "avatarUrl": "", + "wordsCount": 5, + "wordsLeft": 3 + } + ], + "assignedTeams": [ + { + "id": 1, + "wordsCount": 5 + } + ], + "fileIds": [ + 1 + ], + "progress": { + "total": 24, + "done": 15, + "percent": 62 + }, + "sourceLanguageId": "en", + "targetLanguageId": "fr", + "description": "Proofread all French strings", + "hash": "dac37aff364d83899128e68afe0de4994", + "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", + "wordsCount": 24, + "filesCount": 2, + "commentsCount": 0, + "deadline": "2019-09-27T07:00:14+00:00", + "timeRange": "string", + "workflowStepId": 10, + "createdAt": "2019-09-23T09:04:29+00:00", + "updatedAt": "2019-09-23T09:04:29+00:00" + } + }, + { + "data": { + "id": 2, + "projectId": 12, + "creatorId": 6, + "type": 1, + "status": "todo", + "title": "French#2", + "assignees": [ + { + "id": 1, + "username": "john_smith", + "fullName": "john_smith", + "avatarUrl": "", + "wordsCount": 5, + "wordsLeft": 3 + } + ], + "assignedTeams": [ + { + "id": 1, + "wordsCount": 5 + } + ], + "fileIds": [ + 1 + ], + "progress": { + "total": 24, + "done": 15, + "percent": 62 + }, + "sourceLanguageId": "en", + "targetLanguageId": "fr", + "description": "Proofread all French strings", + "hash": "dac37aff364d83899128e68afe0de4994", + "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", + "wordsCount": 24, + "filesCount": 2, + "commentsCount": 0, + "deadline": "2019-09-27T07:00:14+00:00", + "timeRange": "string", + "workflowStepId": 10, + "createdAt": "2019-09-23T09:04:29+00:00", + "updatedAt": "2019-09-23T09:04:29+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/tasks/listTasksSortByIdDesc.json b/src/test/resources/api/tasks/listTasksSortByIdDesc.json new file mode 100644 index 000000000..34bb24d74 --- /dev/null +++ b/src/test/resources/api/tasks/listTasksSortByIdDesc.json @@ -0,0 +1,102 @@ +{ + "data": [ + { + "data": { + "id": 2, + "projectId": 12, + "creatorId": 6, + "type": 1, + "status": "todo", + "title": "French#2", + "assignees": [ + { + "id": 1, + "username": "john_smith", + "fullName": "john_smith", + "avatarUrl": "", + "wordsCount": 5, + "wordsLeft": 3 + } + ], + "assignedTeams": [ + { + "id": 1, + "wordsCount": 5 + } + ], + "fileIds": [ + 1 + ], + "progress": { + "total": 24, + "done": 15, + "percent": 62 + }, + "sourceLanguageId": "en", + "targetLanguageId": "fr", + "description": "Proofread all French strings", + "hash": "dac37aff364d83899128e68afe0de4994", + "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", + "wordsCount": 24, + "filesCount": 2, + "commentsCount": 0, + "deadline": "2019-09-27T07:00:14+00:00", + "timeRange": "string", + "workflowStepId": 10, + "createdAt": "2019-09-23T09:04:29+00:00", + "updatedAt": "2019-09-23T09:04:29+00:00" + } + }, + { + "data": { + "id": 1, + "projectId": 12, + "creatorId": 6, + "type": 1, + "status": "todo", + "title": "French#1", + "assignees": [ + { + "id": 1, + "username": "john_smith", + "fullName": "john_smith", + "avatarUrl": "", + "wordsCount": 5, + "wordsLeft": 3 + } + ], + "assignedTeams": [ + { + "id": 1, + "wordsCount": 5 + } + ], + "fileIds": [ + 1 + ], + "progress": { + "total": 24, + "done": 15, + "percent": 62 + }, + "sourceLanguageId": "en", + "targetLanguageId": "fr", + "description": "Proofread all French strings", + "hash": "dac37aff364d83899128e68afe0de4994", + "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", + "wordsCount": 24, + "filesCount": 2, + "commentsCount": 0, + "deadline": "2019-09-27T07:00:14+00:00", + "timeRange": "string", + "workflowStepId": 10, + "createdAt": "2019-09-23T09:04:29+00:00", + "updatedAt": "2019-09-23T09:04:29+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/tasks/listTasksSortByIdDescTitleAsc.json b/src/test/resources/api/tasks/listTasksSortByIdDescTitleAsc.json new file mode 100644 index 000000000..8b1685ab0 --- /dev/null +++ b/src/test/resources/api/tasks/listTasksSortByIdDescTitleAsc.json @@ -0,0 +1,102 @@ +{ + "data": [ + { + "data": { + "id": 2, + "projectId": 12, + "creatorId": 6, + "type": 1, + "status": "todo", + "title": "French#1", + "assignees": [ + { + "id": 1, + "username": "john_smith", + "fullName": "john_smith", + "avatarUrl": "", + "wordsCount": 5, + "wordsLeft": 3 + } + ], + "assignedTeams": [ + { + "id": 1, + "wordsCount": 5 + } + ], + "fileIds": [ + 1 + ], + "progress": { + "total": 24, + "done": 15, + "percent": 62 + }, + "sourceLanguageId": "en", + "targetLanguageId": "fr", + "description": "Proofread all French strings", + "hash": "dac37aff364d83899128e68afe0de4994", + "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", + "wordsCount": 24, + "filesCount": 2, + "commentsCount": 0, + "deadline": "2019-09-27T07:00:14+00:00", + "timeRange": "string", + "workflowStepId": 10, + "createdAt": "2019-09-23T09:04:29+00:00", + "updatedAt": "2019-09-23T09:04:29+00:00" + } + }, + { + "data": { + "id": 1, + "projectId": 12, + "creatorId": 6, + "type": 1, + "status": "todo", + "title": "French#2", + "assignees": [ + { + "id": 1, + "username": "john_smith", + "fullName": "john_smith", + "avatarUrl": "", + "wordsCount": 5, + "wordsLeft": 3 + } + ], + "assignedTeams": [ + { + "id": 1, + "wordsCount": 5 + } + ], + "fileIds": [ + 1 + ], + "progress": { + "total": 24, + "done": 15, + "percent": 62 + }, + "sourceLanguageId": "en", + "targetLanguageId": "fr", + "description": "Proofread all French strings", + "hash": "dac37aff364d83899128e68afe0de4994", + "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", + "wordsCount": 24, + "filesCount": 2, + "commentsCount": 0, + "deadline": "2019-09-27T07:00:14+00:00", + "timeRange": "string", + "workflowStepId": 10, + "createdAt": "2019-09-23T09:04:29+00:00", + "updatedAt": "2019-09-23T09:04:29+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} From c8cb503df59e4603ee9e39d5fcf861a1df7b5fb9 Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Wed, 1 Oct 2025 23:45:01 +0300 Subject: [PATCH 2/9] wip: Keep field and sort direction in pojo class. Use List instead of Map --- .../http/impl/util/SortOrderGenerator.java | 28 ----------- .../client/core/model/OrderByField.java | 31 +++++++++++++ .../com/crowdin/client/tasks/TasksApi.java | 7 ++- .../crowdin/client/tasks/TasksApiTest.java | 46 +++++++++++++------ 4 files changed, 67 insertions(+), 45 deletions(-) delete mode 100644 src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java create mode 100644 src/main/java/com/crowdin/client/core/model/OrderByField.java diff --git a/src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java b/src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java deleted file mode 100644 index 276c36460..000000000 --- a/src/main/java/com/crowdin/client/core/http/impl/util/SortOrderGenerator.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.crowdin.client.core.http.impl.util; - -import java.util.Map; -import java.util.stream.Collectors; - -import com.crowdin.client.core.model.SortOrder; - -public class SortOrderGenerator { - public static String generateSortParam(Map orderByMap) { - if (orderByMap == null || orderByMap.isEmpty()) { - return null; - } - - String sortParam = orderByMap.entrySet().stream() - .map(entry -> { - if (entry.getValue() == null) { - entry.setValue(SortOrder.ASC); - } - - return entry.getKey() + " " + entry.getValue().to(entry.getValue()); - }) - .collect(Collectors.joining(",")); - - return RequestEncoder.encodeSpaces(sortParam); - - - } -} diff --git a/src/main/java/com/crowdin/client/core/model/OrderByField.java b/src/main/java/com/crowdin/client/core/model/OrderByField.java new file mode 100644 index 000000000..f3a56cbb2 --- /dev/null +++ b/src/main/java/com/crowdin/client/core/model/OrderByField.java @@ -0,0 +1,31 @@ +package com.crowdin.client.core.model; + +import com.crowdin.client.core.http.impl.util.RequestEncoder; +import lombok.Data; + +import java.util.List; +import java.util.stream.Collectors; + +@Data +public class OrderByField { + private String fieldName; + private SortOrder orderBy; + + public static String generateSortParam(List fields) { + if (fields == null || fields.isEmpty()) { + return null; + } + + String sortParam = fields.stream() + .map(field -> { + if (field.getOrderBy() == null) { + field.setOrderBy(SortOrder.ASC); + } + + return field.getFieldName() + " " + field.getOrderBy().to(field.getOrderBy()); + }) + .collect(Collectors.joining(",")); + + return RequestEncoder.encodeSpaces(sortParam); + } +} diff --git a/src/main/java/com/crowdin/client/tasks/TasksApi.java b/src/main/java/com/crowdin/client/tasks/TasksApi.java index 0a80b4932..599bffb0a 100644 --- a/src/main/java/com/crowdin/client/tasks/TasksApi.java +++ b/src/main/java/com/crowdin/client/tasks/TasksApi.java @@ -4,7 +4,6 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.http.impl.util.SortOrderGenerator; import com.crowdin.client.core.model.*; import com.crowdin.client.tasks.model.*; @@ -52,20 +51,20 @@ public ResponseList listTasks(Long projectId, Integer limit, Integer offse * @param offset starting offset in the collection (default 0) * @param status filter by status * @param assigneeId filter by assignee id - * @param orderBy sort keys and strategy + * @param orderBy list of OrderByField * @return list of tasks * @see */ - public ResponseList listTasks(Long projectId, Integer limit, Integer offset, Status status, Integer assigneeId, Map orderBy) throws HttpException, HttpBadRequestException { + public ResponseList listTasks(Long projectId, Integer limit, Integer offset, Status status, Integer assigneeId, List orderBy) throws HttpException, HttpBadRequestException { Map> queryParams = HttpRequestConfig.buildUrlParams( "status", Optional.ofNullable(status), "assigneeId", Optional.ofNullable(assigneeId), "limit", Optional.ofNullable(limit), "offset", Optional.ofNullable(offset), - "orderBy", Optional.ofNullable(SortOrderGenerator.generateSortParam(orderBy)) + "orderBy", Optional.ofNullable(OrderByField.generateSortParam(orderBy)) ); TaskResponseList taskResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/tasks", new HttpRequestConfig(queryParams), TaskResponseList.class); return TaskResponseList.to(taskResponseList); diff --git a/src/test/java/com/crowdin/client/tasks/TasksApiTest.java b/src/test/java/com/crowdin/client/tasks/TasksApiTest.java index 44bd04f1a..8c7fabb44 100644 --- a/src/test/java/com/crowdin/client/tasks/TasksApiTest.java +++ b/src/test/java/com/crowdin/client/tasks/TasksApiTest.java @@ -95,9 +95,13 @@ public void listTasksTest_noSortDefined() { @Test public void listTasksTest_testSortByIdDefault() { - Map orderBy = new LinkedHashMap<>(); - orderBy.put("id", null); - ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdAsc, null, null, null, null, orderBy); + OrderByField orderBy = new OrderByField(); + orderBy.setFieldName("id"); + + List orderByFields = new ArrayList<>(); + orderByFields.add(orderBy); + + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdAsc, null, null, null, null, orderByFields); assertNotNull(taskResponseList.getData().get(0).getData()); assertEquals(2, taskResponseList.getData().size()); @@ -108,9 +112,14 @@ public void listTasksTest_testSortByIdDefault() { @Test public void listTasksTest_testSortByIdAsc() { - Map orderBy = new LinkedHashMap<>(); - orderBy.put("id", SortOrder.ASC); - ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdAsc, null, null, null, null, orderBy); + OrderByField orderBy = new OrderByField(); + orderBy.setFieldName("id"); + orderBy.setOrderBy(SortOrder.ASC); + + List orderByFields = new ArrayList<>(); + orderByFields.add(orderBy); + + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdAsc, null, null, null, null, orderByFields); assertNotNull(taskResponseList.getData().get(0).getData()); assertEquals(2, taskResponseList.getData().size()); @@ -121,10 +130,14 @@ public void listTasksTest_testSortByIdAsc() { @Test public void listTasksTest_testSortByIdDesc() { - Map orderBy = new LinkedHashMap<>(); - orderBy.put("id", SortOrder.DESC); + OrderByField orderBy = new OrderByField(); + orderBy.setFieldName("id"); + orderBy.setOrderBy(SortOrder.DESC); - ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdDesc, null, null, null, null, orderBy); + List orderByFields = new ArrayList<>(); + orderByFields.add(orderBy); + + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdDesc, null, null, null, null, orderByFields); assertNotNull(taskResponseList.getData().get(0).getData()); assertEquals(2, taskResponseList.getData().size()); @@ -135,11 +148,18 @@ public void listTasksTest_testSortByIdDesc() { @Test public void listTasksTest_testSortByIdDescTitleAsc() { - Map orderBy = new LinkedHashMap<>(); - orderBy.put("id", SortOrder.DESC); - orderBy.put("title", null); + OrderByField orderByIdDesc = new OrderByField(); + orderByIdDesc.setFieldName("id"); + orderByIdDesc.setOrderBy(SortOrder.DESC); + + OrderByField orderByTitleNull = new OrderByField(); + orderByTitleNull.setFieldName("title"); + + List orderByFields = new ArrayList<>(); + orderByFields.add(orderByIdDesc); + orderByFields.add(orderByTitleNull); - ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdDescTitleAsc, null, null, null, null, orderBy); + ResponseList taskResponseList = this.getTasksApi().listTasks(tasksProjectIdSortByIdDescTitleAsc, null, null, null, null, orderByFields); assertNotNull(taskResponseList.getData().get(0).getData()); assertEquals(2, taskResponseList.getData().size()); From 07017425e411e3999ccd464910442de824b7c11a Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Sun, 5 Oct 2025 14:04:48 +0300 Subject: [PATCH 3/9] wip: add orderBy support to list user tasks and projects --- .../projectsgroups/ProjectsGroupsApi.java | 36 ++++++++++--- .../model/ListProjectOptions.java | 4 ++ .../com/crowdin/client/tasks/TasksApi.java | 24 +++++++++ .../ListProjectsOrderByIdTest.java | 43 +++++++++++++++ .../crowdin/client/tasks/TasksApiTest.java | 11 ++++ .../client/tasks/UserTasksOrderByIdTest.java | 38 ++++++++++++++ .../listProjectsOrderByIdAsc.json | 52 +++++++++++++++++++ 7 files changed, 200 insertions(+), 8 deletions(-) create mode 100644 src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java create mode 100644 src/test/java/com/crowdin/client/tasks/UserTasksOrderByIdTest.java create mode 100644 src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json diff --git a/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java b/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java index 28d9fbdd0..38ef56d00 100644 --- a/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java +++ b/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java @@ -4,13 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.DownloadLinkResponseObject; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.projectsgroups.model.*; import java.util.List; @@ -123,11 +117,37 @@ public ResponseList listProjects(Long groupId, Integer hasMan return listProjects(options); } + /** + * @param groupId group identifier (optional) + * @param hasManagerAccess projects with manager access (default 0) + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of projects + * @see + */ + public ResponseList listProjects(Long groupId, Integer hasManagerAccess, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListProjectOptions options = new ListProjectOptions(); + options.setGroupId(groupId); + options.setHasManagerAccess(hasManagerAccess); + options.setLimit(limit); + options.setOffset(offset); + options.setOrderByFields(orderBy); + return listProjects(options); + } + public ResponseList listProjects(ListProjectOptions options) throws HttpException, HttpBadRequestException { + String orderBy = options.getOrderByFields() != null + ? OrderByField.generateSortParam(options.getOrderByFields()) + : options.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( "groupId", Optional.ofNullable(options.getGroupId()), "hasManagerAccess", Optional.ofNullable(options.getHasManagerAccess()), - "orderBy", Optional.ofNullable(options.getOrderBy()), + "orderBy", Optional.ofNullable(orderBy), "type", Optional.ofNullable(options.getType()), "limit", Optional.ofNullable(options.getLimit()), "offset", Optional.ofNullable(options.getOffset()) diff --git a/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java b/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java index 296ee3ba4..5e23a3bbc 100644 --- a/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java +++ b/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java @@ -1,9 +1,12 @@ package com.crowdin.client.projectsgroups.model; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @EqualsAndHashCode(callSuper = true) @Data public class ListProjectOptions extends Pagination { @@ -12,4 +15,5 @@ public class ListProjectOptions extends Pagination { private Integer hasManagerAccess; private String orderBy; private Integer type; + private List orderByFields; } diff --git a/src/main/java/com/crowdin/client/tasks/TasksApi.java b/src/main/java/com/crowdin/client/tasks/TasksApi.java index 599bffb0a..702dac52b 100644 --- a/src/main/java/com/crowdin/client/tasks/TasksApi.java +++ b/src/main/java/com/crowdin/client/tasks/TasksApi.java @@ -198,6 +198,30 @@ public ResponseList listUserTasks(Integer limit, Integer offset, Status st return TaskResponseList.to(taskResponseList); } + /** + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param status filter by status + * @param isArchived filter by archived status + * @return list of user tasks + * @param orderBy list of OrderByField + * @see + */ + public ResponseList listUserTasks(Integer limit, Integer offset, Status status, BooleanInt isArchived, List orderBy) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "status", Optional.ofNullable(status), + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset), + "isArchived", Optional.ofNullable(isArchived), + "orderBy", Optional.ofNullable(OrderByField.generateSortParam(orderBy)) + ); + TaskResponseList taskResponseList = this.httpClient.get(this.url + "/user/tasks", new HttpRequestConfig(queryParams), TaskResponseList.class); + return TaskResponseList.to(taskResponseList); + } + /** * @param taskId task identifier * @param projectId project identifier (filter) diff --git a/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java b/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java new file mode 100644 index 000000000..c54fba7c4 --- /dev/null +++ b/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java @@ -0,0 +1,43 @@ +package com.crowdin.client.projectsgroups; + +import com.crowdin.client.core.model.*; +import com.crowdin.client.framework.RequestMock; +import com.crowdin.client.framework.TestClient; +import com.crowdin.client.projectsgroups.model.*; +import org.apache.http.client.methods.HttpGet; +import org.junit.jupiter.api.Test; + +import java.util.*; + +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.*; + +public class ListProjectsOrderByIdTest extends TestClient { + private final Long projectId = 8L; + private final String projectName = "Knowledge Base#1"; + + @Override + public List getMocks() { + return Arrays.asList( + RequestMock.build(this.url + "/projects", HttpGet.METHOD_NAME, "api/projectsgroups/listProjectsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}) + ); + } + + @Test + public void listProjectsTest() { + OrderByField orderByField = new OrderByField(); + orderByField.setFieldName("id"); + orderByField.setOrderBy(SortOrder.DESC); + + List orderByFields = singletonList(orderByField); + + ResponseList projectResponseList = this.getProjectsGroupsApi().listProjects(null, null, null, null, orderByFields); + assertEquals(2, projectResponseList.getData().size()); + assertEquals(8, projectResponseList.getData().get(0).getData().getId()); + assertEquals(9, projectResponseList.getData().get(1).getData().getId()); + assertEquals(projectResponseList.getData().get(0).getData().getId(), projectId); + assertEquals(projectResponseList.getData().get(0).getData().getName(), projectName); + } +} diff --git a/src/test/java/com/crowdin/client/tasks/TasksApiTest.java b/src/test/java/com/crowdin/client/tasks/TasksApiTest.java index 8c7fabb44..500908ac1 100644 --- a/src/test/java/com/crowdin/client/tasks/TasksApiTest.java +++ b/src/test/java/com/crowdin/client/tasks/TasksApiTest.java @@ -48,6 +48,9 @@ public List getMocks() { RequestMock.build(this.url + "/projects/" + projectId + "/tasks/" + taskId, HttpDelete.METHOD_NAME), RequestMock.build(this.url + "/projects/" + projectId + "/tasks/" + taskId, HttpPatch.METHOD_NAME, "api/tasks/editTask.json", "api/tasks/task.json"), RequestMock.build(this.url + "/user/tasks", HttpGet.METHOD_NAME, "api/tasks/listTasks.json"), + RequestMock.build(this.url + "/user/tasks", HttpGet.METHOD_NAME, "api/tasks/listTasks.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/user/tasks/" + taskId, HttpPatch.METHOD_NAME, "api/tasks/editTask.json", "api/tasks/task.json"), RequestMock.build(this.url + "/projects/" + multiStatusProjectId + "/tasks", HttpGet.METHOD_NAME, "api/tasks/multiStatusListTasks.json", new HashMap() {{ put("status", "todo,done"); @@ -411,6 +414,14 @@ public void listUserTasksTest() { assertEquals(taskResponseList.getData().get(0).getData().getStatus(), status); } + @Test + public void listUserTasksTest_orderByNull() { + ResponseList taskResponseList = this.getTasksApi().listUserTasks(null, null, null, null, null); + assertEquals(1, taskResponseList.getData().size()); + assertEquals(taskId, taskResponseList.getData().get(0).getData().getId()); + assertEquals(status, taskResponseList.getData().get(0).getData().getStatus()); + } + @Test public void editUserTaskTest() { PatchRequest request = new PatchRequest(); diff --git a/src/test/java/com/crowdin/client/tasks/UserTasksOrderByIdTest.java b/src/test/java/com/crowdin/client/tasks/UserTasksOrderByIdTest.java new file mode 100644 index 000000000..ab63e8e4c --- /dev/null +++ b/src/test/java/com/crowdin/client/tasks/UserTasksOrderByIdTest.java @@ -0,0 +1,38 @@ +package com.crowdin.client.tasks; + +import com.crowdin.client.core.model.OrderByField; +import com.crowdin.client.core.model.ResponseList; +import com.crowdin.client.framework.RequestMock; +import com.crowdin.client.framework.TestClient; +import com.crowdin.client.tasks.model.Task; +import org.apache.http.client.methods.HttpGet; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.List; + +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class UserTasksOrderByIdTest extends TestClient { + + @Override + public List getMocks() { + return singletonList( + RequestMock.build(this.url + "/user/tasks", HttpGet.METHOD_NAME, "api/tasks/listTasksSortByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}) + ); + } + + @Test + public void listUserTasksTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList taskResponseList = this.getTasksApi().listUserTasks(null, null, null, null, singletonList(orderById)); + assertEquals(2, taskResponseList.getData().size()); + assertEquals(1, taskResponseList.getData().get(0).getData().getId()); + assertEquals(2, taskResponseList.getData().get(1).getData().getId()); + } +} diff --git a/src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json b/src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json new file mode 100644 index 000000000..0b45790e9 --- /dev/null +++ b/src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json @@ -0,0 +1,52 @@ +{ + "data": [ + { + "data": { + "id": 8, + "groupId": 4, + "userId": 6, + "sourceLanguageId": "es", + "targetLanguageIds": [ + "uk" + ], + "name": "Knowledge Base#1", + "identifier": "1f198a4e907688bc65834a6d5a6000c3", + "description": "Vault of all terms and their explanation", + "logo": "data:image/png;base64,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", + "background": "data:image/png;base64,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", + "isExternal": false, + "externalType": "proofread", + "workflowId": 3, + "hasCrowdsourcing": false, + "createdAt": "2019-09-20T11:34:40+00:00", + "updatedAt": "2019-09-20T11:34:40+00:00" + } + }, + { + "data": { + "id": 9, + "groupId": 4, + "userId": 6, + "sourceLanguageId": "es", + "targetLanguageIds": [ + "uk" + ], + "name": "Knowledge Base#2", + "identifier": "1f198a4e907688bc65834a6d5a6000c3", + "description": "Vault of all terms and their explanation", + "logo": "data:image/png;base64,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", + "background": "data:image/png;base64,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", + "isExternal": false, + "externalType": "proofread", + "workflowId": 3, + "hasCrowdsourcing": false, + "createdAt": "2019-09-20T11:34:40+00:00", + "updatedAt": "2019-09-20T11:34:40+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} From 02dd81cc849a8cab3f89f2ea74367de8e3385260 Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Sun, 5 Oct 2025 14:31:10 +0300 Subject: [PATCH 4/9] wip: Slight improvements in listProjects test --- .../projectsgroups/ListProjectsOrderByIdTest.java | 12 ++++++------ ...erByIdAsc.json => listProjectsOrderByIdDesc.json} | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) rename src/test/resources/api/projectsgroups/{listProjectsOrderByIdAsc.json => listProjectsOrderByIdDesc.json} (100%) diff --git a/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java b/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java index c54fba7c4..58ee508e0 100644 --- a/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java +++ b/src/test/java/com/crowdin/client/projectsgroups/ListProjectsOrderByIdTest.java @@ -13,20 +13,20 @@ import static org.junit.jupiter.api.Assertions.*; public class ListProjectsOrderByIdTest extends TestClient { - private final Long projectId = 8L; - private final String projectName = "Knowledge Base#1"; + private final Long projectId = 9L; + private final String projectName = "Knowledge Base#2"; @Override public List getMocks() { return Arrays.asList( - RequestMock.build(this.url + "/projects", HttpGet.METHOD_NAME, "api/projectsgroups/listProjectsOrderByIdAsc.json", new HashMap() {{ + RequestMock.build(this.url + "/projects", HttpGet.METHOD_NAME, "api/projectsgroups/listProjectsOrderByIdDesc.json", new HashMap() {{ put("orderBy", "id%20desc"); }}) ); } @Test - public void listProjectsTest() { + public void listProjectsTest_orderByIdDesc() { OrderByField orderByField = new OrderByField(); orderByField.setFieldName("id"); orderByField.setOrderBy(SortOrder.DESC); @@ -35,8 +35,8 @@ public void listProjectsTest() { ResponseList projectResponseList = this.getProjectsGroupsApi().listProjects(null, null, null, null, orderByFields); assertEquals(2, projectResponseList.getData().size()); - assertEquals(8, projectResponseList.getData().get(0).getData().getId()); - assertEquals(9, projectResponseList.getData().get(1).getData().getId()); + assertEquals(9, projectResponseList.getData().get(0).getData().getId()); + assertEquals(8, projectResponseList.getData().get(1).getData().getId()); assertEquals(projectResponseList.getData().get(0).getData().getId(), projectId); assertEquals(projectResponseList.getData().get(0).getData().getName(), projectName); } diff --git a/src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json b/src/test/resources/api/projectsgroups/listProjectsOrderByIdDesc.json similarity index 100% rename from src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json rename to src/test/resources/api/projectsgroups/listProjectsOrderByIdDesc.json index 0b45790e9..a40dae04c 100644 --- a/src/test/resources/api/projectsgroups/listProjectsOrderByIdAsc.json +++ b/src/test/resources/api/projectsgroups/listProjectsOrderByIdDesc.json @@ -2,14 +2,14 @@ "data": [ { "data": { - "id": 8, + "id": 9, "groupId": 4, "userId": 6, "sourceLanguageId": "es", "targetLanguageIds": [ "uk" ], - "name": "Knowledge Base#1", + "name": "Knowledge Base#2", "identifier": "1f198a4e907688bc65834a6d5a6000c3", "description": "Vault of all terms and their explanation", "logo": "data:image/png;base64,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", @@ -24,14 +24,14 @@ }, { "data": { - "id": 9, + "id": 8, "groupId": 4, "userId": 6, "sourceLanguageId": "es", "targetLanguageIds": [ "uk" ], - "name": "Knowledge Base#2", + "name": "Knowledge Base#1", "identifier": "1f198a4e907688bc65834a6d5a6000c3", "description": "Vault of all terms and their explanation", "logo": "data:image/png;base64,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", From d00ce51056da7f5507d133d7c18ddeb86fb9c9d9 Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:44:18 +0300 Subject: [PATCH 5/9] wip: second part of orderBy implementation in list methods. List projects, directories, files, branches and source strings --- .../projectsgroups/ProjectsGroupsApi.java | 6 +- .../model/ListProjectOptions.java | 2 +- .../client/sourcefiles/SourceFilesApi.java | 89 +++- .../sourcestrings/SourceStringsApi.java | 21 +- .../model/ListSourceStringsParams.java | 4 + .../sourcefiles/SourceFilesApiTest.java | 408 +++++++++++++++--- .../sourcestrings/SourceStringsApiTest.java | 106 ++++- .../listBranchesOrderedByIdAsc.json | 32 ++ .../listBranchesOrderedByIdDesc.json | 32 ++ .../listDirectoriesOrderByIdAsc.json | 36 ++ .../listDirectoriesOrderByIdDesc.json | 36 ++ .../sourcefiles/listFilesOrderByIdDesc.json | 138 ++++++ .../api/strings/listStringsOrderByIdAsc.json | 52 +++ .../api/strings/listStringsOrderByIdDesc.json | 52 +++ 14 files changed, 941 insertions(+), 73 deletions(-) create mode 100644 src/test/resources/api/sourcefiles/listBranchesOrderedByIdAsc.json create mode 100644 src/test/resources/api/sourcefiles/listBranchesOrderedByIdDesc.json create mode 100644 src/test/resources/api/sourcefiles/listDirectoriesOrderByIdAsc.json create mode 100644 src/test/resources/api/sourcefiles/listDirectoriesOrderByIdDesc.json create mode 100644 src/test/resources/api/sourcefiles/listFilesOrderByIdDesc.json create mode 100644 src/test/resources/api/strings/listStringsOrderByIdAsc.json create mode 100644 src/test/resources/api/strings/listStringsOrderByIdDesc.json diff --git a/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java b/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java index 38ef56d00..13ddda9e6 100644 --- a/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java +++ b/src/main/java/com/crowdin/client/projectsgroups/ProjectsGroupsApi.java @@ -135,13 +135,13 @@ public ResponseList listProjects(Long groupId, Integer hasMan options.setHasManagerAccess(hasManagerAccess); options.setLimit(limit); options.setOffset(offset); - options.setOrderByFields(orderBy); + options.setOrderByList(orderBy); return listProjects(options); } public ResponseList listProjects(ListProjectOptions options) throws HttpException, HttpBadRequestException { - String orderBy = options.getOrderByFields() != null - ? OrderByField.generateSortParam(options.getOrderByFields()) + String orderBy = options.getOrderByList() != null + ? OrderByField.generateSortParam(options.getOrderByList()) : options.getOrderBy(); Map> queryParams = HttpRequestConfig.buildUrlParams( diff --git a/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java b/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java index 5e23a3bbc..31cba7eb5 100644 --- a/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java +++ b/src/main/java/com/crowdin/client/projectsgroups/model/ListProjectOptions.java @@ -15,5 +15,5 @@ public class ListProjectOptions extends Pagination { private Integer hasManagerAccess; private String orderBy; private Integer type; - private List orderByFields; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/sourcefiles/SourceFilesApi.java b/src/main/java/com/crowdin/client/sourcefiles/SourceFilesApi.java index b5d2bc27b..908570a0c 100644 --- a/src/main/java/com/crowdin/client/sourcefiles/SourceFilesApi.java +++ b/src/main/java/com/crowdin/client/sourcefiles/SourceFilesApi.java @@ -4,13 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.DownloadLinkResponseObject; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.sourcefiles.model.*; import java.util.List; @@ -47,6 +41,29 @@ public ResponseList listBranches(Long projectId, String name, Integer li return BranchResponseList.to(branchResponseList); } + /** + * @param projectId project identifier + * @param name filter by branch name + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of branches + * @see + */ + public ResponseList listBranches(Long projectId, String name, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "name", Optional.ofNullable(name), + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset), + "orderBy", Optional.ofNullable(OrderByField.generateSortParam(orderBy)) + ); + BranchResponseList branchResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/branches", new HttpRequestConfig(queryParams), BranchResponseList.class); + return BranchResponseList.to(branchResponseList); + } + /** * @param projectId project identifier * @param request request object @@ -129,6 +146,35 @@ public ResponseList listDirectories(Long projectId, Long branchId, Lo return DirectoryResponseList.to(directoryResponseList); } + /** + * @param projectId project identifier + * @param branchId filter by branch id + * @param directoryId filter by directory id + * @param filter filter directories by name + * @param recursion use to list directories recursively + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of directories + * @see + */ + public ResponseList listDirectories(Long projectId, Long branchId, Long directoryId, String filter, Object recursion, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "branchId", Optional.ofNullable(branchId), + "directoryId", Optional.ofNullable(directoryId), + "filter", Optional.ofNullable(filter), + "recursion", Optional.ofNullable(recursion), + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset), + "orderBy", Optional.ofNullable(OrderByField.generateSortParam(orderBy)) + ); + DirectoryResponseList directoryResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/directories", new HttpRequestConfig(queryParams), DirectoryResponseList.class); + return DirectoryResponseList.to(directoryResponseList); + } + /** * @param projectId project identifier * @param request request object @@ -211,6 +257,35 @@ public ResponseList listFiles(Long projectId, Long branchId, return FileInfoResponseList.to(fileInfoResponseList); } + /** + * @param projectId project identifier + * @param branchId filter by branch id + * @param directoryId filter by directory id + * @param filter filter files by name + * @param recursion use to list directories recursively + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of files + * @see + */ + public ResponseList listFiles(Long projectId, Long branchId, Long directoryId, String filter, Object recursion, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + Map> queryParams = HttpRequestConfig.buildUrlParams( + "branchId", Optional.ofNullable(branchId), + "directoryId", Optional.ofNullable(directoryId), + "filter", Optional.ofNullable(filter), + "recursion", Optional.ofNullable(recursion), + "limit", Optional.ofNullable(limit), + "offset", Optional.ofNullable(offset), + "orderBy", Optional.ofNullable(OrderByField.generateSortParam(orderBy)) + ); + FileInfoResponseList fileInfoResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/files", new HttpRequestConfig(queryParams), FileInfoResponseList.class); + return FileInfoResponseList.to(fileInfoResponseList); + } + /** * @param projectId project identifier * @param request request object diff --git a/src/main/java/com/crowdin/client/sourcestrings/SourceStringsApi.java b/src/main/java/com/crowdin/client/sourcestrings/SourceStringsApi.java index 49a9f7bd6..e21857566 100644 --- a/src/main/java/com/crowdin/client/sourcestrings/SourceStringsApi.java +++ b/src/main/java/com/crowdin/client/sourcestrings/SourceStringsApi.java @@ -4,11 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.sourcestrings.model.*; import java.util.List; @@ -71,9 +67,22 @@ public ResponseList listSourceStrings(Long projectId, Long fileId, return listSourceStrings(projectId, params); } + /** + * @param projectId project identifier + * @param params Query params + * @return list of source strings + * @see + */ public ResponseList listSourceStrings(Long projectId, ListSourceStringsParams params) throws HttpException, HttpBadRequestException { + String orderBy = params.getOrderByList() != null + ? OrderByField.generateSortParam(params.getOrderByList()) + : params.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( - "orderBy", Optional.ofNullable(params.getOrderBy()), + "orderBy", Optional.ofNullable(orderBy), "denormalizePlaceholders", Optional.ofNullable(params.getDenormalizePlaceholders()), "labelIds", Optional.ofNullable(params.getLabelIds()), "fileId", Optional.ofNullable(params.getFileId()), diff --git a/src/main/java/com/crowdin/client/sourcestrings/model/ListSourceStringsParams.java b/src/main/java/com/crowdin/client/sourcestrings/model/ListSourceStringsParams.java index 53c34ef0d..daa5acc74 100644 --- a/src/main/java/com/crowdin/client/sourcestrings/model/ListSourceStringsParams.java +++ b/src/main/java/com/crowdin/client/sourcestrings/model/ListSourceStringsParams.java @@ -1,8 +1,11 @@ package com.crowdin.client.sourcestrings.model; +import com.crowdin.client.core.model.OrderByField; import lombok.Builder; import lombok.Data; +import java.util.List; + @Data @Builder public class ListSourceStringsParams { @@ -19,4 +22,5 @@ public class ListSourceStringsParams { private String scope; private Integer limit; private Integer offset; + private List orderByList; } diff --git a/src/test/java/com/crowdin/client/sourcefiles/SourceFilesApiTest.java b/src/test/java/com/crowdin/client/sourcefiles/SourceFilesApiTest.java index e8d23f460..b732f394a 100644 --- a/src/test/java/com/crowdin/client/sourcefiles/SourceFilesApiTest.java +++ b/src/test/java/com/crowdin/client/sourcefiles/SourceFilesApiTest.java @@ -1,13 +1,10 @@ package com.crowdin.client.sourcefiles; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.PatchOperation; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; import com.crowdin.client.sourcefiles.model.*; +import lombok.SneakyThrows; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPatch; @@ -23,21 +20,28 @@ import java.util.Date; import java.util.Calendar; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.*; public class SourceFilesApiTest extends TestClient { private final Long branchId = 34L; + private final Long branch2Id = 35L; private final Long directoryId = 4L; + private final Long directory2Id = 5L; private final Long projectId = 3L; private final Long project2Id = 4L; + private final Long project3Id = 5L; + private final Long project4Id = 6L; private final Long fileId = 44L; private final Long storageId = 61L; private final Long fileRevisionId = 2L; private final Long buildId = 42L; private final String branchName = "develop-master"; + private final String sequentBranchName1 = "develop-master-#1"; + private final String sequentBranchName2 = "develop-master-#2"; private final String directoryName = "main"; + private final String directory2Name = "main-#2"; private final String fileName = "umbrella_app.xliff"; private final String context = "Context for translators"; private final String downloadLink = "test.com"; @@ -50,16 +54,34 @@ public class SourceFilesApiTest extends TestClient { public List getMocks() { return Arrays.asList( RequestMock.build(this.url + "/projects/" + projectId + "/branches", HttpGet.METHOD_NAME, "api/sourcefiles/listBranches.json"), + RequestMock.build(this.url + "/projects/" + project3Id + "/branches", HttpGet.METHOD_NAME, "api/sourcefiles/listBranchesOrderedByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project4Id + "/branches", HttpGet.METHOD_NAME, "api/sourcefiles/listBranchesOrderedByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/projects/" + projectId + "/branches", HttpPost.METHOD_NAME, "api/sourcefiles/addBranchRequest.json", "api/sourcefiles/branch.json"), RequestMock.build(this.url + "/projects/" + projectId + "/branches/" + branchId, HttpGet.METHOD_NAME, "api/sourcefiles/branch.json"), RequestMock.build(this.url + "/projects/" + projectId + "/branches/" + branchId, HttpDelete.METHOD_NAME), RequestMock.build(this.url + "/projects/" + projectId + "/branches/" + branchId, HttpPatch.METHOD_NAME, "api/sourcefiles/editBranch.json", "api/sourcefiles/branch.json"), RequestMock.build(this.url + "/projects/" + projectId + "/directories", HttpGet.METHOD_NAME, "api/sourcefiles/listDirectories.json"), + RequestMock.build(this.url + "/projects/" + project3Id + "/directories", HttpGet.METHOD_NAME, "api/sourcefiles/listDirectoriesOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project4Id + "/directories", HttpGet.METHOD_NAME, "api/sourcefiles/listDirectoriesOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/projects/" + projectId + "/directories", HttpPost.METHOD_NAME, "api/sourcefiles/addDirectoryRequest.json", "api/sourcefiles/directory.json"), RequestMock.build(this.url + "/projects/" + projectId + "/directories/" + directoryId, HttpGet.METHOD_NAME, "api/sourcefiles/directory.json"), RequestMock.build(this.url + "/projects/" + projectId + "/directories/" + directoryId, HttpDelete.METHOD_NAME), RequestMock.build(this.url + "/projects/" + projectId + "/directories/" + directoryId, HttpPatch.METHOD_NAME, "api/sourcefiles/editDirectory.json", "api/sourcefiles/directory.json"), RequestMock.build(this.url + "/projects/" + projectId + "/files", HttpGet.METHOD_NAME, "api/sourcefiles/listFiles.json"), + RequestMock.build(this.url + "/projects/" + project3Id + "/files", HttpGet.METHOD_NAME, "api/sourcefiles/listFiles.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project4Id + "/files", HttpGet.METHOD_NAME, "api/sourcefiles/listFilesOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(String.format("%s/projects/%s/files", this.url, project2Id), HttpGet.METHOD_NAME, "api/sourcefiles/listFileInfos.json"), RequestMock.build(this.url + "/projects/" + projectId + "/files", HttpPost.METHOD_NAME, "api/sourcefiles/addFileRequest.json", "api/sourcefiles/file.json"), RequestMock.build(this.url + "/projects/" + projectId + "/files/" + fileId, HttpGet.METHOD_NAME, "api/sourcefiles/file.json"), @@ -85,6 +107,64 @@ public void listBranchesTest() { assertEquals(branchResponseList.getData().get(0).getData().getName(), branchName); } + @Test + public void listBranchesTest_orderByNull() { + ResponseList branchResponseList = this.getSourceFilesApi().listBranches(projectId, null, null, null, null); + assertEquals(branchResponseList.getData().size(), 1); + assertEquals(branchResponseList.getData().get(0).getData().getId(), branchId); + assertEquals(branchResponseList.getData().get(0).getData().getName(), branchName); + } + + @Test + public void listBranchesTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList branchResponseList = this.getSourceFilesApi().listBranches(project3Id, null, null, null, singletonList(orderById)); + assertEquals(2, branchResponseList.getData().size()); + assertEquals(project2Id, branchResponseList.getData().get(0).getData().getProjectId()); + assertEquals(branchId, branchResponseList.getData().get(0).getData().getId()); + assertEquals(sequentBranchName1, branchResponseList.getData().get(0).getData().getName()); + + assertEquals(project2Id, branchResponseList.getData().get(1).getData().getProjectId()); + assertEquals(branch2Id, branchResponseList.getData().get(1).getData().getId()); + assertEquals(sequentBranchName2, branchResponseList.getData().get(1).getData().getName()); + } + + @Test + public void listBranchesTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList branchResponseList = this.getSourceFilesApi().listBranches(project3Id, null, null, null, singletonList(orderById)); + assertEquals(2, branchResponseList.getData().size()); + assertEquals(project2Id, branchResponseList.getData().get(0).getData().getProjectId()); + assertEquals(branchId, branchResponseList.getData().get(0).getData().getId()); + assertEquals(sequentBranchName1, branchResponseList.getData().get(0).getData().getName()); + + assertEquals(project2Id, branchResponseList.getData().get(1).getData().getProjectId()); + assertEquals(branch2Id, branchResponseList.getData().get(1).getData().getId()); + assertEquals(sequentBranchName2, branchResponseList.getData().get(1).getData().getName()); + } + + @Test + public void listBranchesTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList branchResponseList = this.getSourceFilesApi().listBranches(project4Id, null, null, null, singletonList(orderById)); + assertEquals(2, branchResponseList.getData().size()); + assertEquals(project2Id, branchResponseList.getData().get(1).getData().getProjectId()); + assertEquals(branchId, branchResponseList.getData().get(1).getData().getId()); + assertEquals(sequentBranchName1, branchResponseList.getData().get(1).getData().getName()); + + assertEquals(project2Id, branchResponseList.getData().get(0).getData().getProjectId()); + assertEquals(branch2Id, branchResponseList.getData().get(0).getData().getId()); + assertEquals(sequentBranchName2, branchResponseList.getData().get(0).getData().getName()); + } + @Test public void addBranchTest() { AddBranchRequest request = new AddBranchRequest(); @@ -125,6 +205,98 @@ public void listDirectoriesTest() { assertEquals(directoryResponseList.getData().get(0).getData().getName(), directoryName); } + @Test + public void listDirectoriesTest_orderByNull() { + ResponseList directoryResponseList = this.getSourceFilesApi().listDirectories( + projectId, + null, + null, + null, + null, + null, + null, + null + ); + + assertEquals(1, directoryResponseList.getData().size()); + assertEquals(directoryId, directoryResponseList.getData().get(0).getData().getId()); + assertEquals(directoryName, directoryResponseList.getData().get(0).getData().getName()); + } + + @Test + public void listDirectoriesTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList directoryResponseList = this.getSourceFilesApi().listDirectories( + project3Id, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, directoryResponseList.getData().size()); + assertEquals(directoryId, directoryResponseList.getData().get(0).getData().getId()); + assertEquals(directoryName, directoryResponseList.getData().get(0).getData().getName()); + + assertEquals(directory2Id, directoryResponseList.getData().get(1).getData().getId()); + assertEquals(directory2Name, directoryResponseList.getData().get(1).getData().getName()); + } + + @Test + public void listDirectoriesTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList directoryResponseList = this.getSourceFilesApi().listDirectories( + project3Id, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, directoryResponseList.getData().size()); + assertEquals(directoryId, directoryResponseList.getData().get(0).getData().getId()); + assertEquals(directoryName, directoryResponseList.getData().get(0).getData().getName()); + + assertEquals(directory2Id, directoryResponseList.getData().get(1).getData().getId()); + assertEquals(directory2Name, directoryResponseList.getData().get(1).getData().getName()); + } + + @Test + public void listDirectoriesTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList directoryResponseList = this.getSourceFilesApi().listDirectories( + project4Id, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, directoryResponseList.getData().size()); + assertEquals(directory2Id, directoryResponseList.getData().get(0).getData().getId()); + assertEquals(directory2Name, directoryResponseList.getData().get(0).getData().getName()); + + assertEquals(directoryId, directoryResponseList.getData().get(1).getData().getId()); + assertEquals(directoryName, directoryResponseList.getData().get(1).getData().getName()); + } + @Test public void addDirectoryTest() { AddDirectoryRequest request = new AddDirectoryRequest(); @@ -162,54 +334,78 @@ public void editDirectoryTest() { @Test public void listFilesTest() { ResponseList fileResponseList = (ResponseList) this.getSourceFilesApi().listFiles(projectId, null, null, null, null, null, null); - assertEquals(fileResponseList.getData().size(), 5); - assertEquals(fileResponseList.getData().get(0).getData().getId(), fileId); - assertEquals(fileResponseList.getData().get(0).getData().getName(), fileName); - assertEquals(fileResponseList.getData().get(0).getData().getContext(), context); - ExportOptions exportOptions = fileResponseList.getData().get(0).getData().getExportOptions(); - assertTrue(exportOptions instanceof GeneralFileExportOptions); - assertEquals(((GeneralFileExportOptions) exportOptions).getExportPattern(), "/localization/%locale%/%file_name%.%file_extension%"); + assertListFilesOrderByIdAsc(fileResponseList); + } - assertEquals(fileResponseList.getData().get(1).getData().getId(), Long.valueOf(45L)); - assertEquals(fileResponseList.getData().get(1).getData().getName(), "fileA.properties"); - assertEquals(fileResponseList.getData().get(1).getData().getContext(), "Context for fileA.properties"); - exportOptions = fileResponseList.getData().get(1).getData().getExportOptions(); - assertTrue(exportOptions instanceof PropertyFileExportOptions); - assertEquals(((PropertyFileExportOptions) exportOptions).getExportPattern(), "/files/fileA.properties"); - assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeQuotes(), Integer.valueOf(3)); - assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeSpecialCharacters(), null); + @Test + public void listFilesTest_orderByNull() { + ResponseList fileResponseList = (ResponseList) this.getSourceFilesApi().listFiles( + projectId, + null, + null, + null, + null, + null, + null, + null + ); + assertListFilesOrderByIdAsc(fileResponseList); + } - assertEquals(fileResponseList.getData().get(2).getData().getId(), Long.valueOf(46L)); - assertEquals(fileResponseList.getData().get(2).getData().getName(), "fileB.properties"); - assertEquals(fileResponseList.getData().get(2).getData().getContext(), "Context for fileB.properties"); - exportOptions = fileResponseList.getData().get(2).getData().getExportOptions(); - assertTrue(exportOptions instanceof PropertyFileExportOptions); - assertEquals(((PropertyFileExportOptions) exportOptions).getExportPattern(), "/files/fileB.properties"); - assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeQuotes(), null); - assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeSpecialCharacters(), Integer.valueOf(1)); + @Test + public void listFilesTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList fileResponseList = (ResponseList) this.getSourceFilesApi().listFiles( + project3Id, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + assertListFilesOrderByIdAsc(fileResponseList); + } - assertEquals(fileResponseList.getData().get(3).getData().getId(), Long.valueOf(47L)); - assertEquals(fileResponseList.getData().get(3).getData().getName(), "guide.odt"); - assertEquals(fileResponseList.getData().get(3).getData().getContext(), "Context for guide.odt"); - assertEquals(fileResponseList.getData().get(3).getData().getType(), "docx"); - ImportOptions importOptions = fileResponseList.getData().get(3).getData().getImportOptions(); - assertTrue(importOptions instanceof DocxFileImportOptions); - assertEquals(((DocxFileImportOptions) importOptions).getCleanTagsAggressively(), false); - assertEquals(((DocxFileImportOptions) importOptions).getTranslateHiddenText(), true); - assertEquals(((DocxFileImportOptions) importOptions).getTranslateHyperlinkUrls(), false); - assertEquals(((DocxFileImportOptions) importOptions).getTranslateHiddenRowsAndColumns(), false); - assertEquals(((DocxFileImportOptions) importOptions).getImportNotes(), true); - assertEquals(((DocxFileImportOptions) importOptions).getImportHiddenSlides(), false); - assertEquals(((DocxFileImportOptions) importOptions).getContentSegmentation(), true); - assertEquals(((DocxFileImportOptions) importOptions).getSrxStorageId(), null); + @Test + public void listFilesTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList fileResponseList = (ResponseList) this.getSourceFilesApi().listFiles( + project3Id, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + assertListFilesOrderByIdAsc(fileResponseList); + } - assertEquals(fileResponseList.getData().get(4).getData().getId(), Long.valueOf(48L)); - assertEquals(fileResponseList.getData().get(4).getData().getName(), "fileB.js"); - assertEquals(fileResponseList.getData().get(4).getData().getContext(), "Context for fileB.js"); - exportOptions = fileResponseList.getData().get(4).getData().getExportOptions(); - assertTrue(exportOptions instanceof JavaScriptFileExportOptions); - assertEquals(((JavaScriptFileExportOptions) exportOptions).getExportPattern(), "/files/fileB.js"); - assertEquals(((JavaScriptFileExportOptions) exportOptions).getExportQuotes().name().toLowerCase(), "single"); + @Test + public void listFilesTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList fileResponseList = (ResponseList) this.getSourceFilesApi().listFiles( + project4Id, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + assertListFilesOrderByIdDesc(fileResponseList); } @Test @@ -334,4 +530,114 @@ public void downloadFilePreview() { ResponseObject response = this.getSourceFilesApi().downloadFilePreview(projectId, fileId); assertEquals(downloadLink, response.getData().getUrl()); } + + // + @SneakyThrows + private void assertListFilesOrderByIdAsc(ResponseList fileResponseList) { + assertEquals(fileResponseList.getData().size(), 5); + assertEquals(fileResponseList.getData().get(0).getData().getId(), fileId); + assertEquals(fileResponseList.getData().get(0).getData().getName(), fileName); + assertEquals(fileResponseList.getData().get(0).getData().getContext(), context); + ExportOptions exportOptions = fileResponseList.getData().get(0).getData().getExportOptions(); + assertTrue(exportOptions instanceof GeneralFileExportOptions); + assertEquals(((GeneralFileExportOptions) exportOptions).getExportPattern(), "/localization/%locale%/%file_name%.%file_extension%"); + + assertEquals(fileResponseList.getData().get(1).getData().getId(), Long.valueOf(45L)); + assertEquals(fileResponseList.getData().get(1).getData().getName(), "fileA.properties"); + assertEquals(fileResponseList.getData().get(1).getData().getContext(), "Context for fileA.properties"); + exportOptions = fileResponseList.getData().get(1).getData().getExportOptions(); + assertTrue(exportOptions instanceof PropertyFileExportOptions); + assertEquals(((PropertyFileExportOptions) exportOptions).getExportPattern(), "/files/fileA.properties"); + assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeQuotes(), Integer.valueOf(3)); + assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeSpecialCharacters(), null); + + assertEquals(fileResponseList.getData().get(2).getData().getId(), Long.valueOf(46L)); + assertEquals(fileResponseList.getData().get(2).getData().getName(), "fileB.properties"); + assertEquals(fileResponseList.getData().get(2).getData().getContext(), "Context for fileB.properties"); + exportOptions = fileResponseList.getData().get(2).getData().getExportOptions(); + assertTrue(exportOptions instanceof PropertyFileExportOptions); + assertEquals(((PropertyFileExportOptions) exportOptions).getExportPattern(), "/files/fileB.properties"); + assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeQuotes(), null); + assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeSpecialCharacters(), Integer.valueOf(1)); + + assertEquals(fileResponseList.getData().get(3).getData().getId(), Long.valueOf(47L)); + assertEquals(fileResponseList.getData().get(3).getData().getName(), "guide.odt"); + assertEquals(fileResponseList.getData().get(3).getData().getContext(), "Context for guide.odt"); + assertEquals(fileResponseList.getData().get(3).getData().getType(), "docx"); + ImportOptions importOptions = fileResponseList.getData().get(3).getData().getImportOptions(); + assertTrue(importOptions instanceof DocxFileImportOptions); + assertEquals(((DocxFileImportOptions) importOptions).getCleanTagsAggressively(), false); + assertEquals(((DocxFileImportOptions) importOptions).getTranslateHiddenText(), true); + assertEquals(((DocxFileImportOptions) importOptions).getTranslateHyperlinkUrls(), false); + assertEquals(((DocxFileImportOptions) importOptions).getTranslateHiddenRowsAndColumns(), false); + assertEquals(((DocxFileImportOptions) importOptions).getImportNotes(), true); + assertEquals(((DocxFileImportOptions) importOptions).getImportHiddenSlides(), false); + assertEquals(((DocxFileImportOptions) importOptions).getContentSegmentation(), true); + assertEquals(((DocxFileImportOptions) importOptions).getSrxStorageId(), null); + + assertEquals(fileResponseList.getData().get(4).getData().getId(), Long.valueOf(48L)); + assertEquals(fileResponseList.getData().get(4).getData().getName(), "fileB.js"); + assertEquals(fileResponseList.getData().get(4).getData().getContext(), "Context for fileB.js"); + exportOptions = fileResponseList.getData().get(4).getData().getExportOptions(); + assertTrue(exportOptions instanceof JavaScriptFileExportOptions); + assertEquals(((JavaScriptFileExportOptions) exportOptions).getExportPattern(), "/files/fileB.js"); + assertEquals(((JavaScriptFileExportOptions) exportOptions).getExportQuotes().name().toLowerCase(), "single"); + } + + @SneakyThrows + private void assertListFilesOrderByIdDesc(ResponseList fileResponseList) { + assertEquals(5, fileResponseList.getData().size()); + + ExportOptions exportOptions = fileResponseList.getData().get(0).getData().getExportOptions(); + + assertEquals(Long.valueOf(48L), fileResponseList.getData().get(0).getData().getId()); + assertEquals("fileB.js", fileResponseList.getData().get(0).getData().getName()); + assertEquals("Context for fileB.js", fileResponseList.getData().get(0).getData().getContext()); + exportOptions = fileResponseList.getData().get(0).getData().getExportOptions(); + assertInstanceOf(JavaScriptFileExportOptions.class, exportOptions); + assertEquals("/files/fileB.js", ((JavaScriptFileExportOptions) exportOptions).getExportPattern()); + assertEquals("single", ((JavaScriptFileExportOptions) exportOptions).getExportQuotes().name().toLowerCase()); + + assertEquals(fileResponseList.getData().get(3).getData().getId(), Long.valueOf(45L)); + assertEquals("fileA.properties", fileResponseList.getData().get(3).getData().getName()); + assertEquals("Context for fileA.properties", fileResponseList.getData().get(3).getData().getContext()); + exportOptions = fileResponseList.getData().get(3).getData().getExportOptions(); + assertInstanceOf(PropertyFileExportOptions.class, exportOptions); + assertEquals("/files/fileA.properties", ((PropertyFileExportOptions) exportOptions).getExportPattern()); + assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeQuotes(), Integer.valueOf(3)); + assertNull(((PropertyFileExportOptions) exportOptions).getEscapeSpecialCharacters()); + + assertEquals(fileResponseList.getData().get(2).getData().getId(), Long.valueOf(46L)); + assertEquals("fileB.properties", fileResponseList.getData().get(2).getData().getName()); + assertEquals("Context for fileB.properties", fileResponseList.getData().get(2).getData().getContext()); + exportOptions = fileResponseList.getData().get(2).getData().getExportOptions(); + assertInstanceOf(PropertyFileExportOptions.class, exportOptions); + assertEquals("/files/fileB.properties", ((PropertyFileExportOptions) exportOptions).getExportPattern()); + assertNull(((PropertyFileExportOptions) exportOptions).getEscapeQuotes()); + assertEquals(((PropertyFileExportOptions) exportOptions).getEscapeSpecialCharacters(), Integer.valueOf(1)); + + assertEquals(fileResponseList.getData().get(1).getData().getId(), Long.valueOf(47L)); + assertEquals("guide.odt", fileResponseList.getData().get(1).getData().getName()); + assertEquals("Context for guide.odt", fileResponseList.getData().get(1).getData().getContext()); + assertEquals("docx", fileResponseList.getData().get(1).getData().getType()); + ImportOptions importOptions = fileResponseList.getData().get(1).getData().getImportOptions(); + assertInstanceOf(DocxFileImportOptions.class, importOptions); + + assertEquals(fileResponseList.getData().get(4).getData().getId(), fileId); + assertEquals(fileResponseList.getData().get(4).getData().getName(), fileName); + assertEquals(fileResponseList.getData().get(4).getData().getContext(), context); + exportOptions = fileResponseList.getData().get(4).getData().getExportOptions(); + assertInstanceOf(GeneralFileExportOptions.class, exportOptions); + assertEquals("/localization/%locale%/%file_name%.%file_extension%", ((GeneralFileExportOptions) exportOptions).getExportPattern()); + + assertEquals(false, ((DocxFileImportOptions) importOptions).getCleanTagsAggressively()); + assertEquals(true, ((DocxFileImportOptions) importOptions).getTranslateHiddenText()); + assertEquals(false, ((DocxFileImportOptions) importOptions).getTranslateHyperlinkUrls()); + assertEquals(false, ((DocxFileImportOptions) importOptions).getTranslateHiddenRowsAndColumns()); + assertEquals(true, ((DocxFileImportOptions) importOptions).getImportNotes()); + assertEquals(false, ((DocxFileImportOptions) importOptions).getImportHiddenSlides()); + assertEquals(true, ((DocxFileImportOptions) importOptions).getContentSegmentation()); + assertNull(((DocxFileImportOptions) importOptions).getSrxStorageId()); + } + // } diff --git a/src/test/java/com/crowdin/client/sourcestrings/SourceStringsApiTest.java b/src/test/java/com/crowdin/client/sourcestrings/SourceStringsApiTest.java index 20687a886..f134cb8bb 100644 --- a/src/test/java/com/crowdin/client/sourcestrings/SourceStringsApiTest.java +++ b/src/test/java/com/crowdin/client/sourcestrings/SourceStringsApiTest.java @@ -1,10 +1,7 @@ package com.crowdin.client.sourcestrings; import com.crowdin.client.core.http.exceptions.HttpBatchBadRequestException; -import com.crowdin.client.core.model.PatchOperation; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; import com.crowdin.client.sourcefiles.model.UpdateOption; @@ -28,7 +25,10 @@ public class SourceStringsApiTest extends TestClient { private final String text = "Not all videos are shown to users. See more"; private final Long projectId = 3L; + private final Long project2Id = 4L; + private final Long project3Id = 5L; private final Long id = 2814L; + private final Long id2 = 2815L; private final Long branchId = 667L; private final Long storageId = 61L; private final Long labelId = 1L; @@ -40,7 +40,12 @@ public List getMocks() { RequestMock.build(this.url + "/projects/" + projectId + "/strings/uploads/" + uploadId, HttpGet.METHOD_NAME, "api/strings/uploadStrings.json"), RequestMock.build(this.url + "/projects/" + projectId + "/strings/uploads", HttpPost.METHOD_NAME, "api/strings/uploadStringsReq.json", "api/strings/uploadStrings.json"), RequestMock.build(this.url + "/projects/" + projectId + "/strings", HttpGet.METHOD_NAME, "api/strings/listStrings.json"), - RequestMock.build(this.url + "/projects/" + projectId + "/strings", HttpGet.METHOD_NAME, "api/strings/listStrings.json"), + RequestMock.build(this.url + "/projects/" + project2Id + "/strings", HttpGet.METHOD_NAME, "api/strings/listStringsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project3Id + "/strings", HttpGet.METHOD_NAME, "api/strings/listStringsOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/projects/" + projectId + "/strings", HttpPost.METHOD_NAME, "api/strings/addStringRequest.json", "api/strings/string.json"), RequestMock.build(this.url + "/projects/" + projectId + "/strings", HttpPost.METHOD_NAME, "api/strings/addPluralStringRequest.json", "api/strings/pluralString.json"), RequestMock.build(this.url + "/projects/" + projectId + "/strings", HttpPost.METHOD_NAME, "api/strings/addStringStringsBasedRequest.json", "api/strings/string.json"), @@ -91,6 +96,97 @@ public void listStringsTest() { assertFalse(sourceStringResponseList.getData().get(0).getData().isDuplicate()); } + @Test + public void listStringsTest_orderByNull() { + ResponseList sourceStringResponseList = this.getSourceStringsApi().listSourceStrings(projectId, ListSourceStringsParams.builder().build()); + assertEquals(1, sourceStringResponseList.getData().size()); + assertEquals(id, sourceStringResponseList.getData().get(0).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(0).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(0).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(0).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(0).getData().isDuplicate()); + } + + @Test + public void listStringsTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ListSourceStringsParams params = ListSourceStringsParams + .builder() + .orderByList(singletonList(orderById)) + .build(); + + ResponseList sourceStringResponseList = this.getSourceStringsApi().listSourceStrings(project2Id, params); + assertEquals(2, sourceStringResponseList.getData().size()); + + assertEquals(id, sourceStringResponseList.getData().get(0).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(0).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(0).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(0).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(0).getData().isDuplicate()); + + assertEquals(id2, sourceStringResponseList.getData().get(1).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(1).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(1).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(1).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(1).getData().isDuplicate()); + } + + @Test + public void listStringsTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ListSourceStringsParams params = ListSourceStringsParams + .builder() + .orderByList(singletonList(orderById)) + .build(); + + ResponseList sourceStringResponseList = this.getSourceStringsApi().listSourceStrings(project2Id, params); + assertEquals(2, sourceStringResponseList.getData().size()); + + assertEquals(id, sourceStringResponseList.getData().get(0).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(0).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(0).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(0).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(0).getData().isDuplicate()); + + assertEquals(id2, sourceStringResponseList.getData().get(1).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(1).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(1).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(1).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(1).getData().isDuplicate()); + } + + @Test + public void listStringsTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ListSourceStringsParams params = ListSourceStringsParams + .builder() + .orderByList(singletonList(orderById)) + .build(); + + ResponseList sourceStringResponseList = this.getSourceStringsApi().listSourceStrings(project3Id, params); + assertEquals(2, sourceStringResponseList.getData().size()); + + assertEquals(id2, sourceStringResponseList.getData().get(0).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(0).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(0).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(0).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(0).getData().isDuplicate()); + + assertEquals(id, sourceStringResponseList.getData().get(1).getData().getId()); + assertEquals(text, sourceStringResponseList.getData().get(1).getData().getText()); + assertEquals(branchId, sourceStringResponseList.getData().get(1).getData().getBranchId()); + assertNull(sourceStringResponseList.getData().get(1).getData().getMasterStringId()); + assertFalse(sourceStringResponseList.getData().get(1).getData().isDuplicate()); + } + @Test public void addStringTest() { AddSourceStringRequest request = new AddSourceStringRequest(); diff --git a/src/test/resources/api/sourcefiles/listBranchesOrderedByIdAsc.json b/src/test/resources/api/sourcefiles/listBranchesOrderedByIdAsc.json new file mode 100644 index 000000000..331fe64ac --- /dev/null +++ b/src/test/resources/api/sourcefiles/listBranchesOrderedByIdAsc.json @@ -0,0 +1,32 @@ +{ + "data": [ + { + "data": { + "id": 34, + "projectId": 4, + "name": "develop-master-#1", + "title": "Master branch", + "exportPattern": "%three_letters_code%", + "priority": "normal", + "createdAt": "2019-09-16T13:48:04+00:00", + "updatedAt": "2019-09-19T13:25:27+00:00" + } + }, + { + "data": { + "id": 35, + "projectId": 4, + "name": "develop-master-#2", + "title": "Master branch", + "exportPattern": "%three_letters_code%", + "priority": "normal", + "createdAt": "2019-09-16T13:48:04+00:00", + "updatedAt": "2019-09-19T13:25:27+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/sourcefiles/listBranchesOrderedByIdDesc.json b/src/test/resources/api/sourcefiles/listBranchesOrderedByIdDesc.json new file mode 100644 index 000000000..0a2c877e9 --- /dev/null +++ b/src/test/resources/api/sourcefiles/listBranchesOrderedByIdDesc.json @@ -0,0 +1,32 @@ +{ + "data": [ + { + "data": { + "id": 35, + "projectId": 4, + "name": "develop-master-#2", + "title": "Master branch", + "exportPattern": "%three_letters_code%", + "priority": "normal", + "createdAt": "2019-09-16T13:48:04+00:00", + "updatedAt": "2019-09-19T13:25:27+00:00" + } + }, + { + "data": { + "id": 34, + "projectId": 4, + "name": "develop-master-#1", + "title": "Master branch", + "exportPattern": "%three_letters_code%", + "priority": "normal", + "createdAt": "2019-09-16T13:48:04+00:00", + "updatedAt": "2019-09-19T13:25:27+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/sourcefiles/listDirectoriesOrderByIdAsc.json b/src/test/resources/api/sourcefiles/listDirectoriesOrderByIdAsc.json new file mode 100644 index 000000000..7483b4821 --- /dev/null +++ b/src/test/resources/api/sourcefiles/listDirectoriesOrderByIdAsc.json @@ -0,0 +1,36 @@ +{ + "data": [ + { + "data": { + "id": 4, + "projectId": 2, + "branchId": 34, + "directoryId": 0, + "name": "main", + "title": "", + "exportPattern": "/localization/%locale%/%file_name%", + "priority": "normal", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + }, + { + "data": { + "id": 5, + "projectId": 2, + "branchId": 34, + "directoryId": 0, + "name": "main-#2", + "title": "", + "exportPattern": "/localization/%locale%/%file_name%", + "priority": "normal", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/sourcefiles/listDirectoriesOrderByIdDesc.json b/src/test/resources/api/sourcefiles/listDirectoriesOrderByIdDesc.json new file mode 100644 index 000000000..5e883fc7a --- /dev/null +++ b/src/test/resources/api/sourcefiles/listDirectoriesOrderByIdDesc.json @@ -0,0 +1,36 @@ +{ + "data": [ + { + "data": { + "id": 5, + "projectId": 2, + "branchId": 34, + "directoryId": 0, + "name": "main-#2", + "title": "", + "exportPattern": "/localization/%locale%/%file_name%", + "priority": "normal", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + }, + { + "data": { + "id": 4, + "projectId": 2, + "branchId": 34, + "directoryId": 0, + "name": "main", + "title": "", + "exportPattern": "/localization/%locale%/%file_name%", + "priority": "normal", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/sourcefiles/listFilesOrderByIdDesc.json b/src/test/resources/api/sourcefiles/listFilesOrderByIdDesc.json new file mode 100644 index 000000000..35c31e631 --- /dev/null +++ b/src/test/resources/api/sourcefiles/listFilesOrderByIdDesc.json @@ -0,0 +1,138 @@ +{ + "data": [ + { + "data": { + "id": 48, + "projectId": 2, + "branchId": 34, + "directoryId": 4, + "name": "fileB.js", + "title": "File B", + "context": "Context for fileB.js", + "type": "js", + "revisionId": 1, + "status": "active", + "priority": "normal", + "importOptions": {}, + "exportOptions": { + "exportQuotes": "single", + "exportPattern": "/files/fileB.js" + }, + "createdAt": "2019-09-19T15:10:43+00:00", + "updatedAt": "2019-09-19T15:10:46+00:00" + } + }, + { + "data": { + "id" : 47, + "projectId" : 2, + "branchId" : null, + "directoryId" : 5, + "revisionId" : 6, + "status" : "active", + "priority" : "high", + "importOptions" : { + "cleanTagsAggressively" : false, + "translateHiddenText" : true, + "translateHyperlinkUrls" : false, + "translateHiddenRowsAndColumns" : false, + "importNotes" : true, + "importHiddenSlides" : false, + "contentSegmentation" : true, + "customSegmentation" : false + }, + "exportOptions" : { + "exportPattern" : "guide.odt" + }, + "excludedTargetLanguages" : null, + "createdAt" : "2014-06-04T10:28:51+00:00", + "updatedAt" : "2022-02-23T09:16:35+00:00", + "name" : "guide.odt", + "title" : null, + "type" : "docx", + "context": "Context for guide.odt", + "path" : "/docs/guide.odt" + } + }, + { + "data": { + "id": 46, + "projectId": 2, + "branchId": 34, + "directoryId": 4, + "name": "fileB.properties", + "title": "File B", + "context": "Context for fileB.properties", + "type": "properties", + "revisionId": 1, + "status": "active", + "priority": "normal", + "importOptions": {}, + "exportOptions": { + "escapeSpecialCharacters": 1, + "exportPattern": "/files/fileB.properties" + }, + "createdAt": "2019-09-19T15:10:43+00:00", + "updatedAt": "2019-09-19T15:10:46+00:00" + } + }, + { + "data": { + "id": 45, + "projectId": 2, + "branchId": 34, + "directoryId": 4, + "name": "fileA.properties", + "title": "File A", + "context": "Context for fileA.properties", + "type": "properties", + "revisionId": 1, + "status": "active", + "priority": "normal", + "importOptions": {}, + "exportOptions": { + "escapeQuotes": 3, + "exportPattern": "/files/fileA.properties" + }, + "createdAt": "2019-09-19T15:10:43+00:00", + "updatedAt": "2019-09-19T15:10:46+00:00" + } + }, + { + "data": { + "id": 44, + "projectId": 2, + "branchId": 34, + "directoryId": 4, + "name": "umbrella_app.xliff", + "title": "source_app_info", + "context": "Context for translators", + "type": "xliff", + "parserVersion": 1, + "revisionId": 1, + "status": "active", + "path": "/path/to", + "priority": "normal", + "importOptions": { + "firstLineContainsHeader": false, + "importTranslations": true, + "scheme": { + "identifier": 0, + "sourcePhrase": 1, + "en": 2, + "de": 3 + } + }, + "exportOptions": { + "exportPattern": "/localization/%locale%/%file_name%.%file_extension%" + }, + "createdAt": "2019-09-19T15:10:43+00:00", + "updatedAt": "2019-09-19T15:10:46+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/strings/listStringsOrderByIdAsc.json b/src/test/resources/api/strings/listStringsOrderByIdAsc.json new file mode 100644 index 000000000..69af10103 --- /dev/null +++ b/src/test/resources/api/strings/listStringsOrderByIdAsc.json @@ -0,0 +1,52 @@ +{ + "data": [ + { + "data": { + "id": 2814, + "projectId": 2, + "fileId": 48, + "branchId": 667, + "identifier": "6a1821e6499ebae94de4b880fd93b985", + "text": "Not all videos are shown to users. See more", + "type": "text", + "context": "shown on main page", + "maxLength": 35, + "isHidden": false, + "revision": 1, + "hasPlurals": false, + "isIcu": false, + "labelIds": [ + 3 + ], + "createdAt": "2019-09-20T12:43:57+00:00", + "updatedAt": "2019-09-20T13:24:01+00:00" + } + }, + { + "data": { + "id": 2815, + "projectId": 2, + "fileId": 48, + "branchId": 667, + "identifier": "6a1821e6499ebae94de4b880fd93b985", + "text": "Not all videos are shown to users. See more", + "type": "text", + "context": "shown on main page", + "maxLength": 35, + "isHidden": false, + "revision": 1, + "hasPlurals": false, + "isIcu": false, + "labelIds": [ + 3 + ], + "createdAt": "2019-09-20T12:43:57+00:00", + "updatedAt": "2019-09-20T13:24:01+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/strings/listStringsOrderByIdDesc.json b/src/test/resources/api/strings/listStringsOrderByIdDesc.json new file mode 100644 index 000000000..788d19381 --- /dev/null +++ b/src/test/resources/api/strings/listStringsOrderByIdDesc.json @@ -0,0 +1,52 @@ +{ + "data": [ + { + "data": { + "id": 2815, + "projectId": 2, + "fileId": 48, + "branchId": 667, + "identifier": "6a1821e6499ebae94de4b880fd93b985", + "text": "Not all videos are shown to users. See more", + "type": "text", + "context": "shown on main page", + "maxLength": 35, + "isHidden": false, + "revision": 1, + "hasPlurals": false, + "isIcu": false, + "labelIds": [ + 3 + ], + "createdAt": "2019-09-20T12:43:57+00:00", + "updatedAt": "2019-09-20T13:24:01+00:00" + } + }, + { + "data": { + "id": 2814, + "projectId": 2, + "fileId": 48, + "branchId": 667, + "identifier": "6a1821e6499ebae94de4b880fd93b985", + "text": "Not all videos are shown to users. See more", + "type": "text", + "context": "shown on main page", + "maxLength": 35, + "isHidden": false, + "revision": 1, + "hasPlurals": false, + "isIcu": false, + "labelIds": [ + 3 + ], + "createdAt": "2019-09-20T12:43:57+00:00", + "updatedAt": "2019-09-20T13:24:01+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} From 55031a1fdcc837feb73d113eaf3286ddf0c54ed1 Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Fri, 10 Oct 2025 16:51:43 +0300 Subject: [PATCH 6/9] wip: third part of orderBy implementation in list methods --- .../client/glossaries/GlossariesApi.java | 123 +++++++-- .../glossaries/model/ListConceptsParams.java | 4 + .../model/ListGlossariesParams.java | 4 + .../glossaries/model/ListTermsParams.java | 4 + .../client/screenshots/ScreenshotsApi.java | 39 ++- .../model/ListScreenshotsParams.java | 4 + .../StringTranslationsApi.java | 133 ++++++++-- .../ListLanguageTranslationsOptions.java | 4 + .../model/ListStringTranslationsOptions.java | 4 + .../ListTranslationApprovalsOptions.java | 4 + ...ossariesApiGlossariesOrderByIdAscTest.java | 57 ++++ ...ssariesApiGlossariesOrderByIdDescTest.java | 46 ++++ .../client/glossaries/GlossariesApiTest.java | 109 +++++++- .../screenshots/ScreenshotsApiTest.java | 92 ++++++- .../StringTranslationsApiTest.java | 244 +++++++++++++++++- .../glossaries/listConceptsOrderByIdAsc.json | 56 ++++ .../glossaries/listConceptsOrderByIdDesc.json | 56 ++++ .../listGlossariesOrderByIdAsc.json | 40 +++ .../listGlossariesOrderByIdDesc.json | 40 +++ .../api/glossaries/listTermsOrderByIdAsc.json | 48 ++++ .../glossaries/listTermsOrderByIdDesc.json | 48 ++++ .../listScreenshotsOrderByIdAsc.json | 78 ++++++ .../listScreenshotsOrderByIdDesc.json | 78 ++++++ .../listApprovalsOrderByIdAsc.json | 38 +++ .../listApprovalsOrderByIdDesc.json | 38 +++ ...nguageTranslations_plain_orderByIdAsc.json | 38 +++ ...guageTranslations_plain_orderByIdDesc.json | 38 +++ .../listStringTranslationsOrderByIdAsc.json | 34 +++ .../listStringTranslationsOrderByIdDesc.json | 34 +++ 29 files changed, 1474 insertions(+), 61 deletions(-) create mode 100644 src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdAscTest.java create mode 100644 src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdDescTest.java create mode 100644 src/test/resources/api/glossaries/listConceptsOrderByIdAsc.json create mode 100644 src/test/resources/api/glossaries/listConceptsOrderByIdDesc.json create mode 100644 src/test/resources/api/glossaries/listGlossariesOrderByIdAsc.json create mode 100644 src/test/resources/api/glossaries/listGlossariesOrderByIdDesc.json create mode 100644 src/test/resources/api/glossaries/listTermsOrderByIdAsc.json create mode 100644 src/test/resources/api/glossaries/listTermsOrderByIdDesc.json create mode 100644 src/test/resources/api/screenshots/listScreenshotsOrderByIdAsc.json create mode 100644 src/test/resources/api/screenshots/listScreenshotsOrderByIdDesc.json create mode 100644 src/test/resources/api/stringtranslations/listApprovalsOrderByIdAsc.json create mode 100644 src/test/resources/api/stringtranslations/listApprovalsOrderByIdDesc.json create mode 100644 src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdAsc.json create mode 100644 src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdDesc.json create mode 100644 src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdAsc.json create mode 100644 src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdDesc.json diff --git a/src/main/java/com/crowdin/client/glossaries/GlossariesApi.java b/src/main/java/com/crowdin/client/glossaries/GlossariesApi.java index 100cf5730..0f1e2bdb5 100644 --- a/src/main/java/com/crowdin/client/glossaries/GlossariesApi.java +++ b/src/main/java/com/crowdin/client/glossaries/GlossariesApi.java @@ -4,13 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.DownloadLinkResponseObject; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.glossaries.model.*; import java.util.List; @@ -59,11 +53,36 @@ public ResponseList listConcepts(Long glossaryId, Integer limit, Intege return listConcepts(glossaryId, params); } + /** + * @param glossaryId glossary identifier + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByFields + * @return list of concepts + * @see + */ + public ResponseList listConcepts(Long glossaryId, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListConceptsParams params = new ListConceptsParams(); + params.setLimit(limit); + params.setOffset(offset); + params.setOrderByList(orderBy); + return listConcepts(glossaryId, params); + } + public ResponseList listConcepts(Long glossaryId, ListConceptsParams params) throws HttpException, HttpBadRequestException { + ListConceptsParams query = Optional.ofNullable(params).orElse(new ListConceptsParams()); + + String orderBy = query.getOrderByList() != null + ? OrderByField.generateSortParam(query.getOrderByList()) + : query.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( - "orderBy", Optional.ofNullable(params.getOrderBy()), - "limit", Optional.ofNullable(params.getLimit()), - "offset", Optional.ofNullable(params.getOffset()) + "orderBy", Optional.ofNullable(orderBy), + "limit", Optional.ofNullable(query.getLimit()), + "offset", Optional.ofNullable(query.getOffset()) ); ConceptResponseList conceptResponseList = this.httpClient.get(this.url + "/glossaries/" + glossaryId + "/concepts", new HttpRequestConfig(queryParams), ConceptResponseList.class); return ConceptResponseList.to(conceptResponseList); @@ -128,12 +147,39 @@ public ResponseList listGlossaries(Long groupId, Integer limit, Intege return listGlossaries(params); } + /** + * @param groupId group identifier + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of glossaries + * @see + */ + public ResponseList listGlossaries(Long groupId, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListGlossariesParams params = new ListGlossariesParams(); + params.setGroupId(groupId); + params.setLimit(limit); + params.setOffset(offset); + params.setOrderByList(orderBy); + return listGlossaries(params); + } + public ResponseList listGlossaries(ListGlossariesParams params) throws HttpException, HttpBadRequestException { + ListGlossariesParams query = Optional.ofNullable(params).orElse(new ListGlossariesParams()); + + String orderBy = query.getOrderByList() != null + ? OrderByField.generateSortParam(query.getOrderByList()) + : query.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( - "groupId", Optional.ofNullable(params.getGroupId()), - "userId", Optional.ofNullable(params.getUserId()), - "limit", Optional.ofNullable(params.getLimit()), - "offset", Optional.ofNullable(params.getOffset()) + "groupId", Optional.ofNullable(query.getGroupId()), + "userId", Optional.ofNullable(query.getUserId()), + "limit", Optional.ofNullable(query.getLimit()), + "offset", Optional.ofNullable(query.getOffset()), + "orderBy", Optional.ofNullable(orderBy) ); GlossaryResponseList glossaryResponseList = this.httpClient.get(this.url + "/glossaries", new HttpRequestConfig(queryParams), GlossaryResponseList.class); return GlossaryResponseList.to(glossaryResponseList); @@ -285,16 +331,49 @@ public ResponseList listTerms(Long glossaryId, Long userId, String languag return listTerms(glossaryId, params); } + /** + * @param glossaryId glossary identifier + * @param userId user identifier + * @param languageId language identifier + * @param conceptId concept identifier + * @param translationOfTermId term identifier + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of terms + * @see + */ + public ResponseList listTerms(Long glossaryId, Long userId, String languageId, Long conceptId, @Deprecated Long translationOfTermId, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListTermsParams params = new ListTermsParams(); + params.setUserId(userId); + params.setLanguageId(languageId); + params.setConceptId(conceptId); + params.setTranslationOfTermId(translationOfTermId); + params.setLimit(limit); + params.setOffset(offset); + params.setOrderByList(orderBy); + return listTerms(glossaryId, params); + } + public ResponseList listTerms(Long glossaryId, ListTermsParams params) throws HttpException, HttpBadRequestException { + ListTermsParams query = Optional.ofNullable(params).orElse(new ListTermsParams()); + + String orderBy = query.getOrderByList() != null + ? OrderByField.generateSortParam(query.getOrderByList()) + : query.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( - "orderBy", Optional.ofNullable(params.getOrderBy()), - "userId", Optional.ofNullable(params.getUserId()), - "languageId", Optional.ofNullable(params.getLanguageId()), - "conceptId", Optional.ofNullable(params.getConceptId()), - "translationOfTermId", Optional.ofNullable(params.getTranslationOfTermId()), - "croql", Optional.ofNullable(params.getCroql()), - "limit", Optional.ofNullable(params.getLimit()), - "offset", Optional.ofNullable(params.getOffset()) + "orderBy", Optional.ofNullable(orderBy), + "userId", Optional.ofNullable(query.getUserId()), + "languageId", Optional.ofNullable(query.getLanguageId()), + "conceptId", Optional.ofNullable(query.getConceptId()), + "translationOfTermId", Optional.ofNullable(query.getTranslationOfTermId()), + "croql", Optional.ofNullable(query.getCroql()), + "limit", Optional.ofNullable(query.getLimit()), + "offset", Optional.ofNullable(query.getOffset()) ); TermResponseList termResponseList = this.httpClient.get(this.url + "/glossaries/" + glossaryId + "/terms", new HttpRequestConfig(queryParams), TermResponseList.class); return TermResponseList.to(termResponseList); diff --git a/src/main/java/com/crowdin/client/glossaries/model/ListConceptsParams.java b/src/main/java/com/crowdin/client/glossaries/model/ListConceptsParams.java index c48cbe2c7..e6f8ed0fc 100644 --- a/src/main/java/com/crowdin/client/glossaries/model/ListConceptsParams.java +++ b/src/main/java/com/crowdin/client/glossaries/model/ListConceptsParams.java @@ -1,10 +1,14 @@ package com.crowdin.client.glossaries.model; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; +import java.util.List; + @Data public class ListConceptsParams extends Pagination { private String orderBy; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/glossaries/model/ListGlossariesParams.java b/src/main/java/com/crowdin/client/glossaries/model/ListGlossariesParams.java index 4615f2cde..ca7f7aa8f 100644 --- a/src/main/java/com/crowdin/client/glossaries/model/ListGlossariesParams.java +++ b/src/main/java/com/crowdin/client/glossaries/model/ListGlossariesParams.java @@ -1,12 +1,16 @@ package com.crowdin.client.glossaries.model; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; +import java.util.List; + @Data public class ListGlossariesParams extends Pagination { private String orderBy; private Long userId; private Long groupId; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/glossaries/model/ListTermsParams.java b/src/main/java/com/crowdin/client/glossaries/model/ListTermsParams.java index 5d1ee861e..946947613 100644 --- a/src/main/java/com/crowdin/client/glossaries/model/ListTermsParams.java +++ b/src/main/java/com/crowdin/client/glossaries/model/ListTermsParams.java @@ -1,8 +1,11 @@ package com.crowdin.client.glossaries.model; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; +import java.util.List; + @Data public class ListTermsParams extends Pagination { @@ -15,4 +18,5 @@ public class ListTermsParams extends Pagination { */ private Long translationOfTermId; private String croql; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/screenshots/ScreenshotsApi.java b/src/main/java/com/crowdin/client/screenshots/ScreenshotsApi.java index 5fca63963..b85a54578 100644 --- a/src/main/java/com/crowdin/client/screenshots/ScreenshotsApi.java +++ b/src/main/java/com/crowdin/client/screenshots/ScreenshotsApi.java @@ -4,11 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.screenshots.model.*; import java.util.List; @@ -67,6 +63,32 @@ public ResponseList listScreenshots(Long projectId, List str return this.listScreenshots(projectId, screenshotsParams); } + /** + * @param projectId project identifier + * @param stringIds string identifiers + * @param labelIds label identifiers + * @param excludeLabelIds exclude label identifiers + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of screenshots + * @see + */ + public ResponseList listScreenshots(Long projectId, List stringIds, List labelIds, List excludeLabelIds, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListScreenshotsParams screenshotsParams = new ListScreenshotsParams(); + screenshotsParams.setStringIds(Optional.ofNullable(stringIds).map(l -> String.join(",", l)).orElse(null)); + screenshotsParams.setLabelIds(Optional.ofNullable(labelIds).map(l -> String.join(",", l)).orElse(null)); + screenshotsParams.setExcludeLabelIds(Optional.ofNullable(excludeLabelIds).map(l -> String.join(",", l)).orElse(null)); + screenshotsParams.setLimit(limit); + screenshotsParams.setOffset(offset); + screenshotsParams.setOrderByList(orderBy); + + return this.listScreenshots(projectId, screenshotsParams); + } + /** * @param projectId project identifier * @param params query params @@ -78,9 +100,14 @@ public ResponseList listScreenshots(Long projectId, List str */ public ResponseList listScreenshots(Long projectId, ListScreenshotsParams params) throws HttpException, HttpBadRequestException { ListScreenshotsParams query = Optional.ofNullable(params).orElse(new ListScreenshotsParams()); + + String orderBy = query.getOrderByList() != null + ? OrderByField.generateSortParam(query.getOrderByList()) + : query.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( "search", Optional.ofNullable(query.getSearch()), - "orderBy", Optional.ofNullable(query.getOrderBy()), + "orderBy", Optional.ofNullable(orderBy), "stringIds", Optional.ofNullable(query.getStringIds()), "labelIds", Optional.ofNullable(query.getLabelIds()), "excludeLabelIds", Optional.ofNullable(query.getExcludeLabelIds()), diff --git a/src/main/java/com/crowdin/client/screenshots/model/ListScreenshotsParams.java b/src/main/java/com/crowdin/client/screenshots/model/ListScreenshotsParams.java index a194f3f24..ff2d18549 100644 --- a/src/main/java/com/crowdin/client/screenshots/model/ListScreenshotsParams.java +++ b/src/main/java/com/crowdin/client/screenshots/model/ListScreenshotsParams.java @@ -1,9 +1,12 @@ package com.crowdin.client.screenshots.model; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @EqualsAndHashCode(callSuper = true) @Data public class ListScreenshotsParams extends Pagination { @@ -13,4 +16,5 @@ public class ListScreenshotsParams extends Pagination { private String stringIds; private String labelIds; private String excludeLabelIds; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/stringtranslations/StringTranslationsApi.java b/src/main/java/com/crowdin/client/stringtranslations/StringTranslationsApi.java index d654cbfdb..b6ff3882b 100644 --- a/src/main/java/com/crowdin/client/stringtranslations/StringTranslationsApi.java +++ b/src/main/java/com/crowdin/client/stringtranslations/StringTranslationsApi.java @@ -63,17 +63,54 @@ public ResponseList listTranslationApprovals(Long projectId, Long file return listTranslationApprovals(projectId, options); } + /** + * @param projectId project identifier + * @param fileId file identifier + * @param stringId string identifier + * @param languageId language identifier + * @param translationId translation identifier + * @param labelIds filter approvals by labelIds + * @param excludeLabelIds exclude approvals by labelIds + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of approvals + * @see + */ + public ResponseList listTranslationApprovals(Long projectId, Long fileId, Long stringId, String languageId, Long translationId, String labelIds, String excludeLabelIds, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListTranslationApprovalsOptions options = new ListTranslationApprovalsOptions(); + options.setFileId(fileId); + options.setStringId(stringId); + options.setLanguageId(languageId); + options.setTranslationId(translationId); + options.setLabelIds(labelIds); + options.setExcludeLabelIds(excludeLabelIds); + options.setLimit(limit); + options.setOffset(offset); + options.setOrderByList(orderBy); + return listTranslationApprovals(projectId, options); + } + public ResponseList listTranslationApprovals(Long projectId, ListTranslationApprovalsOptions options) throws HttpException, HttpBadRequestException { + ListTranslationApprovalsOptions query = Optional.ofNullable(options).orElse(new ListTranslationApprovalsOptions()); + + String orderBy = query.getOrderByList() != null + ? OrderByField.generateSortParam(query.getOrderByList()) + : query.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( - "orderBy", Optional.ofNullable(options.getOrderBy()), - "fileId", Optional.ofNullable(options.getFileId()), - "labelIds", Optional.ofNullable(options.getLabelIds()), - "excludeLabelIds", Optional.ofNullable(options.getExcludeLabelIds()), - "stringId", Optional.ofNullable(options.getStringId()), - "languageId", Optional.ofNullable(options.getLanguageId()), - "translationId", Optional.ofNullable(options.getTranslationId()), - "limit", Optional.ofNullable(options.getLimit()), - "offset", Optional.ofNullable(options.getOffset()) + "fileId", Optional.ofNullable(query.getFileId()), + "labelIds", Optional.ofNullable(query.getLabelIds()), + "excludeLabelIds", Optional.ofNullable(query.getExcludeLabelIds()), + "stringId", Optional.ofNullable(query.getStringId()), + "languageId", Optional.ofNullable(query.getLanguageId()), + "translationId", Optional.ofNullable(query.getTranslationId()), + "limit", Optional.ofNullable(query.getLimit()), + "offset", Optional.ofNullable(query.getOffset()), + "orderBy", Optional.ofNullable(orderBy) ); ApprovalResponseList approvalResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/approvals", new HttpRequestConfig(queryParams), ApprovalResponseList.class); return ApprovalResponseList.to(approvalResponseList); @@ -192,6 +229,40 @@ public ResponseList listLanguageTranslations(Long projectI return listLanguageTranslations(projectId, languageId, options); } + /** + * @param projectId project identifier + * @param languageId language identifier + * @param stringIds filter translations by stringIds + * @param labelIds filter translations by labelIds + * @param fileId filter translations by file identifier + * @param branchId filter translations by branchId + * @param directoryId filter translations by directoryId + * @param croql filter translations by croql + * @param denormalizePlaceholders enable denormalize placeholders + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderByField + * @return list of language translations + * @see + */ + public ResponseList listLanguageTranslations(Long projectId, String languageId, String stringIds, String labelIds, Long fileId, Long branchId, Long directoryId, String croql, Integer denormalizePlaceholders, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListLanguageTranslationsOptions options = new ListLanguageTranslationsOptions(); + options.setStringIds(stringIds); + options.setLabelIds(labelIds); + options.setFileId(fileId); + options.setBranchId(branchId); + options.setDirectoryId(directoryId); + options.setCroql(croql); + options.setDenormalizePlaceholders(BooleanInt.fromInt(denormalizePlaceholders)); + options.setLimit(limit); + options.setOffset(offset); + options.setOrderByList(orderBy); + return listLanguageTranslations(projectId, languageId, options); + } + public ResponseList listLanguageTranslations(Long projectId, String languageId, ListLanguageTranslationsOptions options) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/projects/%d/languages/%s/translations", this.url, projectId, languageId); Map> queryParams = HttpRequestConfig.buildUrlParams( @@ -205,7 +276,8 @@ public ResponseList listLanguageTranslations(Long projectI "croql", Optional.ofNullable(options.getCroql()), "denormalizePlaceholders", Optional.ofNullable(options.getDenormalizePlaceholders()), "limit", Optional.ofNullable(options.getLimit()), - "offset", Optional.ofNullable(options.getOffset()) + "offset", Optional.ofNullable(options.getOffset()), + "orderBy", Optional.ofNullable(OrderByField.generateSortParam(options.getOrderByList())) ); LanguageTranslationsResponseList languageTranslationsResponseList = this.httpClient.get(builtUrl, new HttpRequestConfig(queryParams), LanguageTranslationsResponseList.class); return LanguageTranslationsResponseList.to(languageTranslationsResponseList); @@ -232,14 +304,43 @@ public ResponseList listStringTranslations(Long projectId, Lo return listStringTranslations(projectId, options); } + /** + * @param projectId project identifier + * @param stringId string identifier + * @param languageId language identifier + * @param limit maximum number of items to retrieve (default 25) + * @param offset starting offset in the collection (default 0) + * @param orderBy list of OrderBy field + * @return list of string translations + * @see + */ + public ResponseList listStringTranslations(Long projectId, Long stringId, String languageId, Integer limit, Integer offset, List orderBy) throws HttpException, HttpBadRequestException { + ListStringTranslationsOptions options = new ListStringTranslationsOptions(); + options.setStringId(stringId); + options.setLanguageId(languageId); + options.setLimit(limit); + options.setOffset(offset); + options.setOrderByList(orderBy); + return listStringTranslations(projectId, options); + } + public ResponseList listStringTranslations(Long projectId, ListStringTranslationsOptions options) throws HttpException, HttpBadRequestException { + ListStringTranslationsOptions query = Optional.ofNullable(options).orElse(new ListStringTranslationsOptions()); + + String orderBy = query.getOrderByList() != null + ? OrderByField.generateSortParam(query.getOrderByList()) + : query.getOrderBy(); + Map> queryParams = HttpRequestConfig.buildUrlParams( - "stringId", Optional.ofNullable(options.getStringId()), - "languageId", Optional.ofNullable(options.getLanguageId()), - "orderBy", Optional.ofNullable(options.getOrderBy()), - "denormalizePlaceholders", Optional.ofNullable(options.getDenormalizePlaceholders()), - "limit", Optional.ofNullable(options.getLimit()), - "offset", Optional.ofNullable(options.getOffset()) + "stringId", Optional.ofNullable(query.getStringId()), + "languageId", Optional.ofNullable(query.getLanguageId()), + "denormalizePlaceholders", Optional.ofNullable(query.getDenormalizePlaceholders()), + "limit", Optional.ofNullable(query.getLimit()), + "offset", Optional.ofNullable(query.getOffset()), + "orderBy", Optional.ofNullable(orderBy) ); StringTranslationResponseList stringTranslationResponseList = this.httpClient.get(this.url + "/projects/" + projectId + "/translations", new HttpRequestConfig(queryParams), StringTranslationResponseList.class); return StringTranslationResponseList.to(stringTranslationResponseList); diff --git a/src/main/java/com/crowdin/client/stringtranslations/model/ListLanguageTranslationsOptions.java b/src/main/java/com/crowdin/client/stringtranslations/model/ListLanguageTranslationsOptions.java index cb740322a..9d758754e 100644 --- a/src/main/java/com/crowdin/client/stringtranslations/model/ListLanguageTranslationsOptions.java +++ b/src/main/java/com/crowdin/client/stringtranslations/model/ListLanguageTranslationsOptions.java @@ -1,10 +1,13 @@ package com.crowdin.client.stringtranslations.model; import com.crowdin.client.core.model.BooleanInt; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @EqualsAndHashCode(callSuper = true) @Data public class ListLanguageTranslationsOptions extends Pagination { @@ -18,4 +21,5 @@ public class ListLanguageTranslationsOptions extends Pagination { private Integer minApprovalCount; private String croql; private BooleanInt denormalizePlaceholders; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/stringtranslations/model/ListStringTranslationsOptions.java b/src/main/java/com/crowdin/client/stringtranslations/model/ListStringTranslationsOptions.java index 61a86eee3..204821449 100644 --- a/src/main/java/com/crowdin/client/stringtranslations/model/ListStringTranslationsOptions.java +++ b/src/main/java/com/crowdin/client/stringtranslations/model/ListStringTranslationsOptions.java @@ -1,10 +1,13 @@ package com.crowdin.client.stringtranslations.model; import com.crowdin.client.core.model.BooleanInt; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @EqualsAndHashCode(callSuper = true) @Data public class ListStringTranslationsOptions extends Pagination { @@ -13,4 +16,5 @@ public class ListStringTranslationsOptions extends Pagination { private String languageId; private String orderBy; private BooleanInt denormalizePlaceholders; + private List orderByList; } diff --git a/src/main/java/com/crowdin/client/stringtranslations/model/ListTranslationApprovalsOptions.java b/src/main/java/com/crowdin/client/stringtranslations/model/ListTranslationApprovalsOptions.java index 78ff5b728..5512fd43c 100644 --- a/src/main/java/com/crowdin/client/stringtranslations/model/ListTranslationApprovalsOptions.java +++ b/src/main/java/com/crowdin/client/stringtranslations/model/ListTranslationApprovalsOptions.java @@ -1,9 +1,12 @@ package com.crowdin.client.stringtranslations.model; +import com.crowdin.client.core.model.OrderByField; import com.crowdin.client.core.model.Pagination; import lombok.Data; import lombok.EqualsAndHashCode; +import java.util.List; + @EqualsAndHashCode(callSuper = true) @Data public class ListTranslationApprovalsOptions extends Pagination { @@ -15,4 +18,5 @@ public class ListTranslationApprovalsOptions extends Pagination { private Long stringId; private String languageId; private Long translationId; + private List orderByList; } diff --git a/src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdAscTest.java b/src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdAscTest.java new file mode 100644 index 000000000..4b34f43b3 --- /dev/null +++ b/src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdAscTest.java @@ -0,0 +1,57 @@ +package com.crowdin.client.glossaries; + +import com.crowdin.client.core.model.*; +import com.crowdin.client.framework.RequestMock; +import com.crowdin.client.framework.TestClient; +import com.crowdin.client.glossaries.model.*; +import org.apache.http.client.methods.*; +import org.junit.jupiter.api.Test; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.util.Collections.reverseOrder; +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class GlossariesApiGlossariesOrderByIdAscTest extends TestClient { + + private final Long glossaryId = 2L; + private final Long glossary2Id = 3L; + + @Override + public List getMocks() { + return Arrays.asList( + RequestMock.build(this.url + "/glossaries", HttpGet.METHOD_NAME, "api/glossaries/listGlossariesOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}) + ); + } + + @Test + public void listGlossariesTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList glossaryResponseList = this.getGlossariesApi().listGlossaries(null, null, null, singletonList(orderById)); + assertEquals(2, glossaryResponseList.getData().size()); + assertEquals(glossaryId, glossaryResponseList.getData().get(0).getData().getId()); + assertEquals(glossary2Id, glossaryResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listGlossariesTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList glossaryResponseList = this.getGlossariesApi().listGlossaries(null, null, null, singletonList(orderById)); + assertEquals(2, glossaryResponseList.getData().size()); + assertEquals(glossaryId, glossaryResponseList.getData().get(0).getData().getId()); + assertEquals(glossary2Id, glossaryResponseList.getData().get(1).getData().getId()); + } +} + + diff --git a/src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdDescTest.java b/src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdDescTest.java new file mode 100644 index 000000000..998312746 --- /dev/null +++ b/src/test/java/com/crowdin/client/glossaries/GlossariesApiGlossariesOrderByIdDescTest.java @@ -0,0 +1,46 @@ +package com.crowdin.client.glossaries; + +import com.crowdin.client.core.model.OrderByField; +import com.crowdin.client.core.model.ResponseList; +import com.crowdin.client.core.model.SortOrder; +import com.crowdin.client.framework.RequestMock; +import com.crowdin.client.framework.TestClient; +import com.crowdin.client.glossaries.model.Glossary; +import org.apache.http.client.methods.HttpGet; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import static java.util.Collections.singletonList; +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class GlossariesApiGlossariesOrderByIdDescTest extends TestClient { + + private final Long glossaryId = 2L; + private final Long glossary2Id = 3L; + + @Override + public List getMocks() { + return Arrays.asList( + RequestMock.build(this.url + "/glossaries", HttpGet.METHOD_NAME, "api/glossaries/listGlossariesOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}) + ); + } + + @Test + public void listGlossariesTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList glossaryResponseList = this.getGlossariesApi().listGlossaries(null, null, null, singletonList(orderById)); + assertEquals(2, glossaryResponseList.getData().size()); + assertEquals(glossary2Id, glossaryResponseList.getData().get(0).getData().getId()); + assertEquals(glossaryId, glossaryResponseList.getData().get(1).getData().getId()); + } +} + + diff --git a/src/test/java/com/crowdin/client/glossaries/GlossariesApiTest.java b/src/test/java/com/crowdin/client/glossaries/GlossariesApiTest.java index 320656c20..42886f017 100644 --- a/src/test/java/com/crowdin/client/glossaries/GlossariesApiTest.java +++ b/src/test/java/com/crowdin/client/glossaries/GlossariesApiTest.java @@ -1,10 +1,6 @@ package com.crowdin.client.glossaries; -import com.crowdin.client.core.model.DownloadLink; -import com.crowdin.client.core.model.PatchOperation; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; import com.crowdin.client.glossaries.model.*; @@ -26,9 +22,12 @@ public class GlossariesApiTest extends TestClient { private final Long projectId = 2L; private final Long glossaryId = 2L; + private final Long glossary2Id = 3L; + private final Long glossary3Id = 4L; private final Long groupId = 2L; private final Long conceptId = 3L; private final Long termId = 2L; + private final Long term2Id = 3L; private final String name = "Be My Eyes iOS's Glossary"; private final String subject = "general"; private final String text = "Voir"; @@ -42,6 +41,12 @@ public class GlossariesApiTest extends TestClient { public List getMocks() { return Arrays.asList( RequestMock.build(this.url + "/glossaries/" + glossaryId + "/concepts", HttpGet.METHOD_NAME, "api/glossaries/listConcepts.json"), + RequestMock.build(this.url + "/glossaries/" + glossary2Id + "/concepts", HttpGet.METHOD_NAME, "api/glossaries/listConceptsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/glossaries/" + glossary3Id + "/concepts", HttpGet.METHOD_NAME, "api/glossaries/listConceptsOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/concepts/" + conceptId, HttpGet.METHOD_NAME, "api/glossaries/concept.json"), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/concepts/" + conceptId, HttpPut.METHOD_NAME, "api/glossaries/updateConcept.json", "api/glossaries/concept.json"), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/concepts/" + conceptId, HttpDelete.METHOD_NAME), @@ -56,6 +61,12 @@ public List getMocks() { RequestMock.build(this.url + "/glossaries/" + glossaryId + "/imports", HttpPost.METHOD_NAME, "api/glossaries/importGlossary.json", "api/glossaries/importGlossaryStatus.json"), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/imports/" + importId, HttpGet.METHOD_NAME, "api/glossaries/importGlossaryStatus.json"), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/terms", HttpGet.METHOD_NAME, "api/glossaries/listTerms.json"), + RequestMock.build(this.url + "/glossaries/" + glossary2Id + "/terms", HttpGet.METHOD_NAME, "api/glossaries/listTermsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/glossaries/" + glossary3Id + "/terms", HttpGet.METHOD_NAME, "api/glossaries/listTermsOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/terms", HttpPost.METHOD_NAME, "api/glossaries/addTermRequest.json", "api/glossaries/term.json"), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/terms", HttpDelete.METHOD_NAME), RequestMock.build(this.url + "/glossaries/" + glossaryId + "/terms/" + termId, HttpGet.METHOD_NAME, "api/glossaries/term.json"), @@ -87,6 +98,49 @@ public void listConceptsTest() { assertEquals(conceptResponseList.getData().get(0).getData().getSubject(), subject); } + @Test + public void listConceptsTest_orderByNull() { + ResponseList conceptResponseList = this.getGlossariesApi().listConcepts(glossaryId, null, null, null); + assertEquals(1, conceptResponseList.getData().size()); + assertEquals(glossaryId, conceptResponseList.getData().get(0).getData().getId()); + assertEquals(subject, conceptResponseList.getData().get(0).getData().getSubject()); + } + + @Test + public void listConceptsTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList conceptResponseList = this.getGlossariesApi().listConcepts(glossary2Id, null, null, singletonList(orderById)); + assertEquals(2, conceptResponseList.getData().size()); + assertEquals(glossaryId, conceptResponseList.getData().get(0).getData().getId()); + assertEquals(glossary2Id, conceptResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listConceptsTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList conceptResponseList = this.getGlossariesApi().listConcepts(glossary2Id, null, null, singletonList(orderById)); + assertEquals(2, conceptResponseList.getData().size()); + assertEquals(glossaryId, conceptResponseList.getData().get(0).getData().getId()); + assertEquals(glossary2Id, conceptResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listConceptsTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList conceptResponseList = this.getGlossariesApi().listConcepts(glossary3Id, null, null, singletonList(orderById)); + assertEquals(2, conceptResponseList.getData().size()); + assertEquals(glossary2Id, conceptResponseList.getData().get(0).getData().getId()); + assertEquals(glossaryId, conceptResponseList.getData().get(1).getData().getId()); + } + @Test public void getConceptTest() { TimeZone.setDefault(tz); @@ -212,6 +266,51 @@ public void listTermsTest() { assertEquals(new Date(119,Calendar.SEPTEMBER,23,7,19,47), termResponseList.getData().get(0).getData().getCreatedAt()); } + @Test + public void listTermsTest_orderByNull() { + TimeZone.setDefault(tz); + ResponseList termResponseList = this.getGlossariesApi().listTerms(glossaryId, null, null, null, null, null, null, null); + assertEquals(1, termResponseList.getData().size()); + assertEquals(termId, termResponseList.getData().get(0).getData().getId()); + + } + + @Test + public void listTermsTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + TimeZone.setDefault(tz); + ResponseList termResponseList = this.getGlossariesApi().listTerms(glossary2Id, null, null, null, null, null, null, singletonList(orderById)); + assertEquals(2, termResponseList.getData().size()); + assertEquals(termId, termResponseList.getData().get(0).getData().getId()); + assertEquals(term2Id, termResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listTermsTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList termResponseList = this.getGlossariesApi().listTerms(glossary2Id, null, null, null, null, null, null, singletonList(orderById)); + assertEquals(2, termResponseList.getData().size()); + assertEquals(termId, termResponseList.getData().get(0).getData().getId()); + assertEquals(term2Id, termResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listTermsTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList termResponseList = this.getGlossariesApi().listTerms(glossary3Id, null, null, null, null, null, null, singletonList(orderById)); + assertEquals(2, termResponseList.getData().size()); + assertEquals(term2Id, termResponseList.getData().get(0).getData().getId()); + assertEquals(termId, termResponseList.getData().get(1).getData().getId()); + } + @Test public void addTermTest() { AddTermRequest request = new AddTermRequest(); diff --git a/src/test/java/com/crowdin/client/screenshots/ScreenshotsApiTest.java b/src/test/java/com/crowdin/client/screenshots/ScreenshotsApiTest.java index 8c6561c79..9b5303831 100644 --- a/src/test/java/com/crowdin/client/screenshots/ScreenshotsApiTest.java +++ b/src/test/java/com/crowdin/client/screenshots/ScreenshotsApiTest.java @@ -1,9 +1,6 @@ package com.crowdin.client.screenshots; -import com.crowdin.client.core.model.PatchOperation; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; import com.crowdin.client.screenshots.model.AddScreenshotRequest; @@ -28,7 +25,10 @@ public class ScreenshotsApiTest extends TestClient { private final Long projectId = 3L; + private final Long project2Id = 4L; + private final Long project3Id = 5L; private final Long screenshotId = 2L; + private final Long screenshot2Id = 3L; private final Long storageId = 71L; private final Long fileId = 48L; private final Long tagId = 98L; @@ -41,6 +41,12 @@ public class ScreenshotsApiTest extends TestClient { public List getMocks() { return Arrays.asList( RequestMock.build(this.url + "/projects/" + projectId + "/screenshots", HttpGet.METHOD_NAME, "api/screenshots/listScreenshots.json"), + RequestMock.build(this.url + "/projects/" + project2Id + "/screenshots", HttpGet.METHOD_NAME, "api/screenshots/listScreenshotsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project3Id + "/screenshots", HttpGet.METHOD_NAME, "api/screenshots/listScreenshotsOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), RequestMock.build(this.url + "/projects/" + projectId + "/screenshots", HttpPost.METHOD_NAME, "api/screenshots/addScreenshotRequest.json", "api/screenshots/screenshot.json"), RequestMock.build(this.url + "/projects/" + projectId + "/screenshots/" + screenshotId, HttpGet.METHOD_NAME, "api/screenshots/screenshot.json"), RequestMock.build(this.url + "/projects/" + projectId + "/screenshots/" + screenshotId, HttpPut.METHOD_NAME, "api/screenshots/updateScreenshotRequest.json", "api/screenshots/screenshot.json"), @@ -70,6 +76,84 @@ public void newListScreenshotsTest() { assertEquals(screenshotResponseList.getData().get(0).getData().getId(), screenshotId); } + @Test + public void newListScreenshotsTest_orderByNull() { + ResponseList screenshotResponseList = this.getScreenshotsApi().listScreenshots( + projectId, + null, + null, + null, + null, + null, + null + ); + + assertEquals(1, screenshotResponseList.getData().size()); + assertEquals(screenshotId, screenshotResponseList.getData().get(0).getData().getId()); + } + + @Test + public void newListScreenshotsTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList screenshotResponseList = this.getScreenshotsApi().listScreenshots( + project2Id, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, screenshotResponseList.getData().size()); + assertEquals(screenshotId, screenshotResponseList.getData().get(0).getData().getId()); + assertEquals(screenshot2Id, screenshotResponseList.getData().get(1).getData().getId()); + } + + @Test + public void newListScreenshotsTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList screenshotResponseList = this.getScreenshotsApi().listScreenshots( + project2Id, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, screenshotResponseList.getData().size()); + assertEquals(screenshotId, screenshotResponseList.getData().get(0).getData().getId()); + assertEquals(screenshot2Id, screenshotResponseList.getData().get(1).getData().getId()); + } + + @Test + public void newListScreenshotsTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList screenshotResponseList = this.getScreenshotsApi().listScreenshots( + project3Id, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, screenshotResponseList.getData().size()); + assertEquals(screenshot2Id, screenshotResponseList.getData().get(0).getData().getId()); + assertEquals(screenshotId, screenshotResponseList.getData().get(1).getData().getId()); + } + @Test public void addScreenshotTest() { AddScreenshotRequest request = new AddScreenshotRequest(); diff --git a/src/test/java/com/crowdin/client/stringtranslations/StringTranslationsApiTest.java b/src/test/java/com/crowdin/client/stringtranslations/StringTranslationsApiTest.java index 5d6996434..cfd17e878 100644 --- a/src/test/java/com/crowdin/client/stringtranslations/StringTranslationsApiTest.java +++ b/src/test/java/com/crowdin/client/stringtranslations/StringTranslationsApiTest.java @@ -1,38 +1,47 @@ package com.crowdin.client.stringtranslations; -import com.crowdin.client.core.model.PatchOperation; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; import com.crowdin.client.stringtranslations.model.*; import org.apache.http.client.methods.*; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Collections; +import java.util.*; +import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.*; public class StringTranslationsApiTest extends TestClient { private final Long projectId = 3L; + private final Long project2Id = 4L; + private final Long project3Id = 5L; private final Long secondProjectId = 4L; private final Long thirdProjectId = 5L; + private final Long fourthProjectId = 6L; + private final Long fifthProjectId = 7L; private final Long approvalId = 190695L; + private final Long approval2Id = 190696L; private final Long translationId = 190694L; + private final Long translation2Id = 190695L; private final String text = "Цю стрічку перекладено"; private final String language = "uk"; private final Long stringId = 35434L; + private final Long string2Id = 35435L; private final Long voteId = 6643L; @Override public List getMocks() { return Arrays.asList( RequestMock.build(this.url + "/projects/" + projectId + "/approvals", HttpGet.METHOD_NAME, "api/stringtranslations/listApprovals.json"), + RequestMock.build(this.url + "/projects/" + project2Id + "/approvals", HttpGet.METHOD_NAME, "api/stringtranslations/listApprovalsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project3Id + "/approvals", HttpGet.METHOD_NAME, "api/stringtranslations/listApprovalsOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), + RequestMock.build(this.url + "/projects/" + project3Id + "/approvals", HttpGet.METHOD_NAME, "api/stringtranslations/listApprovals.json"), RequestMock.build(this.url + "/projects/" + projectId + "/approvals", HttpPost.METHOD_NAME, "api/stringtranslations/addApprovalRequest.json", "api/stringtranslations/approval.json"), RequestMock.build(this.url + "/projects/" + projectId + "/approvals/" + approvalId, HttpGet.METHOD_NAME, "api/stringtranslations/approval.json"), RequestMock.build(this.url + "/projects/" + projectId + "/approvals", HttpDelete.METHOD_NAME, null, Collections.singletonMap("stringId", stringId)), @@ -40,7 +49,22 @@ public List getMocks() { RequestMock.build(String.format("%s/projects/%d/languages/%s/translations", this.url, projectId, language), HttpGet.METHOD_NAME, "api/stringtranslations/listLanguageTranslations_plain.json"), RequestMock.build(String.format("%s/projects/%d/languages/%s/translations", this.url, secondProjectId, language), HttpGet.METHOD_NAME, "api/stringtranslations/listLanguageTranslations_plural.json"), RequestMock.build(String.format("%s/projects/%d/languages/%s/translations", this.url, thirdProjectId, language), HttpGet.METHOD_NAME, "api/stringtranslations/listLanguageTranslations_ICU.json"), + + RequestMock.build(String.format("%s/projects/%d/languages/%s/translations", this.url, fourthProjectId, language), HttpGet.METHOD_NAME, "api/stringtranslations/listLanguageTranslations_plain_orderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(String.format("%s/projects/%d/languages/%s/translations", this.url, fifthProjectId, language), HttpGet.METHOD_NAME, "api/stringtranslations/listLanguageTranslations_plain_orderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), + RequestMock.build(this.url + "/projects/" + projectId + "/translations", HttpGet.METHOD_NAME, "api/stringtranslations/listStringTranslations..json"), + RequestMock.build(this.url + "/projects/" + project2Id + "/translations", HttpGet.METHOD_NAME, "api/stringtranslations/listStringTranslationsOrderByIdAsc.json", new HashMap() {{ + put("orderBy", "id%20asc"); + }}), + RequestMock.build(this.url + "/projects/" + project3Id + "/translations", HttpGet.METHOD_NAME, "api/stringtranslations/listStringTranslationsOrderByIdDesc.json", new HashMap() {{ + put("orderBy", "id%20desc"); + }}), + RequestMock.build(this.url + "/projects/" + projectId + "/translations", HttpPost.METHOD_NAME, "api/stringtranslations/addTranslationRequest.json", "api/stringtranslations/translation.json"), RequestMock.build(this.url + "/projects/" + projectId + "/translations", HttpDelete.METHOD_NAME, null, Collections.singletonMap("stringId", stringId)), RequestMock.build(this.url + "/projects/" + projectId + "/translations/" + translationId, HttpGet.METHOD_NAME, "api/stringtranslations/translation.json"), @@ -86,6 +110,48 @@ public void listApprovalsTest() { assertEquals(approvalId, approvalResponseList.getData().get(0).getData().getId()); } + @Test + public void listApprovalsTest_orderByNull() { + ResponseList approvalResponseList = this.getStringTranslationsApi().listTranslationApprovals(projectId, null, null, null, null, null, null, null, null, null); + assertEquals(1, approvalResponseList.getData().size()); + assertEquals(approvalId, approvalResponseList.getData().get(0).getData().getId()); + } + + @Test + public void listApprovalsTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList approvalResponseList = this.getStringTranslationsApi().listTranslationApprovals(project2Id, null, null, null, null, null, null, null, null, singletonList(orderById)); + assertEquals(2, approvalResponseList.getData().size()); + assertEquals(approvalId, approvalResponseList.getData().get(0).getData().getId()); + assertEquals(approval2Id, approvalResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listApprovalsTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList approvalResponseList = this.getStringTranslationsApi().listTranslationApprovals(project2Id, null, null, null, null, null, null, null, null, singletonList(orderById)); + assertEquals(2, approvalResponseList.getData().size()); + assertEquals(approvalId, approvalResponseList.getData().get(0).getData().getId()); + assertEquals(approval2Id, approvalResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listApprovalsTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList approvalResponseList = this.getStringTranslationsApi().listTranslationApprovals(project3Id, null, null, null, null, null, null, null, null, singletonList(orderById)); + assertEquals(2, approvalResponseList.getData().size()); + assertEquals(approval2Id, approvalResponseList.getData().get(0).getData().getId()); + assertEquals(approvalId, approvalResponseList.getData().get(1).getData().getId()); + } + @Test public void addApprovalTest() { AddApprovalRequest request = new AddApprovalRequest(); @@ -118,6 +184,94 @@ public void listLanguageTranslationsPlainTest() { assertEquals(stringId, ((PlainLanguageTranslations) languageTranslationsList.getData().get(0).getData()).getStringId()); } + @Test + public void listLanguageTranslationsPlainTest_orderByNull() { + ResponseList languageTranslationsList = this.getStringTranslationsApi().listLanguageTranslations(projectId, language, null, null, null, null, null, null, null, null, null, null); + assertEquals(1, languageTranslationsList.getData().size()); + assertTrue(languageTranslationsList.getData().get(0).getData() instanceof PlainLanguageTranslations, "Wrong return type, must be PlainLanguageTranslations"); + assertEquals(stringId, ((PlainLanguageTranslations) languageTranslationsList.getData().get(0).getData()).getStringId()); + } + + @Test + public void listLanguageTranslationsPlainTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList languageTranslationsList = this.getStringTranslationsApi().listLanguageTranslations( + fourthProjectId, + language, + null, + null, + null, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, languageTranslationsList.getData().size()); + + assertEquals(stringId, ((PlainLanguageTranslations) languageTranslationsList.getData().get(0).getData()).getStringId()); + assertEquals(string2Id, ((PlainLanguageTranslations) languageTranslationsList.getData().get(1).getData()).getStringId()); + } + + @Test + public void listLanguageTranslationsPlainTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList languageTranslationsList = this.getStringTranslationsApi().listLanguageTranslations( + fourthProjectId, + language, + null, + null, + null, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, languageTranslationsList.getData().size()); + + assertEquals(stringId, ((PlainLanguageTranslations) languageTranslationsList.getData().get(0).getData()).getStringId()); + assertEquals(string2Id, ((PlainLanguageTranslations) languageTranslationsList.getData().get(1).getData()).getStringId()); + } + + @Test + public void listLanguageTranslationsPlainTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList languageTranslationsList = this.getStringTranslationsApi().listLanguageTranslations( + fifthProjectId, + language, + null, + null, + null, + null, + null, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, languageTranslationsList.getData().size()); + + assertEquals(string2Id, ((PlainLanguageTranslations) languageTranslationsList.getData().get(0).getData()).getStringId()); + assertEquals(stringId, ((PlainLanguageTranslations) languageTranslationsList.getData().get(1).getData()).getStringId()); + } + @Test public void listLanguageTranslationsPluralTest() { ResponseList languageTranslationsList = this.getStringTranslationsApi().listLanguageTranslations(secondProjectId, language, null, null, null, null, null, null, null, null, null); @@ -141,6 +295,80 @@ public void listStringTranslationsTest() { assertEquals(stringTranslationResponseList.getData().get(0).getData().getId(), translationId); } + @Test + public void listStringTranslationsTest_orderByNull() { + ResponseList stringTranslationResponseList = this.getStringTranslationsApi().listStringTranslations( + projectId, + null, + null, + null, + null, + null + ); + + assertEquals(1, stringTranslationResponseList.getData().size()); + assertEquals(translationId, stringTranslationResponseList.getData().get(0).getData().getId()); + } + + @Test + public void listStringTranslationsTest_orderByIdNull() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + + ResponseList stringTranslationResponseList = this.getStringTranslationsApi().listStringTranslations( + project2Id, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, stringTranslationResponseList.getData().size()); + assertEquals(translationId, stringTranslationResponseList.getData().get(0).getData().getId()); + assertEquals(translation2Id, stringTranslationResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listStringTranslationsTest_orderByIdAsc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.ASC); + + ResponseList stringTranslationResponseList = this.getStringTranslationsApi().listStringTranslations( + project2Id, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, stringTranslationResponseList.getData().size()); + assertEquals(translationId, stringTranslationResponseList.getData().get(0).getData().getId()); + assertEquals(translation2Id, stringTranslationResponseList.getData().get(1).getData().getId()); + } + + @Test + public void listStringTranslationsTest_orderByIdDesc() { + OrderByField orderById = new OrderByField(); + orderById.setFieldName("id"); + orderById.setOrderBy(SortOrder.DESC); + + ResponseList stringTranslationResponseList = this.getStringTranslationsApi().listStringTranslations( + project3Id, + null, + null, + null, + null, + singletonList(orderById) + ); + + assertEquals(2, stringTranslationResponseList.getData().size()); + assertEquals(translation2Id, stringTranslationResponseList.getData().get(0).getData().getId()); + assertEquals(translationId, stringTranslationResponseList.getData().get(1).getData().getId()); + } + @Test public void addTranslationTest() { AddStringTranslationRequest request = new AddStringTranslationRequest(); diff --git a/src/test/resources/api/glossaries/listConceptsOrderByIdAsc.json b/src/test/resources/api/glossaries/listConceptsOrderByIdAsc.json new file mode 100644 index 000000000..ff68fa3ae --- /dev/null +++ b/src/test/resources/api/glossaries/listConceptsOrderByIdAsc.json @@ -0,0 +1,56 @@ +{ + "data": [ + { + "data": { + "id": 2, + "userId": 6, + "glossaryId": 6, + "subject": "general", + "definition": "Some definition", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "figure": "Figure URL", + "languagesDetails": [ + { + "languageId": "en", + "userId": 12, + "definition": "Some definition", + "note": "Some note", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + ], + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + }, + { + "data": { + "id": 3, + "userId": 6, + "glossaryId": 6, + "subject": "general", + "definition": "Some definition", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "figure": "Figure URL", + "languagesDetails": [ + { + "languageId": "en", + "userId": 12, + "definition": "Some definition", + "note": "Some note", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + ], + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/glossaries/listConceptsOrderByIdDesc.json b/src/test/resources/api/glossaries/listConceptsOrderByIdDesc.json new file mode 100644 index 000000000..08e1152ae --- /dev/null +++ b/src/test/resources/api/glossaries/listConceptsOrderByIdDesc.json @@ -0,0 +1,56 @@ +{ + "data": [ + { + "data": { + "id": 3, + "userId": 6, + "glossaryId": 6, + "subject": "general", + "definition": "Some definition", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "figure": "Figure URL", + "languagesDetails": [ + { + "languageId": "en", + "userId": 12, + "definition": "Some definition", + "note": "Some note", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + ], + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + }, + { + "data": { + "id": 2, + "userId": 6, + "glossaryId": 6, + "subject": "general", + "definition": "Some definition", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "figure": "Figure URL", + "languagesDetails": [ + { + "languageId": "en", + "userId": 12, + "definition": "Some definition", + "note": "Some note", + "createdAt": "2019-09-19T14:14:00+00:00", + "updatedAt": "2019-09-19T14:14:00+00:00" + } + ], + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/glossaries/listGlossariesOrderByIdAsc.json b/src/test/resources/api/glossaries/listGlossariesOrderByIdAsc.json new file mode 100644 index 000000000..412c40e33 --- /dev/null +++ b/src/test/resources/api/glossaries/listGlossariesOrderByIdAsc.json @@ -0,0 +1,40 @@ +{ + "data": [ + { + "data": { + "id": 2, + "name": "Be My Eyes iOS's Glossary", + "groupId": 2, + "userId": 2, + "terms": 25, + "languageIds": [ + "ro" + ], + "projectIds": [ + 6 + ], + "createdAt": "2019-09-16T13:42:04+00:00" + } + }, + { + "data": { + "id": 3, + "name": "Be My Eyes iOS's Glossary", + "groupId": 2, + "userId": 2, + "terms": 25, + "languageIds": [ + "ro" + ], + "projectIds": [ + 6 + ], + "createdAt": "2019-09-16T13:42:04+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/glossaries/listGlossariesOrderByIdDesc.json b/src/test/resources/api/glossaries/listGlossariesOrderByIdDesc.json new file mode 100644 index 000000000..96d3761e3 --- /dev/null +++ b/src/test/resources/api/glossaries/listGlossariesOrderByIdDesc.json @@ -0,0 +1,40 @@ +{ + "data": [ + { + "data": { + "id": 3, + "name": "Be My Eyes iOS's Glossary", + "groupId": 2, + "userId": 2, + "terms": 25, + "languageIds": [ + "ro" + ], + "projectIds": [ + 6 + ], + "createdAt": "2019-09-16T13:42:04+00:00" + } + }, + { + "data": { + "id": 2, + "name": "Be My Eyes iOS's Glossary", + "groupId": 2, + "userId": 2, + "terms": 25, + "languageIds": [ + "ro" + ], + "projectIds": [ + 6 + ], + "createdAt": "2019-09-16T13:42:04+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/glossaries/listTermsOrderByIdAsc.json b/src/test/resources/api/glossaries/listTermsOrderByIdAsc.json new file mode 100644 index 000000000..038c18708 --- /dev/null +++ b/src/test/resources/api/glossaries/listTermsOrderByIdAsc.json @@ -0,0 +1,48 @@ +{ + "data": [ + { + "data": { + "id": 2, + "userId": 6, + "glossaryId": 6, + "languageId": "fr", + "text": "Voir", + "description": "use for pages only (check screenshots)", + "partOfSpeech": "verb", + "status": "preferred", + "type": "abbreviation", + "gender": "masculine", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "conceptId": 6, + "lemma": "voir", + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + }, + { + "data": { + "id": 3, + "userId": 6, + "glossaryId": 6, + "languageId": "fr", + "text": "Voir", + "description": "use for pages only (check screenshots)", + "partOfSpeech": "verb", + "status": "preferred", + "type": "abbreviation", + "gender": "masculine", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "conceptId": 6, + "lemma": "voir", + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/glossaries/listTermsOrderByIdDesc.json b/src/test/resources/api/glossaries/listTermsOrderByIdDesc.json new file mode 100644 index 000000000..7ed0cb3b5 --- /dev/null +++ b/src/test/resources/api/glossaries/listTermsOrderByIdDesc.json @@ -0,0 +1,48 @@ +{ + "data": [ + { + "data": { + "id": 3, + "userId": 6, + "glossaryId": 6, + "languageId": "fr", + "text": "Voir", + "description": "use for pages only (check screenshots)", + "partOfSpeech": "verb", + "status": "preferred", + "type": "abbreviation", + "gender": "masculine", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "conceptId": 6, + "lemma": "voir", + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + }, + { + "data": { + "id": 2, + "userId": 6, + "glossaryId": 6, + "languageId": "fr", + "text": "Voir", + "description": "use for pages only (check screenshots)", + "partOfSpeech": "verb", + "status": "preferred", + "type": "abbreviation", + "gender": "masculine", + "note": "Any kind of note, such as a usage note, explanation, or instruction", + "url": "Base URL", + "conceptId": 6, + "lemma": "voir", + "createdAt": "2019-09-23T07:19:47+00:00", + "updatedAt": "2019-09-23T07:19:47+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/screenshots/listScreenshotsOrderByIdAsc.json b/src/test/resources/api/screenshots/listScreenshotsOrderByIdAsc.json new file mode 100644 index 000000000..3dca6e033 --- /dev/null +++ b/src/test/resources/api/screenshots/listScreenshotsOrderByIdAsc.json @@ -0,0 +1,78 @@ +{ + "data": [ + { + "data": { + "id": 2, + "userId": 6, + "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", + "name": "translate_with_siri.jpg", + "size": { + "width": 267, + "height": 176 + }, + "tagsCount": 1, + "tags": [ + { + "id": 98, + "screenshotId": 2, + "stringId": 2822, + "position": { + "x": 474, + "y": 147, + "width": 490, + "height": 99 + }, + "createdAt": "2019-09-23T09:35:31+00:00" + } + ], + "labels": [ + 1 + ], + "labelIds": [ + 1 + ], + "createdAt": "2019-09-23T09:29:19+00:00", + "updatedAt": "2019-09-23T09:29:19+00:00" + } + }, + { + "data": { + "id": 3, + "userId": 6, + "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", + "name": "translate_with_siri.jpg", + "size": { + "width": 267, + "height": 176 + }, + "tagsCount": 1, + "tags": [ + { + "id": 98, + "screenshotId": 2, + "stringId": 2822, + "position": { + "x": 474, + "y": 147, + "width": 490, + "height": 99 + }, + "createdAt": "2019-09-23T09:35:31+00:00" + } + ], + "labels": [ + 1 + ], + "labelIds": [ + 1 + ], + "createdAt": "2019-09-23T09:29:19+00:00", + "updatedAt": "2019-09-23T09:29:19+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/screenshots/listScreenshotsOrderByIdDesc.json b/src/test/resources/api/screenshots/listScreenshotsOrderByIdDesc.json new file mode 100644 index 000000000..933bdfb50 --- /dev/null +++ b/src/test/resources/api/screenshots/listScreenshotsOrderByIdDesc.json @@ -0,0 +1,78 @@ +{ + "data": [ + { + "data": { + "id": 3, + "userId": 6, + "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", + "name": "translate_with_siri.jpg", + "size": { + "width": 267, + "height": 176 + }, + "tagsCount": 1, + "tags": [ + { + "id": 98, + "screenshotId": 2, + "stringId": 2822, + "position": { + "x": 474, + "y": 147, + "width": 490, + "height": 99 + }, + "createdAt": "2019-09-23T09:35:31+00:00" + } + ], + "labels": [ + 1 + ], + "labelIds": [ + 1 + ], + "createdAt": "2019-09-23T09:29:19+00:00", + "updatedAt": "2019-09-23T09:29:19+00:00" + } + }, + { + "data": { + "id": 2, + "userId": 6, + "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", + "name": "translate_with_siri.jpg", + "size": { + "width": 267, + "height": 176 + }, + "tagsCount": 1, + "tags": [ + { + "id": 98, + "screenshotId": 2, + "stringId": 2822, + "position": { + "x": 474, + "y": 147, + "width": 490, + "height": 99 + }, + "createdAt": "2019-09-23T09:35:31+00:00" + } + ], + "labels": [ + 1 + ], + "labelIds": [ + 1 + ], + "createdAt": "2019-09-23T09:29:19+00:00", + "updatedAt": "2019-09-23T09:29:19+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/stringtranslations/listApprovalsOrderByIdAsc.json b/src/test/resources/api/stringtranslations/listApprovalsOrderByIdAsc.json new file mode 100644 index 000000000..7f98ba946 --- /dev/null +++ b/src/test/resources/api/stringtranslations/listApprovalsOrderByIdAsc.json @@ -0,0 +1,38 @@ +{ + "data": [ + { + "data": { + "id": 190695, + "user": { + "id": 19, + "login": "john_doe" + }, + "translationId": 200, + "fileId": 667, + "stringId": 2345, + "languageId": "uk", + "workflowStepId": 122, + "createdAt": "2019-09-19T12:42:12+00:00" + } + }, + { + "data": { + "id": 190696, + "user": { + "id": 19, + "login": "john_doe" + }, + "translationId": 200, + "fileId": 667, + "stringId": 2345, + "languageId": "uk", + "workflowStepId": 122, + "createdAt": "2019-09-19T12:42:12+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/stringtranslations/listApprovalsOrderByIdDesc.json b/src/test/resources/api/stringtranslations/listApprovalsOrderByIdDesc.json new file mode 100644 index 000000000..39406915b --- /dev/null +++ b/src/test/resources/api/stringtranslations/listApprovalsOrderByIdDesc.json @@ -0,0 +1,38 @@ +{ + "data": [ + { + "data": { + "id": 190696, + "user": { + "id": 19, + "login": "john_doe" + }, + "translationId": 200, + "fileId": 667, + "stringId": 2345, + "languageId": "uk", + "workflowStepId": 122, + "createdAt": "2019-09-19T12:42:12+00:00" + } + }, + { + "data": { + "id": 190695, + "user": { + "id": 19, + "login": "john_doe" + }, + "translationId": 200, + "fileId": 667, + "stringId": 2345, + "languageId": "uk", + "workflowStepId": 122, + "createdAt": "2019-09-19T12:42:12+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdAsc.json b/src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdAsc.json new file mode 100644 index 000000000..27bb9ffa6 --- /dev/null +++ b/src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdAsc.json @@ -0,0 +1,38 @@ +{ + "data": [ + { + "data": { + "stringId": 35434, + "contentType": "text/plain", + "translationId": 190694, + "text": "Цю стрічку перекладено", + "user": { + "id": 19, + "username": "john_doe", + "fullName": "John Smith", + "avatarUrl": "" + }, + "createdAt": "2019-09-23T11:26:54+00:00" + } + }, + { + "data": { + "stringId": 35435, + "contentType": "text/plain", + "translationId": 190694, + "text": "Цю стрічку перекладено", + "user": { + "id": 19, + "username": "john_doe", + "fullName": "John Smith", + "avatarUrl": "" + }, + "createdAt": "2019-09-23T11:26:54+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdDesc.json b/src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdDesc.json new file mode 100644 index 000000000..10d297d2c --- /dev/null +++ b/src/test/resources/api/stringtranslations/listLanguageTranslations_plain_orderByIdDesc.json @@ -0,0 +1,38 @@ +{ + "data": [ + { + "data": { + "stringId": 35435, + "contentType": "text/plain", + "translationId": 190694, + "text": "Цю стрічку перекладено", + "user": { + "id": 19, + "username": "john_doe", + "fullName": "John Smith", + "avatarUrl": "" + }, + "createdAt": "2019-09-23T11:26:54+00:00" + } + }, + { + "data": { + "stringId": 35434, + "contentType": "text/plain", + "translationId": 190694, + "text": "Цю стрічку перекладено", + "user": { + "id": 19, + "username": "john_doe", + "fullName": "John Smith", + "avatarUrl": "" + }, + "createdAt": "2019-09-23T11:26:54+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} \ No newline at end of file diff --git a/src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdAsc.json b/src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdAsc.json new file mode 100644 index 000000000..21ac6f695 --- /dev/null +++ b/src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdAsc.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "data": { + "id": 190694, + "text": "Цю стрічку перекладено", + "pluralCategoryName": "few", + "user": { + "id": 19, + "login": "john_doe" + }, + "rating": 10, + "createdAt": "2019-09-23T11:26:54+00:00" + } + }, + { + "data": { + "id": 190695, + "text": "Цю стрічку перекладено", + "pluralCategoryName": "few", + "user": { + "id": 19, + "login": "john_doe" + }, + "rating": 10, + "createdAt": "2019-09-23T11:26:54+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} diff --git a/src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdDesc.json b/src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdDesc.json new file mode 100644 index 000000000..c571e12fd --- /dev/null +++ b/src/test/resources/api/stringtranslations/listStringTranslationsOrderByIdDesc.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "data": { + "id": 190695, + "text": "Цю стрічку перекладено", + "pluralCategoryName": "few", + "user": { + "id": 19, + "login": "john_doe" + }, + "rating": 10, + "createdAt": "2019-09-23T11:26:54+00:00" + } + }, + { + "data": { + "id": 190694, + "text": "Цю стрічку перекладено", + "pluralCategoryName": "few", + "user": { + "id": 19, + "login": "john_doe" + }, + "rating": 10, + "createdAt": "2019-09-23T11:26:54+00:00" + } + } + ], + "pagination": { + "offset": 0, + "limit": 25 + } +} From 23d2923e1275e150761c0770b19d166e6b72ff58 Mon Sep 17 00:00:00 2001 From: korzol <48809063+korzol@users.noreply.github.com> Date: Sat, 11 Oct 2025 13:11:02 +0300 Subject: [PATCH 7/9] wip: fourth part of orderBy implementation in list methods --- .../com/crowdin/client/labels/LabelsApi.java | 31 ++- .../com/crowdin/client/teams/TeamsApi.java | 61 ++++-- .../teams/model/ListGroupTeamsParams.java | 16 ++ .../TranslationMemoryApi.java | 54 ++++- .../com/crowdin/client/users/UsersApi.java | 96 ++++++++- .../users/model/ListGroupManagersParams.java | 12 ++ .../crowdin/client/labels/LabelsApiTest.java | 79 ++++++- .../TeamsApiListTeamsOrderByIdAscTest.java | 57 +++++ .../TeamsApiListTeamsOrderByIdDescTest.java | 49 +++++ .../crowdin/client/teams/TeamsApiTest.java | 113 ++++++++-- ...ationMemoryApiListTmsOrderByIdAscTest.java | 55 +++++ ...tionMemoryApiListTmsOrderByIdDescTest.java | 46 +++++ .../TranslationMemoryApiTest.java | 8 + .../TranslationMemorySegmentsApiTest.java | 76 ++++++- .../client/users/UsersApiOrderyIdAscTest.java | 67 ++++++ .../users/UsersApiOrderyIdDescTest.java | 52 +++++ .../crowdin/client/users/UsersApiTest.java | 194 +++++++++++++++++- .../api/labels/listLabelsOrderByIdAsc.json | 20 ++ .../api/labels/listLabelsOrderByIdDesc.json | 20 ++ .../api/teams/listGroupTeamsOrderByIdAsc.json | 32 +++ .../teams/listGroupTeamsOrderByIdDesc.json | 32 +++ .../api/teams/listTeamsOrderByIdAsc.json | 26 +++ .../api/teams/listTeamsOrderByIdDesc.json | 26 +++ .../listTmsOrderByIdAsc.json | 46 +++++ .../listTmsOrderByIdDesc.json | 46 +++++ .../listTmSegmentsResponseOrderByIdAsc.json | 42 ++++ .../listTmSegmentsResponseOrderByIdDesc.json | 42 ++++ .../users/listGroupManagersOrderByIdAsc.json | 62 ++++++ .../users/listGroupManagersOrderByIdDesc.json | 62 ++++++ ...tProjectMembersEnterpriseOrderByIdAsc.json | 68 ++++++ ...ProjectMembersEnterpriseOrderByIdDesc.json | 68 ++++++ .../users/listProjectMembersOrderByIdAsc.json | 28 +++ .../listProjectMembersOrderByIdDesc.json | 28 +++ .../api/users/listUsersOrderByIdAsc.json | 40 ++++ .../api/users/listUsersOrderByIdDesc.json | 40 ++++ 35 files changed, 1730 insertions(+), 64 deletions(-) create mode 100644 src/main/java/com/crowdin/client/teams/model/ListGroupTeamsParams.java create mode 100644 src/main/java/com/crowdin/client/users/model/ListGroupManagersParams.java create mode 100644 src/test/java/com/crowdin/client/teams/TeamsApiListTeamsOrderByIdAscTest.java create mode 100644 src/test/java/com/crowdin/client/teams/TeamsApiListTeamsOrderByIdDescTest.java create mode 100644 src/test/java/com/crowdin/client/translationmemory/TranslationMemoryApiListTmsOrderByIdAscTest.java create mode 100644 src/test/java/com/crowdin/client/translationmemory/TranslationMemoryApiListTmsOrderByIdDescTest.java create mode 100644 src/test/java/com/crowdin/client/users/UsersApiOrderyIdAscTest.java create mode 100644 src/test/java/com/crowdin/client/users/UsersApiOrderyIdDescTest.java create mode 100644 src/test/resources/api/labels/listLabelsOrderByIdAsc.json create mode 100644 src/test/resources/api/labels/listLabelsOrderByIdDesc.json create mode 100644 src/test/resources/api/teams/listGroupTeamsOrderByIdAsc.json create mode 100644 src/test/resources/api/teams/listGroupTeamsOrderByIdDesc.json create mode 100644 src/test/resources/api/teams/listTeamsOrderByIdAsc.json create mode 100644 src/test/resources/api/teams/listTeamsOrderByIdDesc.json create mode 100644 src/test/resources/api/translationmemory/listTmsOrderByIdAsc.json create mode 100644 src/test/resources/api/translationmemory/listTmsOrderByIdDesc.json create mode 100644 src/test/resources/api/translationmemory/segments/listTmSegmentsResponseOrderByIdAsc.json create mode 100644 src/test/resources/api/translationmemory/segments/listTmSegmentsResponseOrderByIdDesc.json create mode 100644 src/test/resources/api/users/listGroupManagersOrderByIdAsc.json create mode 100644 src/test/resources/api/users/listGroupManagersOrderByIdDesc.json create mode 100644 src/test/resources/api/users/listProjectMembersEnterpriseOrderByIdAsc.json create mode 100644 src/test/resources/api/users/listProjectMembersEnterpriseOrderByIdDesc.json create mode 100644 src/test/resources/api/users/listProjectMembersOrderByIdAsc.json create mode 100644 src/test/resources/api/users/listProjectMembersOrderByIdDesc.json create mode 100644 src/test/resources/api/users/listUsersOrderByIdAsc.json create mode 100644 src/test/resources/api/users/listUsersOrderByIdDesc.json diff --git a/src/main/java/com/crowdin/client/labels/LabelsApi.java b/src/main/java/com/crowdin/client/labels/LabelsApi.java index a9573a981..29543e486 100644 --- a/src/main/java/com/crowdin/client/labels/LabelsApi.java +++ b/src/main/java/com/crowdin/client/labels/LabelsApi.java @@ -4,12 +4,7 @@ import com.crowdin.client.core.http.HttpRequestConfig; import com.crowdin.client.core.http.exceptions.HttpBadRequestException; import com.crowdin.client.core.http.exceptions.HttpException; -import com.crowdin.client.core.model.BooleanInt; -import com.crowdin.client.core.model.ClientConfig; -import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.core.model.PatchRequest; -import com.crowdin.client.core.model.ResponseList; -import com.crowdin.client.core.model.ResponseObject; +import com.crowdin.client.core.model.*; import com.crowdin.client.labels.model.AddLabelRequest; import com.crowdin.client.labels.model.Label; import com.crowdin.client.labels.model.LabelResponseList; @@ -58,6 +53,30 @@ public ResponseList