jw
11/12/2020, 2:30 AMjw
11/12/2020, 2:30 AMjw
11/12/2020, 2:31 AMchris-horner
11/12/2020, 3:18 AMForwardingSink
private class UnclosingSink(output: OutputStream) : ForwardingSink(output.sink()) {
override fun close() {
delegate.flush()
}
}
fun getEncryptedSink(output: OutputStream): Sink {
val cipher = getEncryptionCipher()
return UnclosingSink(output).buffer()
.writeInt(cipher.iv.size)
.write(cipher.iv)
.cipherSink(cipher)
}
Manuel Lorenzo
11/17/2020, 4:11 PMManuel Lorenzo
11/17/2020, 4:11 PMtestImplementation
but I’m getting java.lang.NoSuchMethodError: app.cash.turbine.FlowTurbineKt.test-f_gJSvk$default(Lkotlinx/coroutines/flow/Flow;DLkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
jw
11/17/2020, 4:21 PMManuel Lorenzo
11/17/2020, 4:22 PMManuel Lorenzo
11/17/2020, 4:37 PMManuel Lorenzo
11/17/2020, 4:57 PMkotlin("android") version "1.4.0" apply false
Manuel Lorenzo
11/17/2020, 4:58 PMapply false
or set it to true, I get
* Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not resolve all files for configuration ':app:coreLibraryDesugaring'.
Cannot resolve external dependency com.android.tools:desugar_jdk_libs:1.1.0 because no repositories are defined.
Vailo Tok
11/18/2020, 1:22 AMwellingtoncosta
11/18/2020, 6:15 PMjava.lang.AbstractMethodError: kotlinx.coroutines.test.TestCoroutineDispatcher.invokeOnTimeout(JLjava/lang/Runnable;Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/DisposableHandle;
Here's my test code:
class MyViewModelTest {
private lateinit var viewModel: MyViewModel
@get:Rule
var mainCoroutineRule = MainCoroutineRule()
@Test
fun `should test successfully`() {
mainCoroutineRule.testDispatcher.runBlockingTest {
// ...
viewModel.states.test {
assertEquals(State.Ok, expectItem())
expectComplete()
}
}
}
}
jw
11/18/2020, 7:19 PMwellingtoncosta
11/18/2020, 7:40 PMkotlinx-coroutines-core:1.4.0
and kotlinx-coroutines-test:1.3.8
). I bumped kotlinx-coroutines-test
to 1.4.0
, and now I'm getting the following error:
kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 1000 ms
wellingtoncosta
11/18/2020, 7:54 PMkotlinx.coroutines.TimeoutCancellationException
was threw because I called expectComplete()
, but my StateFlow isn't yet closed. Never mind about that. Thanks for helping me.Cyril Find
11/20/2020, 11:09 AMinternal
?jw
11/20/2020, 12:44 PMCyril Find
11/20/2020, 1:53 PMdavid.bilik
11/21/2020, 5:19 PM{
"status": "OK",
"data": { //my data }
}
but in the case of errors the response is still http status code 200 but body looks like
{
"status": "Error",
"description": "Invalid email address",
"error_code": 0,
"data": []
}
I have a generic class ApiResponse<T>
looking like
class ApiResponse<T>(
val data: T?,
val status: String?,
@Json(name = "error_code") val errorCode: Int?,
@JvmField val description: String? = null
)
and I am parsing it through Moshi through function similar to
fun <T> parseResponse(moshi: Moshi, body:String, type: Class<T>) : ApiResponse<T> {
val apiResponseType = Types.newParameterizedType(ApiResponse::class.java, type)
val toReturn = moshi.adapter<ApiResponse<T>>(apiResponseType).fromJson(body)
if (toReturn.errorCode != null) {
throw ApiResponseErrorException(toReturn.errorCode, toReturn.description ?: "")
}
return toReturn
}
which works fine in most of the cases but the problem is that the field data
is returned as empty array in the case of error, which results in failing JSON parsing if the type of ApiResponse
is not an list.. My first thought was to create a custom adapter for ApiResponse
class and in the case of status == "Error"
i would not parse the data at all and just return the exception but i don’t know how to write such an adapter because I don’t have information about the generic type of data
in the happy scenarios. What is the best way to deal with that without ugly try/catches?Colton Idle
11/21/2020, 5:53 PMMaurice Jouvet
11/23/2020, 3:01 PMalec
11/23/2020, 3:01 PMMaurice Jouvet
11/23/2020, 3:02 PMalec
11/23/2020, 3:02 PMalec
11/23/2020, 3:02 PMMaurice Jouvet
11/23/2020, 3:03 PMMaurice Jouvet
11/23/2020, 3:31 PMalec
11/23/2020, 3:52 PMtvtan
11/27/2020, 10:26 AMmultiplatform
module using wire 3.5.1-SNAPSHOT
(also with 3.6.0-SNAPSHOT) but get this error:
Unresolved reference: ByteStringSerializer
my build.gradle.kts:
import dependencies.Dependencies
import dependencies.TestDependencies
plugins {
id(BuildPlugins.KOTLIN_MULTIPLATFORM)
id(BuildPlugins.KOTLIN_PLUGIN_SERIALIZATION)
id(BuildPlugins.WIRE)
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
}
ios {
binaries {
framework {
baseName = "domain"
}
}
}
sourceSets {
val commonMain by getting {
kotlin.srcDir("$buildDir/generated/source/wire")
dependencies {
api(Dependencies.Domain.KOTLIN_SERIALIZATION)
api(Dependencies.Domain.WIRE)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
val iosMain by getting
val iosTest by getting
}
}
wire {
sourcePath {
srcDir("src/commonMain/proto")
}
kotlin {
emitKotlinSerialization = "UNSUPPORTED"
}
}
In the IDEA, it shows the generated source set as iosArm64Main
and gradle dependencies contains only wire-runtime for ios targets: