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
class AnagramCalculator(private val wordsDictionary: Collection<String>) { | |
private fun findAnagrams( | |
word: String, | |
dictionary: Collection<String>, | |
acc: String = "", | |
): Collection<String> { | |
if (word.isEmpty() || dictionary.isEmpty()) { | |
return dictionary | |
} |
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.patxi.intellijsplashscreen | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.geometry.Size | |
import androidx.compose.ui.graphics.drawscope.DrawScope | |
import androidx.compose.ui.graphics.drawscope.translate | |
import androidx.compose.ui.unit.IntSize |
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
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.geometry.Offset | |
import androidx.compose.ui.geometry.Size | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.drawscope.DrawScope | |
import androidx.compose.ui.graphics.drawscope.translate | |
import androidx.compose.ui.tooling.preview.Preview |
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
@get:Rule | |
RequestOverrideRule( | |
MockedRequest( | |
method = GET, | |
url = "/example/endpoint", | |
jsonBody = json { | |
"intProperty" to 0 | |
"stringProperty" to "test" | |
} | |
) |
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
scope.launch { | |
overrideChannel.consumeEach { mockedRequest -> | |
server.application.routing { | |
val httpAction: Route.(String, PipelineInterceptor<Unit, ApplicationCall>) -> Route = | |
when (mockedRequest.method) { | |
HttpMethod.GET -> Route::get | |
HttpMethod.POST -> Route::post | |
HttpMethod.PUT -> Route::put | |
} | |
httpAction(mockedRequest.url) { |
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
private val job = Job() | |
private val scope = CoroutineScope(job + Dispatchers.Default) | |
private val overrideChannel = Channel<MockedRequest>(Channel.UNLIMITED) |
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
class RequestOverrideRule(private vararg val mockedRequests: MockedRequest, private val overrideChannel: SendChannel<MockedRequest> = get().koin.get()) : TestRule { | |
override fun apply(statement: Statement, description: Description): Statement { | |
return object : Statement() { | |
override fun evaluate() { | |
mockedRequests.forEach { | |
overrideChannel.offer(it) | |
} | |
statement.evaluate() | |
} | |
} |
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
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
startKoin { | |
modules(..., environmentKoinModule, ...) | |
} | |
... | |
} |
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
environmentKoinModule.factory<UrlsDataStore>(override = true) { | |
val httpAddress = "localhost:8080" | |
object : UrlsDataStore { | |
override val api = httpAddress | |
override val bff = httpAddress | |
... | |
} | |
} |
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
get("path/to/get") { | |
call.respondText("Hello GET!") | |
} | |
post("path/to/post") { | |
call.respondText("Hello POST!") | |
} |
NewerOlder