This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
forked from facebook/facebook-java-business-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re facebook#309 Fixed APINodeList requesting extra empty page at resu…
…lts end.
- Loading branch information
1 parent
2ed4e7a
commit a8b3d17
Showing
2 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.facebook.ads.sdk | ||
|
||
import io.mockk.Runs | ||
import io.mockk.every | ||
import io.mockk.just | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import org.junit.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
|
||
class ApiNodeListTest { | ||
|
||
@Test | ||
fun testNextPageWhenNextPageAvailable() { | ||
val request = mockk<APIRequest<Campaign>>() | ||
val nextPage = mockk<APINodeList<Campaign>>() | ||
every { request.setOverrideUrl("https://graph.facebook.api/NEXT") } just Runs | ||
every { request.execute() } returns(nextPage) | ||
val list = APINodeList<Campaign>(request, "raw value", "header") | ||
list.setPaging("https://graph.facebook.api/PREVIOUS", "https://graph.facebook.api/NEXT") | ||
list.setCursors("BEFORE_CURSOR", "AFTER_CURSOR") | ||
|
||
val result = list.nextPage() | ||
|
||
assertEquals(nextPage, result) | ||
verify { | ||
request.setOverrideUrl("https://graph.facebook.api/NEXT") | ||
} | ||
} | ||
|
||
@Test | ||
fun testNextPageWhenAlreadyOnLastPage() { | ||
val request = mockk<APIRequest<Campaign>>() | ||
val list = APINodeList<Campaign>(request, "raw value", "header") | ||
list.setPaging("https://graph.facebook.api/PREVIOUS", null) | ||
list.setCursors("BEFORE_CURSOR", "AFTER_CURSOR") | ||
|
||
val result = list.nextPage() | ||
|
||
assertNull(result) | ||
} | ||
|
||
} |