Skip to content

Commit

Permalink
Update mock web server and fix demo app (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
DevPabloGarcia authored Jun 14, 2024
1 parent 4d0c817 commit 3c26f86
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 87 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/telefonica/mocks/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class App : Application() {

if (BuildConfig.DEFAULT_ENVIRONMENT == Environment.DEMO) {
super.onCreate()
mockHelper.setUp(enableSsl = true)
getUserMocksUseCase()
CoroutineScope(Dispatchers.IO).launch {
mockHelper.setUp(enableSsl = true)
getUserMocksUseCase()
initBackendUrl()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package com.telefonica.mocks.domain.mock

import com.squareup.moshi.Moshi
import com.telefonica.mock.Method
import com.telefonica.mock.MockedApiResponse
import com.telefonica.mock.MockHelper
import com.telefonica.mocks.model.user.NameDto
import com.telefonica.mocks.model.user.UserDto
import com.telefonica.mocks.model.user.UserWrapperDto
import javax.inject.Inject

open class GetUserMocksUseCase @Inject constructor(
Expand All @@ -15,85 +9,9 @@ open class GetUserMocksUseCase @Inject constructor(

operator fun invoke() {
mockHelper.enqueue {
whenever("/image.png").thenReturnFromRawFile("demo_image")
whenever("/?results=5").thenReturnFromFile("user_list_success_1.json")
whenever(".*/?results=5").thenReturnFromFile("user_list_success_1.json")
whenever(".*/?results=10").thenReturnFromFile("user_list_success_2.json")
}
}

companion object {
val DEMO_LIST = UserWrapperDto(
results = listOf(
UserDto(
name = NameDto(
title = "Sr", first = "Pablo", last = "Garcia"
),
email = "Pablogarcia@telefonica.com",
phone = "611 11 11 11"
),
UserDto(
name = NameDto(
title = "Sr", first = "David", last = "Santiago"
),
email = "Davidsantiago@telefonica.com",
phone = "611 11 11 12"
),
UserDto(
name = NameDto(
title = "Sr", first = "David", last = "Pastor"
),
email = "Davidpastor@telefonica.com",
phone = "611 11 11 13"
),
UserDto(
name = NameDto(
title = "Sr", first = "Pablo", last = "Martin"
),
email = "Pablomartin@telefonica.com",
phone = "611 11 11 14"
),
UserDto(
name = NameDto(
title = "Sr", first = "Yamal", last = "Al-Mahamid"
),
email = "Yamalalmahamid@telefonica.com",
phone = "611 11 11 15"
),
UserDto(
name = NameDto(
title = "Sr", first = "David", last = "Gonzalez"
),
email = "Davidgonzalez@telefonica.com",
phone = "611 11 11 16"
),
UserDto(
name = NameDto(
title = "Sr", first = "Jesus", last = "Latorre"
),
email = "Jesuslatorre@telefonica.com",
phone = "611 11 11 17"
),
UserDto(
name = NameDto(
title = "Sr", first = "Guillermo", last = "Merino"
),
email = "Guillermomerino@telefonica.com",
phone = "611 11 11 18"
),
UserDto(
name = NameDto(
title = "Sr", first = "Manolo", last = "Vera"
),
email = "Manolovera@gmail.com",
phone = "611 11 11 19"
),
UserDto(
name = NameDto(
title = "Sr", first = "Javier", last = "Delgado"
),
email = "Javierdelgado@gmail.com",
phone = "611 11 11 10"
),
),
)
}
}
2 changes: 1 addition & 1 deletion mock/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {

dependencies {

implementation "com.squareup.okhttp3:mockwebserver:4.9.3"
implementation "com.squareup.okhttp3:mockwebserver:4.12.0"
implementation "com.squareup.okhttp3:okhttp-tls:4.9.3"

implementation "com.google.dagger:dagger:2.46.1"
Expand Down

0 comments on commit 3c26f86

Please sign in to comment.