package Ġcom . github . avro kotlin . avro 4 k . decoder Ċ Ċ import Ġcom . github . avro kotlin . avro 4 k . Av ro Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġio . kot est . core . spec . style . Word Spec Ċ import Ġkotlinx . serialization . Serializable Ċ import Ġorg . apache . avro . Schema Ċ import Ġorg . apache . avro . generic . Generic Data Ċ Ċ @ Serializable Ċ data Ġclass ĠTest Array B ooleans ( val Ġb ooleans : ĠArray < Boolean >) Ċ Ċ @ Serializable Ċ data Ġclass ĠTest List Doubles ( val Ġdouble s : ĠList < Double >) Ċ Ċ @ Serializable Ċ data Ġclass ĠTest SetString ( val Ġstrings : ĠSet < String >) Ċ Ċ @ Serializable Ċ data Ġclass ĠTest Array Records ( val Ġrecords : ĠArray < Record >) Ċ Ċ @ Serializable Ċ data Ġclass ĠTest List Records ( val Ġrecords : ĠList < Record >) Ċ Ċ @ Serializable Ċ data Ġclass ĠTest Set Records ( val Ġrecords : ĠSet < Record >) Ċ Ċ @ Serializable Ċ data Ġclass ĠRecord ( val Ġstr : ĠString , Ġval Ġdouble : ĠDouble ) Ċ Ċ class ĠArray Decoder Test Ġ: ĠWord Spec ({ ĊĊĠ Ġ" Decoder " Ġshould Ġ{ ĊĊĠĠĠ Ġ" support Ġarray Ġfor Ġan ĠArray Ġof Ġb ooleans " Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test Array B ooleans . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" b ooleans ", ĠarrayOf ( true , Ġfalse , Ġtrue )) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test Array B ooleans . serializer (), Ġrecord ). b ooleans . toList () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠlistOf ( true , Ġfalse , Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġlist Ġfor Ġan ĠArray Ġof Ġb ooleans " Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test Array B ooleans . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" b ooleans ", ĠlistOf ( true , Ġfalse , Ġtrue )) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test Array B ooleans . serializer (), Ġrecord ). b ooleans . toList () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠlistOf ( true , Ġfalse , Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support ĠGeneric Data . Array Ġfor Ġan ĠArray Ġof Ġb ooleans " Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test Array B ooleans . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" b ooleans ", ĊĠĠĠĠĠĠĠĠĠ ĠGeneric Data . Array ( Schema . create Array ( Schema . create ( Schema . Type . BOOLEAN )), ĠlistOf ( true , Ġfalse , Ġtrue ))) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test Array B ooleans . serializer (), Ġrecord ). b ooleans . toList () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠlistOf ( true , Ġfalse , Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġarray Ġfor Ġa ĠList Ġof Ġdouble s " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test List Doubles . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" double s ", ĠarrayOf ( 1 2 . 5 4 , Ġ 2 3 . 5 , Ġ 9 1 2 3 . 2 3 1 4 )) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test List Doubles . serializer (), Ġrecord ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest List Doubles ( listOf ( 1 2 . 5 4 , Ġ 2 3 . 5 , Ġ 9 1 2 3 . 2 3 1 4 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġlist Ġfor Ġa ĠList Ġof Ġdouble s " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test List Doubles . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" double s ", ĠlistOf ( 1 2 . 5 4 , Ġ 2 3 . 5 , Ġ 9 1 2 3 . 2 3 1 4 )) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test List Doubles . serializer (), Ġrecord ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest List Doubles ( listOf ( 1 2 . 5 4 , Ġ 2 3 . 5 , Ġ 9 1 2 3 . 2 3 1 4 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support ĠGeneric Data . Array Ġfor Ġa ĠList Ġof Ġdouble s " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test List Doubles . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" double s ", ĊĠĠĠĠĠĠĠĠĠ ĠGeneric Data . Array ( Schema . create Array ( Schema . create ( Schema . Type . DOUBLE )), ĠlistOf ( 1 2 . 5 4 , Ġ 2 3 . 5 , Ġ 9 1 2 3 . 2 3 1 4 ))) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test List Doubles . serializer (), Ġrecord ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest List Doubles ( listOf ( 1 2 . 5 4 , Ġ 2 3 . 5 , Ġ 9 1 2 3 . 2 3 1 4 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġarray Ġfor Ġa ĠList Ġof Ġrecords " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġcontainer Schema Ġ= ĠAv ro . default . schema ( Test List Records . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Schema Ġ= ĠAv ro . default . schema ( Record . serializer ()) ĊĊĠĠĠĠĠ Ġval Ġrecord 1 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 1 . put (" str ", Ġ" q we ") ĊĠĠĠĠĠ Ġrecord 1 . put (" double ", Ġ 1 2 3 . 4 ) ĊĊĠĠĠĠĠ Ġval Ġrecord 2 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 2 . put (" str ", Ġ" wer ") ĊĠĠĠĠĠ Ġrecord 2 . put (" double ", Ġ 8 2 3 4 . 3 2 4 ) ĊĊĠĠĠĠĠ Ġval Ġcontainer Ġ= ĠGeneric Data . Record ( container Schema ) ĊĠĠĠĠĠ Ġcontainer . put (" records ", ĠarrayOf ( record 1 , Ġrecord 2 )) ĊĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test List Records . serializer (), Ġcontainer ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest List Records ( listOf ( Record (" q we ", Ġ 1 2 3 . 4 ), ĠRecord (" wer ", Ġ 8 2 3 4 . 3 2 4 ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġlist Ġfor Ġa ĠList Ġof Ġrecords " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġcontainer Schema Ġ= ĠAv ro . default . schema ( Test List Records . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Schema Ġ= ĠAv ro . default . schema ( Record . serializer ()) ĊĊĠĠĠĠĠ Ġval Ġrecord 1 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 1 . put (" str ", Ġ" q we ") ĊĠĠĠĠĠ Ġrecord 1 . put (" double ", Ġ 1 2 3 . 4 ) ĊĊĠĠĠĠĠ Ġval Ġrecord 2 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 2 . put (" str ", Ġ" wer ") ĊĠĠĠĠĠ Ġrecord 2 . put (" double ", Ġ 8 2 3 4 . 3 2 4 ) ĊĊĠĠĠĠĠ Ġval Ġcontainer Ġ= ĠGeneric Data . Record ( container Schema ) ĊĠĠĠĠĠ Ġcontainer . put (" records ", ĠlistOf ( record 1 , Ġrecord 2 )) ĊĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test List Records . serializer (), Ġcontainer ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest List Records ( listOf ( Record (" q we ", Ġ 1 2 3 . 4 ), ĠRecord (" wer ", Ġ 8 2 3 4 . 3 2 4 ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġarray Ġfor Ġa ĠSet Ġof Ġrecords " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġcontainer Schema Ġ= ĠAv ro . default . schema ( Test Set Records . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Schema Ġ= ĠAv ro . default . schema ( Record . serializer ()) ĊĊĠĠĠĠĠ Ġval Ġrecord 1 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 1 . put (" str ", Ġ" q we ") ĊĠĠĠĠĠ Ġrecord 1 . put (" double ", Ġ 1 2 3 . 4 ) ĊĊĠĠĠĠĠ Ġval Ġrecord 2 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 2 . put (" str ", Ġ" wer ") ĊĠĠĠĠĠ Ġrecord 2 . put (" double ", Ġ 8 2 3 4 . 3 2 4 ) ĊĊĠĠĠĠĠ Ġval Ġcontainer Ġ= ĠGeneric Data . Record ( container Schema ) ĊĠĠĠĠĠ Ġcontainer . put (" records ", ĠarrayOf ( record 1 , Ġrecord 2 )) ĊĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test Set Records . serializer (), Ġcontainer ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest Set Records ( set Of ( Record (" q we ", Ġ 1 2 3 . 4 ), ĠRecord (" wer ", Ġ 8 2 3 4 . 3 2 4 ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support ĠGeneric Data . Array Ġfor Ġa ĠSet Ġof Ġrecords " Ġ{ ĊĊĠĠĠĠĠ Ġval Ġcontainer Schema Ġ= ĠAv ro . default . schema ( Test Set Records . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Schema Ġ= ĠAv ro . default . schema ( Record . serializer ()) ĊĊĠĠĠĠĠ Ġval Ġrecord 1 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 1 . put (" str ", Ġ" q we ") ĊĠĠĠĠĠ Ġrecord 1 . put (" double ", Ġ 1 2 3 . 4 ) ĊĊĠĠĠĠĠ Ġval Ġrecord 2 Ġ= ĠGeneric Data . Record ( record Schema ) ĊĠĠĠĠĠ Ġrecord 2 . put (" str ", Ġ" wer ") ĊĠĠĠĠĠ Ġrecord 2 . put (" double ", Ġ 8 2 3 4 . 3 2 4 ) ĊĊĠĠĠĠĠ Ġval Ġcontainer Ġ= ĠGeneric Data . Record ( container Schema ) ĊĠĠĠĠĠ Ġcontainer . put (" records ", ĊĠĠĠĠĠĠĠĠĠ ĠGeneric Data . Array ( Schema . create Array ( Schema . create ( Schema . Type . STRING )), ĠlistOf ( record 1 , Ġrecord 2 ))) ĊĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test Set Records . serializer (), Ġcontainer ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest Set Records ( set Of ( Record (" q we ", Ġ 1 2 3 . 4 ), ĠRecord (" wer ", Ġ 8 2 3 4 . 3 2 4 ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġarray Ġfor Ġa ĠSet Ġof Ġstrings " Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test SetString . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" strings ", ĠarrayOf (" Q we ", Ġ" 3 2 4 ", Ġ" q ")) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test SetString . serializer (), Ġrecord ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest SetString ( set Of (" Q we ", Ġ" 3 2 4 ", Ġ" q ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support Ġlist Ġfor Ġa ĠSet Ġof Ġstrings " Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test SetString . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" strings ", ĠarrayOf (" Q we ", Ġ" 3 2 4 ", Ġ" q ")) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test SetString . serializer (), Ġrecord ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest SetString ( set Of (" Q we ", Ġ" 3 2 4 ", Ġ" q ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ" support ĠGeneric Data . Array Ġfor Ġa ĠSet Ġof Ġstrings " Ġ{ ĊĠĠĠĠĠ Ġval Ġschema Ġ= ĠAv ro . default . schema ( Test SetString . serializer ()) ĊĠĠĠĠĠ Ġval Ġrecord Ġ= ĠGeneric Data . Record ( schema ) ĊĠĠĠĠĠ Ġrecord . put (" strings ", ĊĠĠĠĠĠĠĠĠĠ ĠGeneric Data . Array ( Schema . create Array ( Schema . create ( Schema . Type . STRING )), ĠlistOf (" Q we ", Ġ" 3 2 4 ", Ġ" q "))) ĊĠĠĠĠĠ ĠAv ro . default . from Record ( Test SetString . serializer (), Ġrecord ) ĠshouldBe ĊĠĠĠĠĠĠĠĠĠ ĠTest SetString ( set Of (" Q we ", Ġ" 3 2 4 ", Ġ" q ")) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ Ċ })