https://kotlinlang.org
Join Slack
Does anyone here have any experience mocking an extension function and capturing the lambda paramete...
j

Justin (Midas) Gilman

almost 4 years ago
Does anyone here have any experience mocking an extension function and capturing the lambda parameter? I am using Mockk and I'm getting this error
java.lang.AbstractMethodError: Receiver class kotlin.jvm.functions.Function1$Subclass0 does not define or inherit an implementation of the resolved method 'abstract java.lang.Object invoke(java.lang.Object)' of interface kotlin.jvm.functions.Function1.
Here's my test:
@Test
    fun `attempt 2`() {
        val routing = mockk<Routing>(relaxed = true)

        val configure = slot<Route.() -> Unit>()
        val mockedRoute = mockk<Route>()

        every { any<Route>().static(capture(configure)) } answers {
            configure.captured.invoke(mockedRoute)
            mockedRoute
        }

        var testObj = ResourcePortalModuleRouter(routing, node)
        testObj.attachPortalCoreRoutes()

        verify {
            mockedRoute.default("index")
        }
    }
The error is thrown on the
every
line, and I don't understand why this isn't working
j
t
+2
  • 4
  • 4
  • 709
Hello! I am looking for some cache library developed in Kotlin Any suggestions?
t

Tiago Brito

about 5 years ago
Hello! I am looking for some cache library developed in Kotlin Any suggestions?
t
e
+5
  • 7
  • 11
  • 708
I'm trying to use bouncycastle for kotlin. I kinda feel like an idiot because i can't find what depe...
c

Colton Idle

over 1 year ago
I'm trying to use bouncycastle for kotlin. I kinda feel like an idiot because i can't find what dependency i should drop into my build.gradle. lol. just me? https://github.com/bcgit/bc-kotlin
c
e
s
  • 3
  • 9
  • 706
How do I send json in form data from the ktor client and receive it on a ktor server? I need multipl...
d

dave08

over 2 years ago
How do I send json in form data from the ktor client and receive it on a ktor server? I need multiple keys (json and json2) with json data in them in the same request.
d
b
a
  • 3
  • 11
  • 706
So i'm using a ModalBottomSheetLayout inside an LazyColumn. The Modalsheet comes up on the button cl...
d

Deepak Gahlot

over 4 years ago
So i'm using a ModalBottomSheetLayout inside an LazyColumn. The Modalsheet comes up on the button click which is one of the item of the LazyColumn. And i'm getting this error
java.lang.IllegalStateException: Nesting scrollable in the same direction layouts like ScrollableContainer and LazyColumn is not allowed.
d
a
+2
  • 4
  • 15
  • 705
What are the main advantages of Kodein over Koin in context of multiplatform project? What made you ...
e

electrolobzik

over 1 year ago
What are the main advantages of Kodein over Koin in context of multiplatform project? What made you choose it over Koin?
e
r
+2
  • 4
  • 36
  • 704
I’ d like load drawable shape and have same error. `java.lang.IllegalArgumentException: Only Vec...
a

Android75

over 3 years ago
I’ d like load drawable shape and have same error.
java.lang.IllegalArgumentException: Only VectorDrawables and rasterized asset types are supported ex. PNG, JPG
this is shape.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="<http://schemas.android.com/apk/res/android>" android:shape="oval">
    <solid android:color="#F44336"/>

</shape>
and code.
Image(
    imageVector =   ImageVector.vectorResource(
        id = R.drawable.ball
    ),
    contentDescription = null
)
a
a
c
  • 3
  • 7
  • 704
Anyone aware of way to create custom deserialization of some "map type" json in to a list (more in t...
j

John O'Reilly

over 3 years ago
Anyone aware of way to create custom deserialization of some "map type" json in to a list (more in thread)....
j
d
+2
  • 4
  • 33
  • 704
hello :wave: has anyone tried `value class` with jackson? ```fun main() { val string = ObjectMap...
t

thanksforallthefish

over 3 years ago
hello 👋 has anyone tried
value class
with jackson?
fun main() {
  val string = ObjectMapper().findAndRegisterModules()
    .convertValue<Map<String, String>>(Value("any"))

  println(string)
}

@JvmInline
value class Value(val value: String)
prints
{value=any}
with jackson 2.12.5, but fails with jackson 2.13.0. error is
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('any')
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
though https://github.com/FasterXML/jackson-module-kotlin/issues/464 makes me wonder if my expectation is wrong. my use case is the one marked as “broken”:
"broken": [ {"value":0}, {"value":0} ]
, though this is exactly what I want
t
w
  • 2
  • 1
  • 704
How can I clear ViewModel at certain event? At the moment when I click 'go back button'. I want to r...
c

chanjungskim

about 2 years ago
How can I clear ViewModel at certain event? At the moment when I click 'go back button'. I want to reset the viewModel. But If I check the uiState, when I enter the screen. 1. Prepping -> Idle (which is correct) -> go back 2. (re-enter) Idle -> go back 3. (re-enter) Idle -> go back I called this function at 'go back event' but it doesn't clear.
// ViewModel
fun clear() = viewModelScope.launch {
    onCleared()
}
c
  • 1
  • 1
  • 701
Previous707172Next

kotlinlang

A modern programming language that makes developers happier.

Powered by