arve
07/31/2020, 12:49 PM// fun src.loadString(fieldName: String): String? {...}
dstBuilder.fieldA = src.loadString("aField") ?: throw Exeption("Field A is not present")
// Instead of throwing, i want to leave dst.fieldA unset - skip this line and move to next.
Nikolay Puliaev
07/31/2020, 5:10 PMval list1 = listOf(ExampleObject(id = 1), ExampleObject(id = 2))
val list2 = listOf(ExampleObject(id = 2))
Result: listOf(ExampleObject(1))
Thanks in advance.Sam Garfinkel
07/31/2020, 8:46 PMendswith("</endtag>")
but this seems inefficient to run over the length of the buffer, especially if we get a char that can’t contribute to the terminal tag.Ju
08/01/2020, 2:54 AMJu
08/01/2020, 4:04 AMMati Galli
08/01/2020, 7:46 PMclass OptionGroupControllerTest : KoinTest {
private val optionGroup: String = this::class.java
.getResource("/jsons/option_group.json")
.readText()
.replace("\n", "")
.replace(" ", "")
@BeforeTest
fun setup() {
startKoin {
module {
single<OptionGroupController>()
single<OptionGroupService>()
}
}
}
@AfterTest
fun teardown() {
stopKoin()
}
@Test
fun `create option`() = withTestApplication(Application::routes) {
with(handleRequest(<http://HttpMethod.Post|HttpMethod.Post>, "/optionGroup") {
addHeader(HttpHeaders.ContentType, ContentType.Application.Json.toString())
setBody(optionGroup)
}) {
assertEquals(HttpStatusCode.Created, response.status())
}
}
}
My Routes:
fun Application.routes() {
val controllerOptionGroup: OptionGroupController by inject()
val controllerOption: OptionController by inject()
routing {
get("/") {
call.respondText("OK")
}
get("/health") {
call.respondText("OK")
}
route("/optionGroup") {
post {
try {
val message = call.receive<String>()
val messageOptionGroup: OptionGroupDTO = Mapper.read(message)
println("SERVER: Message from the client: $message")
call.respond(controllerOptionGroup.create(call, messageOptionGroup))
} catch (ex: ItemException) {
call.respond(HttpStatusCode.BadRequest, mapOf("code" to ex.code, "messages" to arrayListOf(ex.message)))
}
}
}
}
}
And the exception is thrown at line:
call.respond(controllerOptionGroup.create(call, messageOptionGroup))
This problem only gives me when running the tests. When I run the application everything works correctly.
I would really appreciate if someone can give me a hand with this 🙂kqr
08/02/2020, 7:10 AMBig Chungus
08/02/2020, 10:29 AMHullaballoonatic
08/02/2020, 10:59 PMjenji
08/03/2020, 4:50 PMMatteo Mirk
08/04/2020, 8:24 AMMehdi Haghgoo
08/04/2020, 4:26 PMbbaldino
08/04/2020, 11:52 PMTomas Kartasovas
08/05/2020, 2:42 PMpoohbar
08/05/2020, 4:58 PM# JRE version: Java(TM) SE Runtime Environment (8.0_261-b12) (build 1.8.0_261-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.261-b12 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# J 29740 C2 kotlin.reflect.jvm.internal.impl.descriptors.runtime.structure.ReflectClassUtilKt.getDesc(Ljava/lang/Class;)Ljava/lang/String; (73 bytes) @ 0x000000011803a082 [0x0000000118039e20+0x262]
ilyagulya
08/06/2020, 9:33 AMkotlinOptions {
verbose = true
}
Ola Denslaw
08/06/2020, 10:50 AMzkeme
08/06/2020, 1:27 PMfun <T : Any> getFoo(defaultValue: T): Foo<T> {
return when (defaultValue) {
is Long -> LongFoo(defaultValue) as Foo<T> //LongFoo extends Foo<Long>
is Int -> IntFoo(defaultValue) as Foo<T> //IntFoo extends Foo<Int>
is String -> StringFoo(defaultValue) as Foo<T> //StringFoo extends Foo<String>
else -> NonPrimitiveFoo(defaultValue, defaultValue.javaClass)
}
}
Luis Munoz
08/06/2020, 3:35 PMinit {
factory = ConnectionFactory().apply {
setUri(config_uri)
// Attempt recovery every 5 seconds
isAutomaticRecoveryEnabled = true
}
rabbitConnection = factory.newConnection()
eddMX
08/06/2020, 5:52 PMSam Garfinkel
08/06/2020, 6:37 PMfold
with a mutable list of Pairs
.viralshah
08/06/2020, 6:37 PMKyaw Za Zaw
08/06/2020, 7:44 PMAllan Wang
08/06/2020, 10:00 PMchunked
, where the partial window is at the start?
eg with list [1, 2, 3, 4, 5, 6, 7, 8]
, chunked
gives [[1, 2, 3], [4, 5, 6], [7, 8]]
, but I want [[1, 2], [3, 4, 5], [6, 7, 8]]
.
Or do I have to modulo myself and chunk when I know it's a multiple of my chunk window?Matthew Pope
08/07/2020, 1:54 AMNothing?
in your code anywhere?TwoClocks
08/07/2020, 6:02 AMKris-Gerhard Aabrams
08/07/2020, 6:46 AMAlf_
08/07/2020, 12:37 PMval arrayNumber = arrayOf(0, 1, 2, 3)
if (arrayNumber.contains(0)) {
//DO SOMETHING FOR CASE 0
}
if (arrayNumber.contains(1)) {
//DO SOMETHING FOR CASE 1
}
if (arrayNumber.contains(2)) {
//DO SOMETHING FOR CASE 2
}
if (arrayNumber.contains(3)) {
//DO SOMETHING FOR CASE 3
}
Thanks in advance!TwoClocks
08/07/2020, 7:52 PMFlazzarino
08/08/2020, 12:36 PMFlazzarino
08/08/2020, 12:36 PMdarkmoon_uk
08/08/2020, 1:24 PMdelay(<someDuration>)
into your suspending method more than once - that will result in it being suspended multiple times.Flazzarino
08/08/2020, 1:39 PMdarkmoon_uk
08/08/2020, 1:52 PMFlazzarino
08/08/2020, 1:53 PMephemient
08/08/2020, 4:07 PMelse -> throw IllegalStateException("Already resumed")
streetsofboston
08/08/2020, 4:50 PMFlow
that has the same structured concurrency as suspend funs but can emit more than one value.iseki
08/09/2020, 12:21 PM