package Ġno . nav . person br uk er . dit tn av . var sel best iller . done Ċ Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġno . nav . br uk er not ifik as jon . schemas . internal . Done Intern Ċ import Ġno . nav . br uk er not ifik as jon . schemas . internal . N ok kel Intern Ċ import Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon Sto pp Ċ import Ġno . nav . person br uk er . dit tn av . common . metrics . Stub Metrics Reporter Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . database . Local Postgres Database Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . kafka . Consumer Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . kafka . Kafka Producer Wrapper Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . kafka . Kafka Test Topics Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . kafka . delay Until Commit ted Offset Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . dok not ifik as jon Sto pp . D ok not ifik as jon Sto pp Producer Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . metrics . Metrics Collector Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . nok kel . Av ro N ok kel Intern Object M other Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . var sel best illing . Var sel best illing Object M other Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . var sel best illing . Var sel best illing Repository Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . var sel best illing . create Var sel best illing er Ċ import Ġorg . am sh ove . k lu ent . shouldBe Ċ import Ġorg . apache . kafka . clients . consumer . Consumer Record Ċ import Ġorg . apache . kafka . clients . consumer . Mock Consumer Ċ import Ġorg . apache . kafka . clients . consumer . Offset Reset Strategy Ċ import Ġorg . apache . kafka . clients . producer . Mock Producer Ċ import Ġorg . apache . kafka . common . Topic Partition Ċ import Ġorg . junit . jupiter . api . Test Ċ Ċ class ĠDone Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġdatabase Ġ= ĠLocal Postgres Database () ĊĊĠĠĠ Ġprivate Ġval Ġmetrics Reporter Ġ= ĠStub Metrics Reporter () ĊĠĠĠ Ġprivate Ġval Ġmetrics Collector Ġ= ĠMetrics Collector ( metrics Reporter ) ĊĊĠĠĠ Ġprivate Ġval Ġdone Topic Partition Ġ= ĠTopic Partition (" done ", Ġ 0 ) ĊĠĠĠ Ġprivate Ġval Ġdone Consumer Mock Ġ= ĠMock Consumer < N ok kel Intern , ĠDone Intern >( Offset Reset Strategy . EAR LI EST ). also Ġ{ ĊĠĠĠĠĠĠĠ Ġit . subscribe ( listOf ( done Topic Partition . topic ())) ĊĠĠĠĠĠĠĠ Ġit . re balance ( listOf ( done Topic Partition )) ĊĠĠĠĠĠĠĠ Ġit . update Beginning Offsets ( map Of ( done Topic Partition Ġto Ġ 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġdok not ifik as jon Stop Producer Mock Ġ= ĠMock Producer ( ĊĠĠĠĠĠĠĠ Ġfalse , ĊĠĠĠĠĠĠĠ Ġ{ Ġ_: ĠString , Ġ_: ĠString Ġ-> ĠByteArray ( 0 ) Ġ}, Ġ// Dummy Ġserializers ĊĠĠĠĠĠĠĠ Ġ{ Ġ_: ĠString , Ġ_: ĠD ok not ifik as jon Sto pp Ġ-> ĠByteArray ( 0 ) Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġprivate Ġval Ġkafka Producer Wrapper Ġ= ĊĠĠĠĠĠĠĠ ĠKafka Producer Wrapper ( Kafka Test Topics . dok not ifik as jon Stop Topic Name , Ġdok not ifik as jon Stop Producer Mock ) ĊĊĠĠĠ Ġprivate Ġval Ġdok not ifik as jon Repository Ġ= ĠVar sel best illing Repository ( database ) ĊĠĠĠ Ġprivate Ġval Ġdok not ifik as jon Stop Producer Ġ= ĠD ok not ifik as jon Sto pp Producer ( kafka Producer Wrapper , Ġdok not ifik as jon Repository ) ĊĠĠĠ Ġprivate Ġval Ġevent Service Ġ= ĠDone Event Service ( dok not ifik as jon Stop Producer , Ġdok not ifik as jon Repository , Ġmetrics Collector ) ĊĠĠĠ Ġprivate Ġval Ġconsumer Ġ= ĠConsumer ( Kafka Test Topics . done Topic Name , Ġdone Consumer Mock , Ġevent Service ) ĊĊĠĠĠ Ġprivate Ġval Ġvar sel best illing er Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠVar sel best illing Object M other . create Var sel best illing With Best ill ings Id And EventId ( best ill ings Id Ġ= Ġ" B - test - 1 ", Ġevent Id Ġ= Ġ" 1 "), ĊĠĠĠĠĠĠĠ ĠVar sel best illing Object M other . create Var sel best illing With Best ill ings Id And EventId ( best ill ings Id Ġ= Ġ" B - test - 2 ", Ġevent Id Ġ= Ġ" 2 "), ĊĠĠĠĠĠĠĠ ĠVar sel best illing Object M other . create Var sel best illing With Best ill ings Id And EventId ( best ill ings Id Ġ= Ġ" B - test - 3 ", Ġevent Id Ġ= Ġ" 3 ")) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` Les er Ġdone Ġog Ġav best iller Ġvar se ler `() Ġ{ ĊĠĠĠĠĠĠĠ Ġdok not ifik as jon Stop Producer Mock . init Transactions () ĊĊĠĠĠĠĠĠĠ Ġcreate Var sel best illing er In Db () ĊĊĠĠĠĠĠĠĠ Ġval Ġdone Event er Ġ= Ġ( 1 .. 1 0 ). associate Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAv ro N ok kel Intern Object M other . create N ok kel Intern With EventId ( it ) Ġto ĠAv ro Done Intern Object M other . create Done Intern () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġdone Event er . entries . forEach Indexed Ġ{ Ġindex , Ġentry Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdone Consumer Mock . add Record ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠConsumer Record ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdone Topic Partition . topic (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdone Topic Partition . partition (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġindex . to Long (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġentry . key , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġentry . value ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconsumer . start Polling () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdelay Until Commit ted Offset ( done Consumer Mock , Ġdone Topic Partition , Ġdone Event er . size . to Long ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconsumer . stop Polling () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġdok not ifik as jon Stop Event er Ġ= Ġdok not ifik as jon Stop Producer Mock . history () ĊĠĠĠĠĠĠĠ Ġdok not ifik as jon Stop Event er . size ĠshouldBe Ġvar sel best illing er . size ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Var sel best illing er In Db () Ġ{ ĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdatabase . db Query Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcreate Var sel best illing er ( var sel best illing er ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }