From 9d399b16fb18f3ed05be8d761b29c278778c4cbb Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Tue, 2 Jul 2024 11:20:34 +0400 Subject: [PATCH] [TH2-5211] corrected after review --- .../th2/lwdataprovider/entities/responses/Event.kt | 12 ++++-------- .../exactpro/th2/lwdataprovider/http/GetOneEvent.kt | 4 +--- .../exactpro/th2/lwdataprovider/http/HttpServer.kt | 1 - .../entities/responses/TestCustomSerializerKt.kt | 2 +- .../th2/lwdataprovider/http/TestGetOneEvent.kt | 3 +-- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/Event.kt b/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/Event.kt index 3a494e94..09df6ddd 100644 --- a/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/Event.kt +++ b/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/Event.kt @@ -111,16 +111,12 @@ data class Event( companion object { @JvmStatic - fun convertToEventIdProto(id: ProviderEventId): EventID { - return with(id.eventId) { - EventUtils.toEventID(startTimestamp, bookId.name, scope, this.id) - } + fun convertToEventIdProto(providerEventId: ProviderEventId): EventID = providerEventId.eventId.run { + EventUtils.toEventID(startTimestamp, bookId.name, scope, id) } @JvmStatic - fun convertMessageIdToProto(attachedMessageIds: Set): List { - return attachedMessageIds.map { id -> - StoredMessageId.fromString(id).toGrpcMessageId() - } + fun convertMessageIdToProto(attachedMessageIds: Set): List = attachedMessageIds.map { id -> + StoredMessageId.fromString(id).toGrpcMessageId() } } } diff --git a/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/GetOneEvent.kt b/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/GetOneEvent.kt index 581d19be..603b0273 100644 --- a/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/GetOneEvent.kt +++ b/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/GetOneEvent.kt @@ -33,13 +33,11 @@ import io.javalin.openapi.OpenApiParam import io.javalin.openapi.OpenApiResponse import mu.KotlinLogging import java.util.concurrent.ArrayBlockingQueue -import java.util.concurrent.Executor import java.util.function.Supplier class GetOneEvent( private val sseResponseBuilder: SseResponseBuilder, private val searchEventsHandler: SearchEventsHandler, - private val convExecutor: Executor, private val dataMeasurement: DataMeasurement, ) : AbstractRequestHandler() { @@ -89,7 +87,7 @@ class GetOneEvent( val reqContext = HttpGenericResponseHandler( queue, sseResponseBuilder, - convExecutor, + Runnable::run, dataMeasurement, Event::eventId, SseResponseBuilder::build diff --git a/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/HttpServer.kt b/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/HttpServer.kt index 0318e10a..43930ea3 100644 --- a/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/HttpServer.kt +++ b/app/src/main/kotlin/com/exactpro/th2/lwdataprovider/http/HttpServer.kt @@ -104,7 +104,6 @@ class HttpServer(private val context: Context) { GetOneEvent( sseResponseBuilder, this.context.searchEventsHandler, - context.convExecutor, context.requestsDataMeasurement, ), GetEventsServlet( diff --git a/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/TestCustomSerializerKt.kt b/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/TestCustomSerializerKt.kt index bdb71200..2fd1a20f 100644 --- a/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/TestCustomSerializerKt.kt +++ b/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/entities/responses/TestCustomSerializerKt.kt @@ -124,7 +124,7 @@ internal class TestCustomSerializerKt { ) val jsonBytes = event.toJSONByteArray() - println(String(jsonBytes)) + assertDoesNotThrow { mapper.readTree(jsonBytes) } } } \ No newline at end of file diff --git a/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/http/TestGetOneEvent.kt b/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/http/TestGetOneEvent.kt index 80ece489..d3766f41 100644 --- a/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/http/TestGetOneEvent.kt +++ b/app/src/test/kotlin/com/exactpro/th2/lwdataprovider/http/TestGetOneEvent.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 Exactpro (Exactpro Systems Limited) + * Copyright 2022-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ internal class TestGetOneEvent : AbstractHttpHandlerTest() { return GetOneEvent( sseResponseBuilder, context.searchEventsHandler, - context.convExecutor, context.requestsDataMeasurement, ) }