@@ -18,6 +18,7 @@ package com.exactpro.th2.codec.fixng
1818
1919import com.exactpro.sf.common.messages.structures.IDictionaryStructure
2020import com.exactpro.sf.common.messages.structures.loaders.XmlDictionaryStructureLoader
21+ import com.exactpro.sf.comparison.conversion.MultiConverter
2122import com.exactpro.th2.codec.api.IReportingContext
2223import com.exactpro.th2.codec.fixng.FixNgCodecFactory.Companion.PROTOCOL
2324import com.exactpro.th2.common.schema.message.impl.rabbitmq.transport.Direction
@@ -69,6 +70,53 @@ class FixNgCodecTest {
6970 @MethodSource(" configs" )
7071 fun `simple encode` (isDirty : Boolean , delimiter : Char ) = encodeTest(MSG_CORRECT , isDirty, delimiter)
7172
73+ @ParameterizedTest
74+ @CsvSource(
75+ " true,java.lang.Character,a,,287,072" ,
76+ " true,java.lang.Byte,127,,289,131" ,
77+ " true,java.lang.Short,32767,,291,235" ,
78+ " true,java.lang.Integer,2147483647,,296,245" ,
79+ " true,java.lang.Long,9223372036854775807,,305,198" ,
80+ " true,java.lang.Float,3.4028234,,295,174" ,
81+ " true,java.lang.Double,1.7976931348623157,,304,141" ,
82+ " true,java.math.BigDecimal,1.7976931348623157,,304,141" ,
83+ " true,java.time.LocalDateTime,2025-09-29T14:07:53.168966352,20250929-14:07:53.168966352,313,091" ,
84+ " true,java.time.LocalDate,2025-09-29,20250929,294,130" ,
85+ " true,java.time.LocalTime,14:07:53.168,,298,094" , // FIXME: Seconds unit should depend of settings
86+ " true,java.lang.Boolean,true,Y,287,064" ,
87+
88+ " false,java.lang.Character,a,,287,072" ,
89+ " false,java.lang.Byte,127,,289,131" ,
90+ " false,java.lang.Short,32767,,291,235" ,
91+ " false,java.lang.Integer,2147483647,,296,245" ,
92+ " false,java.lang.Long,9223372036854775807,,305,198" ,
93+ " false,java.lang.Float,3.4028234,,295,174" ,
94+ " false,java.lang.Double,1.7976931348623157,,304,141" ,
95+ " false,java.math.BigDecimal,1.7976931348623157,,304,141" ,
96+ " false,java.time.LocalDateTime,2025-09-29T14:07:53.168966352,20250929-14:07:53.168966352,313,091" ,
97+ " false,java.time.LocalDate,2025-09-29,20250929,294,130" ,
98+ " false,java.time.LocalTime,14:07:53.168,,298,094" , // FIXME: Seconds unit should depend of settings
99+ " false,java.lang.Boolean,true,Y,287,064" ,
100+ )
101+ fun `encode with different value types for string field` (
102+ isDirty : Boolean ,
103+ clazz : Class <* >,
104+ value : String ,
105+ encodedValue : String? ,
106+ length : Int ,
107+ checkSum : String ,
108+ ) {
109+ parsedBody[" ExecID" ] = MultiConverter .convert(value, clazz)
110+ encodeTest(
111+ MSG_CORRECT
112+ .replace(" 17=495504662" , " 17=${encodedValue ? : value} " )
113+ .replace(" 9=295" , " 9=${length} " )
114+ .replace(" 10=191" , " 10=${checkSum} " ),
115+ dirtyMode = isDirty,
116+ ' ' ,
117+ )
118+ }
119+
72120 @ParameterizedTest
73121 @MethodSource(" configs" )
74122 fun `simple encode from string values` (isDirty : Boolean , delimiter : Char ) =
@@ -297,6 +345,7 @@ class FixNgCodecTest {
297345
298346 @ParameterizedTest
299347 @ValueSource(chars = [' ' , ' |' ])
348+ @Suppress(" SpellCheckingInspection" )
300349 fun `tags with 0 prefix decode (dirty)` (delimiter : Char ) {
301350 with (parsedMessage) {
302351 (body map " header" ).set(" BodyLength" , 302 )
@@ -1007,7 +1056,7 @@ class FixNgCodecTest {
10071056 return FixNgCodec (dictionary, FixNgCodecSettings (
10081057 dictionary = " " ,
10091058 decodeValuesToStrings = decodeValuesToStrings,
1010- decodeDelimiter = delimiter
1059+ decodeDelimiter = delimiter,
10111060 ))
10121061 }
10131062
@@ -1031,7 +1080,7 @@ class FixNgCodecTest {
10311080 parsedMessage : ParsedMessage ,
10321081 delimiter : Char ,
10331082 expectedWarning : String? = null,
1034- encodeFromStringValues : Boolean = false
1083+ encodeFromStringValues : Boolean = false,
10351084 ) {
10361085 val parsedBody = parsedMessage.body as MutableMap <String , Any ?>
10371086
@@ -1057,7 +1106,7 @@ class FixNgCodecTest {
10571106 parsedMessage : ParsedMessage ,
10581107 delimiter : Char ,
10591108 expectedError : String? = null,
1060- encodeFromStringValues : Boolean = false
1109+ encodeFromStringValues : Boolean = false,
10611110 ) {
10621111 val parsedBody = parsedMessage.body as MutableMap <String , Any ?>
10631112
@@ -1192,6 +1241,7 @@ class FixNgCodecTest {
11921241 else -> value.toString()
11931242 }
11941243
1244+ @Suppress(" SpellCheckingInspection" )
11951245 private val parsedMessage = ParsedMessage (
11961246 MessageId (" test_alias" , Direction .OUTGOING , 0L , Instant .now(), emptyList()),
11971247 EventId (" test_id" , " test_book" , " test_scope" , Instant .now()),
@@ -1249,6 +1299,7 @@ class FixNgCodecTest {
12491299
12501300 private val parsedBody: MutableMap <String , Any ?> = parsedMessage.body as MutableMap
12511301
1302+ @Suppress(" SpellCheckingInspection" )
12521303 private val expectedMessageWithoutBody = ParsedMessage (
12531304 MessageId (" test_alias" , Direction .OUTGOING , 0L , Instant .now(), emptyList()),
12541305 EventId (" test_id" , " test_book" , " test_scope" , Instant .now()),
@@ -1271,6 +1322,7 @@ class FixNgCodecTest {
12711322 )
12721323 )
12731324
1325+ @Suppress(" SpellCheckingInspection" )
12741326 private val parsedMessageWithNestedComponents = ParsedMessage (
12751327 MessageId (" test_alias" , Direction .OUTGOING , 0L , Instant .now(), emptyList()),
12761328 EventId (" test_id" , " test_book" , " test_scope" , Instant .now()),
@@ -1300,6 +1352,7 @@ class FixNgCodecTest {
13001352 )
13011353 private val parsedBodyWithNestedComponents: MutableMap <String , Any ?> = parsedMessageWithNestedComponents.body as MutableMap
13021354
1355+ @Suppress(" SpellCheckingInspection" )
13031356 private val parsedMessageWithNestedGroups = ParsedMessage (
13041357 MessageId (" test_alias" , Direction .OUTGOING , 0L , Instant .now(), emptyList()),
13051358 EventId (" test_id" , " test_book" , " test_scope" , Instant .now()),
@@ -1368,6 +1421,7 @@ class FixNgCodecTest {
13681421 )
13691422 )
13701423
1424+ @Suppress(" SpellCheckingInspection" )
13711425 private val parsedLogon = ParsedMessage (
13721426 MessageId (" test_alias" , Direction .OUTGOING , 0L , Instant .now(), emptyList()),
13731427 EventId (" test_id" , " test_book" , " test_scope" , Instant .now()),
0 commit comments