Mark Allanson
06/29/2021, 8:20 AMspyk intercept all calls to object AND make it relaxed at the same time?Mattia Tommasone
06/29/2021, 8:24 AMMark Allanson
06/29/2021, 8:31 AMclass Dispatcher(val wrapped: SomeClass<*>)
I essentially want to do (where toBeWrapped is injected via spring to the test)....
@SpringBootTest
class DispatcherTests {
@Autowired
lateinit var toBeWrapped: List<ProviderModule<*, *>>
@Test
fun testGetDataDispatchedForEachProvider() {
for (dispatcher in this.toBeWrapped.map { Dispatcher(it) }) {
val moduleSpy = spyk(dispatcher.provider)
every { moduleSpy.getData(any()) }
dispatcher.getData(someData)
verify { moduleSpy.getData(any()) }
}
}
}
of course the call to getData on toBeWrapped could be anything, which is represented as Nothing by the compiler, so am having trouble spying on itMark Allanson
06/29/2021, 8:31 AMoneof which makes it messy)Mattia Tommasone
06/29/2021, 8:32 AMMark Allanson
06/29/2021, 8:33 AMtoBeWrapped classes are added, that a mapping is also added into the Dispatcher componentMattia Tommasone
06/29/2021, 8:33 AM* extends Something rather than just *Mattia Tommasone
06/29/2021, 8:33 AMMattia Tommasone
06/29/2021, 8:33 AMMark Allanson
06/29/2021, 8:33 AMMattia Tommasone
06/29/2021, 8:34 AMMark Allanson
06/29/2021, 8:34 AMMark Allanson
06/29/2021, 8:35 AMpublic final class SomeCalss extends GeneratedMessageV3Mark Allanson
06/29/2021, 8:35 AMMattia Tommasone
06/29/2021, 8:35 AMMark Allanson
06/29/2021, 11:14 AMFor, whereFoo<in T>is a contravariant type parameter,Tis equivalent toFoo<*>. It means there is nothing you can write toFoo<in Nothing>in a safe way whenFoo<*>is unknown.T
Mattia Tommasone
06/29/2021, 11:22 AMMark Allanson
06/29/2021, 2:31 PMevery {
dispatcherSpy invoke "dispatch" withArguments listOf(a, b)
} returns responseMattia Tommasone
06/29/2021, 2:32 PMMark Allanson
06/29/2021, 2:48 PMmockkClass(theClassInstance::class, relaxed = true)