Skip to content

Commit ec95968

Browse files
committed
fix linting issues
1 parent c83f90d commit ec95968

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/test/java/apimatic/core/type/pagination/OffsetPaginationTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ public void testValidStringOffset() {
330330
@Test
331331
public void testInvalidStringOffset() {
332332
PaginatedData<?, ?, ?, ?> paginatedData = mock(PaginatedData.class);
333+
Response response = mock(Response.class);
333334

334335
when(paginatedData.getRequestBuilder())
335336
.thenReturn(new HttpRequest.Builder().queryParam(
@@ -344,14 +345,15 @@ public void testInvalidStringOffset() {
344345
assertEquals(INVALID_OFFSET_STRING, v);
345346
return v;
346347
});
347-
PageWrapper<?, ?> pageWrapper = PageWrapper.create(mock(Response.class), null, null, offset);
348+
PageWrapper<?, ?> pageWrapper = PageWrapper.create(response, null, null, offset);
348349
assertTrue(pageWrapper.isOffsetPagination());
349350
assertEquals(INVALID_OFFSET_RESULT, pageWrapper.getOffsetInput());
350351
}
351352

352353
@Test
353354
public void testMissingOffset() {
354355
PaginatedData<?, ?, ?, ?> paginatedData = mock(PaginatedData.class);
356+
Response response = mock(Response.class);
355357

356358
when(paginatedData.getRequestBuilder()).thenReturn(new HttpRequest.Builder());
357359
when(paginatedData.getPageSize()).thenReturn(PAGE_SIZE);
@@ -360,7 +362,7 @@ public void testMissingOffset() {
360362

361363
Builder requestBuilder = offset.apply(paginatedData);
362364
assertNotNull(requestBuilder);
363-
PageWrapper<?, ?> pageWrapper = PageWrapper.create(mock(Response.class), null, null, offset);
365+
PageWrapper<?, ?> pageWrapper = PageWrapper.create(response, null, null, offset);
364366
assertTrue(pageWrapper.isOffsetPagination());
365367
assertEquals(INVALID_OFFSET_RESULT, pageWrapper.getOffsetInput());
366368
}

src/test/java/apimatic/core/type/pagination/PaginatedDataTest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void testInvalidPaginationWithNullItems() throws IOException {
101101
public void testInvalidPaginationWithNullPage() throws IOException {
102102
assertInvalidPaginatedData(null);
103103
}
104-
104+
105105
private void assertInvalidPaginatedData(String responseBody) throws IOException {
106106
Runnable call1 = () -> when(getResponse().getBody()).thenReturn(responseBody);
107107
PaginatedData<String, PageWrapper<String, RecordPage>,
@@ -161,8 +161,8 @@ public void testCursorPaginationData() throws IOException, CoreApiException {
161161
Runnable call3 = () -> when(getResponse().getBody()).thenReturn(
162162
"{\"data\":[]}");
163163

164-
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2, call3,
165-
new CursorPagination("$response.body#/page_info",
164+
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2,
165+
call3, new CursorPagination("$response.body#/page_info",
166166
"$request.path#/cursor")));
167167

168168
assertTrue(pages.get(0).isCursorPagination());
@@ -208,13 +208,13 @@ public void testOffsetPaginationData() throws IOException, CoreApiException {
208208
Runnable call3 = () -> when(getResponse().getBody()).thenReturn(
209209
"{\"data\":[]}");
210210

211-
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2, call3,
212-
new OffsetPagination("$request.headers#/offset")));
211+
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2,
212+
call3, new OffsetPagination("$request.headers#/offset")));
213213

214214
assertTrue(pages.get(0).isOffsetPagination());
215215
assertEquals(0, pages.get(0).getOffsetInput());
216216
assertTrue(pages.get(1).isOffsetPagination());
217-
assertEquals(3, pages.get(1).getOffsetInput());
217+
assertEquals(PAGE_SIZE, pages.get(1).getOffsetInput());
218218
}
219219

220220
@Test
@@ -246,8 +246,8 @@ public void testPagePaginationData() throws IOException, CoreApiException {
246246
Runnable call3 = () -> when(getResponse().getBody()).thenReturn(
247247
"{\"data\":[]}");
248248

249-
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2, call3,
250-
new PagePagination("$request.query#/page")));
249+
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2,
250+
call3, new PagePagination("$request.query#/page")));
251251

252252
assertTrue(pages.get(0).isNumberPagination());
253253
assertEquals(1, pages.get(0).getPageInput());
@@ -284,8 +284,8 @@ public void testMultiPaginationData() throws IOException, CoreApiException {
284284
Runnable call3 = () -> when(getResponse().getBody()).thenReturn(
285285
"{\"data\":[]}");
286286

287-
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2, call3,
288-
new LinkPagination("$response.INVALID#/next_link"),
287+
List<PageWrapper<String, RecordPage>> pages = verifyData(getPaginatedData(call1, call2,
288+
call3, new LinkPagination("$response.INVALID#/next_link"),
289289
new PagePagination("$request.body#/limit")));
290290

291291
assertTrue(pages.get(0).isLinkPagination());
@@ -384,7 +384,8 @@ public void testMultiPaginationDataAsync()
384384
assertEquals(0, paginatedData.getItems(itemCreator).size());
385385
}
386386

387-
private List<PageWrapper<String, RecordPage>> verifyData(PaginatedData<String, PageWrapper<String, RecordPage>,
387+
private List<PageWrapper<String, RecordPage>> verifyData(
388+
PaginatedData<String, PageWrapper<String, RecordPage>,
388389
RecordPage, CoreApiException> paginatedData) throws CoreApiException, IOException {
389390
Iterator<CheckedSupplier<String, CoreApiException>> itemIterator =
390391
paginatedData.items(cs -> cs);
@@ -407,7 +408,7 @@ private List<PageWrapper<String, RecordPage>> verifyData(PaginatedData<String, P
407408
assertEquals("No more items available.", exception.getMessage());
408409

409410
List<PageWrapper<String, RecordPage>> pages = new ArrayList<>();
410-
411+
411412
Iterator<CheckedSupplier<PageWrapper<String, RecordPage>, CoreApiException>> pagesIterator =
412413
paginatedData.pages(cs -> cs);
413414

@@ -437,7 +438,7 @@ private List<PageWrapper<String, RecordPage>> verifyData(PaginatedData<String, P
437438

438439
exception = assertThrows(NoSuchElementException.class, pagesIterator::next);
439440
assertEquals("No more pages available.", exception.getMessage());
440-
441+
441442
return pages;
442443
}
443444

0 commit comments

Comments
 (0)