-
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.
feat[mock]: mock updated for photo details service
- Loading branch information
1 parent
8bcda3e
commit 3f4edf8
Showing
7 changed files
with
2,460 additions
and
6 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...n/java/com/saiful/mock/mappers/MockApi.kt → .../src/main/java/com/saiful/mock/MockApi.kt
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.saiful.mock.mappers | ||
package com.saiful.mock | ||
|
||
import okhttp3.mockwebserver.RecordedRequest | ||
|
||
|
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 |
---|---|---|
@@ -1,20 +1,26 @@ | ||
package com.saiful.mock.mappers | ||
|
||
import com.saiful.mock.MockApi | ||
|
||
object PhotoMockApi { | ||
|
||
private val PHOTOS = Regex("^photos\\?page=\\d+&per_page=\\d+\$") | ||
private val PHOTO_DETAILS = Regex("^photos/[^/]+\$") | ||
|
||
fun getMap(): Map<Regex, MockApi> = mapOf( | ||
PHOTOS to MockApi( | ||
path = "photos", | ||
findPath = { recordedRequest -> | ||
val regex = """page=(\d+)""".toRegex() | ||
when (regex.find(recordedRequest.path.toString())?.groupValues?.get(1) ?: "") { | ||
"1" -> "photos/one" | ||
"2" -> "photos/two" | ||
else -> "photos" | ||
"1" -> "photos/list/one" | ||
"2" -> "photos/list/two" | ||
else -> "photos/list" | ||
} | ||
} | ||
), | ||
PHOTO_DETAILS to MockApi( | ||
path = "photos/details" | ||
) | ||
) | ||
} |
Oops, something went wrong.