11package com .crowdin .client .stringcomments ;
22
3- import com .crowdin .client .core .model .PatchOperation ;
4- import com .crowdin .client .core .model .PatchRequest ;
5- import com .crowdin .client .core .model .ResponseList ;
6- import com .crowdin .client .core .model .ResponseObject ;
3+ import com .crowdin .client .core .model .*;
74import com .crowdin .client .framework .RequestMock ;
85import com .crowdin .client .framework .TestClient ;
96import com .crowdin .client .stringcomments .model .AddStringCommentRequest ;
1613import org .apache .http .client .methods .HttpPost ;
1714import org .junit .jupiter .api .Test ;
1815
19- import java .util .ArrayList ;
20- import java .util .Arrays ;
21- import java .util .List ;
16+ import java .util .*;
2217
2318import static org .junit .jupiter .api .Assertions .assertEquals ;
2419import static org .junit .jupiter .api .Assertions .assertNotNull ;
2520
2621public class StringCommentsApiTest extends TestClient {
2722
2823 private final Long projectId = 8L ;
24+ private final Long project2Id = 9L ;
25+ private final Long project3Id = 10L ;
2926 private final Long stringId = 64L ;
3027 private final Long stringCommentId = 512L ;
3128
@@ -41,6 +38,14 @@ public List<RequestMock> getMocks() {
4138 return Arrays .asList (
4239 RequestMock .build (String .format ("%s/projects/%d/comments" , this .url , projectId ), HttpGet .METHOD_NAME ,
4340 "api/stringcomments/listStringCommentsResponse.json" ),
41+ RequestMock .build (String .format ("%s/projects/%d/comments" , this .url , project2Id ), HttpGet .METHOD_NAME ,
42+ "api/stringcomments/listStringCommentsResponseOrderByIdAsc.json" , new HashMap <String , String >() {{
43+ put ("orderBy" , "id%20asc" );
44+ }}),
45+ RequestMock .build (String .format ("%s/projects/%d/comments" , this .url , project3Id ), HttpGet .METHOD_NAME ,
46+ "api/stringcomments/listStringCommentsResponseOrderByIdDesc.json" , new HashMap <String , String >(){{
47+ put ("orderBy" , "id%20desc" );
48+ }}),
4449 RequestMock .build (String .format ("%s/projects/%d/comments" , this .url , projectId ), HttpPost .METHOD_NAME ,
4550 "api/stringcomments/addStringCommentRequest.json" , "api/stringcomments/stringCommentResponse.json" ),
4651 RequestMock .build (String .format ("%s/projects/%d/comments/%d" , this .url , projectId , stringCommentId ), HttpGet .METHOD_NAME ,
@@ -65,6 +70,94 @@ public void listStringCommentsTest() {
6570 assertEquals (1 , responseList .getData ().size (), "Size of list should be 1" );
6671 }
6772
73+ @ Test
74+ public void listStringCommentsTest_orderByNull () {
75+ ResponseList <StringComment > responseList = this .getStringCommentsApi ().listStringComments (
76+ projectId ,
77+ null ,
78+ null ,
79+ null ,
80+ null ,
81+ null ,
82+ null ,
83+ null
84+ );
85+ assertNotNull (responseList );
86+ assertNotNull (responseList .getData ());
87+ assertEquals (1 , responseList .getData ().size (), "Size of list should be 1" );
88+ }
89+
90+ @ Test
91+ public void listStringCommentsTest_orderByIdNull () {
92+ OrderByField orderById = new OrderByField ();
93+ orderById .setFieldName ("id" );
94+
95+ ResponseList <StringComment > responseList = this .getStringCommentsApi ().listStringComments (
96+ project2Id ,
97+ null ,
98+ null ,
99+ null ,
100+ null ,
101+ null ,
102+ null ,
103+ Collections .singletonList (orderById )
104+ );
105+ assertNotNull (responseList );
106+ assertNotNull (responseList .getData ());
107+ assertEquals (2 , responseList .getData ().size (), "Size of list should be 1" );
108+
109+ assertEquals (2 , responseList .getData ().get (0 ).getData ().getId (), "Id of list should be 2" );
110+ assertEquals (3 , responseList .getData ().get (1 ).getData ().getId (), "Id of list should be 3" );
111+ }
112+
113+ @ Test
114+ public void listStringCommentsTest_orderByIdAsc () {
115+ OrderByField orderById = new OrderByField ();
116+ orderById .setFieldName ("id" );
117+ orderById .setOrderBy (SortOrder .ASC );
118+
119+ ResponseList <StringComment > responseList = this .getStringCommentsApi ().listStringComments (
120+ project2Id ,
121+ null ,
122+ null ,
123+ null ,
124+ null ,
125+ null ,
126+ null ,
127+ Collections .singletonList (orderById )
128+ );
129+ assertNotNull (responseList );
130+ assertNotNull (responseList .getData ());
131+ assertEquals (2 , responseList .getData ().size (), "Size of list should be 1" );
132+
133+ assertEquals (2 , responseList .getData ().get (0 ).getData ().getId (), "Id of list should be 2" );
134+ assertEquals (3 , responseList .getData ().get (1 ).getData ().getId (), "Id of list should be 3" );
135+ }
136+
137+ @ Test
138+ public void listStringCommentsTest_orderByIdDesc () {
139+ OrderByField orderById = new OrderByField ();
140+ orderById .setFieldName ("id" );
141+ orderById .setOrderBy (SortOrder .DESC );
142+
143+ ResponseList <StringComment > responseList = this .getStringCommentsApi ().listStringComments (
144+ project3Id ,
145+ null ,
146+ null ,
147+ null ,
148+ null ,
149+ null ,
150+ null ,
151+ Collections .singletonList (orderById )
152+ );
153+ assertNotNull (responseList );
154+ assertNotNull (responseList .getData ());
155+ assertEquals (2 , responseList .getData ().size (), "Size of list should be 1" );
156+
157+ assertEquals (3 , responseList .getData ().get (0 ).getData ().getId (), "Id of list should be 3" );
158+ assertEquals (2 , responseList .getData ().get (1 ).getData ().getId (), "Id of list should be 2" );
159+ }
160+
68161 @ Test
69162 public void addStringCommentTest () {
70163 AddStringCommentRequest request = new AddStringCommentRequest () {{
0 commit comments