This file contains hidden or 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
| class GreetingServiceFakeTest { | |
| @Inject | |
| lateinit var greetingService: GreetingService | |
| @Test | |
| fun testGreetingInTheMorning() { | |
| val testModule = module { | |
| bind<TimeService>().toInstance(object : TimeService { |
This file contains hidden or 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
| @RunWith(RobolectricTestRunner::class) | |
| @Config(sdk = [Build.VERSION_CODES.P]) | |
| class GreetingServiceRoboTest { | |
| @get:Rule | |
| val mockitoRule: MockitoRule = MockitoJUnit.rule() | |
| @Mock | |
| lateinit var timeService: TimeService |
This file contains hidden or 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
| class MessageData @Inject constructor(val welcomeMessage: String) |
This file contains hidden or 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
| val builder = Retrofit.Builder() | |
| .client(getClient(serviceClass)) | |
| .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | |
| .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) | |
| .addConverterFactory(GuavaOptionalConverterFactory.create()) | |
| .addConverterFactory(GsonConverterFactory.create(gson)) | |
| .baseUrl(endpointAdapter.getURLString(context, serviceClass.simpleName)) | |
| .addConverterFactory(Json.asConverterFactory(MediaType.get("application/json"))) |
This file contains hidden or 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
| import kotlinx.serialization.Serializable | |
| @Serializable | |
| class GeofencingResponse(val id: String, val accessCode: String, val nickname: String?) |
This file contains hidden or 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
| interface GeoFenceService { | |
| /** | |
| * Return a list of [GeofencingResponse] awaiting for collection by given dpid | |
| */ | |
| @GET("geofencing/v1/articles/{dpid}") | |
| fun getGeoFenceArticles(@Path("dpid") dpid: String): Single<List<GeofencingResponse>> | |
| } |
This file contains hidden or 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
| fun getOnboardingInfoAndSmartMessage() { | |
| viewModelScope.launch { | |
| try { | |
| withTimeout(2500) { | |
| onBoardingData.loadWith(this) { | |
| onBoardDispatchManager.getOnboardingInfoAndSmartMessage() | |
| } | |
| } | |
| } catch (error: TimeoutCancellationException) { | |
| onBoardingData.postError(error) |
This file contains hidden or 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
| private fun loadAppConfig() { | |
| appConfigManager.getAppConfig(pushNotificationManager.deviceId) | |
| .prodTimeout(2500, TimeUnit.MILLISECONDS) | |
| .subscribeOn(Schedulers.io()) | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .`as`(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(lifecycle, Lifecycle.Event.ON_DESTROY))) | |
| .subscribe({ appConfig -> processAppConfig(appConfig) }, | |
| { throwable -> Timber.e(throwable) }) | |
| } |
This file contains hidden or 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
| fun <T> Observable<T>.prodTimeout(timeout: Long, timeUnit: TimeUnit): Observable<T> { | |
| return if (BuildConfig.BUILD_TYPE == "debug" || timeout == 0L) { | |
| this | |
| } else { | |
| this.timeout(timeout, timeUnit) | |
| } | |
| } |
This file contains hidden or 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
| class JsonParser { | |
| val json = Json { ignoreUnknownKeys = true; isLenient = true; } | |
| } |