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
package com.myapp.domain.CallResult | |
sealed class CallResult<out S, out F> { | |
data class Success<out S> internal constructor(val value: S) : CallResult<S, Nothing>() | |
data class Failure<out F> internal constructor(val failure: F) : CallResult<Nothing, F>() | |
inline fun <V> fold(onSuccess: (S) -> V, onFailure: (F) -> V): V = | |
when (this) { | |
is Success -> onSuccess(value) | |
is Failure -> onFailure(failure) |
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
package com.myapp.api.common.failure | |
import com.myapp.api.common.failure.differentpackage.ApiCall3Failure | |
// This Common errors type has to know all the other types to include it in, which isn't nice. They can't include it. | |
// Also, they all must be in the same module (not sooo bad) and PACKAGE (very restrictive), so this third one won't work | |
// as it's been put in another package. | |
sealed class Common() : ApiCall1Failure, ApiCall2Failure /*, ApiCall3Failure */ { | |
object NetworkFailure : Common() | |
object ServerFailure : Common() |
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
package test.framework.idlingresources | |
import androidx.test.espresso.IdlingResource | |
/** | |
* A shared interface for our wrappers around [kotlinx.coroutines.CoroutineDispatcher] and | |
* [kotlinx.coroutines.MainCoroutineDispatcher] that expose an [IdlingResource] for each of them. | |
*/ | |
interface DispatcherWithIdlingResource { | |
val idlingResource: IdlingResource |
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
package test.framework.idlingresources | |
import androidx.test.espresso.IdlingResource | |
import okhttp3.Dispatcher | |
/** | |
* An [IdlingResource] for OkHttp, roughly based on [https://github.com/JakeWharton/okhttp-idling-resource], but in Kotlin, | |
* and with a check to prevent experiencing this issue: ([https://github.com/JakeWharton/okhttp-idling-resource/issues/10]). | |
*/ | |
class OkHttpIdlingResource constructor(private val name: String, private val dispatcher: Dispatcher) : IdlingResource { |
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
/* | |
* Copyright (C) 2018 Square, Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
// For first example on Spek site: | |
// Define a field for the SUT on the spec class: | |
def calculator = new Calculator() | |
// then your Spock test body is just this: | |
expect: | |
calculator.sum(2, 4) == 6 |
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
Africa/Abidjan | |
Africa/Accra | |
Africa/Addis_Ababa | |
Africa/Algiers | |
Africa/Asmara | |
Africa/Asmera | |
Africa/Bamako | |
Africa/Bangui | |
Africa/Banjul | |
Africa/Bissau |