Skip to content

Commit 03f361e

Browse files
committed
UsersTest: document and assert quirky behavior of list item ordering
1 parent 712caf3 commit 03f361e

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

src/test/java/com/uwetrottmann/trakt5/services/UsersTest.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,19 @@ public void test_listItems() throws IOException {
236236
public void test_listItems_sortOrder() throws IOException {
237237
int page = 1;
238238
int limit = 1000;
239-
String sortBy = "title";
240-
String sortHow = "asc";
239+
String sortBy = "added";
240+
String sortHow = "desc";
241241
Response<List<ListEntry>> response = executeCallWithoutReadingBody(
242242
getTrakt().users().listItems(UserSlug.ME,
243243
String.valueOf(TEST_LIST_WITH_ITEMS_TRAKT_ID),
244244
sortBy, sortHow, page, limit, null));
245245

246246
assertPaginationHeaders(response, page, limit);
247-
assertSortOrderHeaders(response, sortBy, sortHow);
247+
// The list items are ordered as requested, but no X-Applied headers are returned, instead the X-Sort headers
248+
// update with nonsensical values.
249+
// assertSortOrderHeaders(response, sortBy, sortHow);
250+
assertThat(response.headers().get("x-sort-by")).isEqualTo("desc");
251+
assertThat(response.headers().get("x-sort-how")).isEqualTo("asc");
248252
assertListEntries(response.body());
249253
}
250254

@@ -260,12 +264,23 @@ public void test_listItems_type() throws IOException {
260264

261265
@Test
262266
public void test_listItems_typeAndsortOrder() throws IOException {
263-
List<ListEntry> entries = executeCall(
267+
int page = 1;
268+
int limit = 1000;
269+
String sortBy = "title";
270+
String sortHow = "desc";
271+
Response<List<ListEntry>> response = executeCallWithoutReadingBody(
264272
getTrakt().users().listItems(UserSlug.ME,
265273
String.valueOf(TEST_LIST_WITH_ITEMS_TRAKT_ID),
266-
"movie,show", "title", "asc", 1, 1000, null)
274+
"movie,show", sortBy, sortHow, page, limit, null)
267275
);
268-
assertListEntries(entries);
276+
277+
assertPaginationHeaders(response, page, limit);
278+
// The list items are ordered as requested, but no X-Applied headers are returned, instead the X-Sort headers
279+
// update to the requested by and how values.
280+
// assertSortOrderHeaders(response, sortBy, sortHow);
281+
assertThat(response.headers().get("x-sort-by")).isEqualTo(sortBy);
282+
assertThat(response.headers().get("x-sort-how")).isEqualTo(sortHow);
283+
assertListEntries(response.body());
269284
}
270285

271286
private static void assertListEntries(List<ListEntry> entries) {

0 commit comments

Comments
 (0)