diff --git a/src/main/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/MessageId.kt b/src/main/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/MessageId.kt index e15d9f339..5bd43a5d6 100644 --- a/src/main/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/MessageId.kt +++ b/src/main/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/MessageId.kt @@ -90,7 +90,7 @@ data class MessageId( } -private const val SEQUENCE_NOT_SET = -1L +private const val SEQUENCE_NOT_SET = Long.MIN_VALUE private class MessageIdBuilderImpl : MessageId.Builder { private var _sessionAlias: String? = null @@ -128,7 +128,7 @@ private class MessageIdBuilderImpl : MessageId.Builder { override fun isDirectionSet(): Boolean = _direction != null override fun setSequence(sequence: Long): MessageId.Builder = apply { - require(sequence > SEQUENCE_NOT_SET) { "Property \"sequence\" should not be negative" } + require(sequence != SEQUENCE_NOT_SET) { "Value $sequence for property \"sequence\" is reserved" } this._sequence = sequence } diff --git a/src/test/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/ParsedMessageTest.kt b/src/test/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/ParsedMessageTest.kt index 2560cb198..23d092e27 100644 --- a/src/test/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/ParsedMessageTest.kt +++ b/src/test/kotlin/com/exactpro/th2/common/schema/message/impl/rabbitmq/transport/ParsedMessageTest.kt @@ -192,7 +192,10 @@ class ParsedMessageTest { private const val TEST_PROTOCOL = "test-protocol" private const val TEST_SESSION_ALIAS = "test-session-alias" private const val TEST_MESSAGE_TYPE = "test-message-type" - private val TEST_SEQUENCE = Random.nextLong() - private val TEST_SUB_SEQUENCE = listOf(Random.nextInt(), Random.nextInt()) + private val TEST_SEQUENCE = Random.nextLong(from = Long.MIN_VALUE + 1, until = Long.MAX_VALUE) + private val TEST_SUB_SEQUENCE = listOf( + Random.nextInt(from = 0, until = Int.MAX_VALUE), + Random.nextInt(from = 0, until = Int.MAX_VALUE), + ) } } \ No newline at end of file