package Ġde . r ki . cor on aw arn app . storage Ċ Ċ import Ġde . r ki . cor on aw arn app . dat ad on ation . analytics . modules . key submission . Analytics Key Submission Collector Ċ import Ġde . r ki . cor on aw arn app . dead man . Dead man Notification Scheduler Ċ import Ġde . r ki . cor on aw arn app . playbook . Background Noise Ċ import Ġde . r ki . cor on aw arn app . service . submission . Submission Service Ċ import Ġde . r ki . cor on aw arn app . submission . Submission Repository Ċ import Ġde . r ki . cor on aw arn app . submission . Submission Settings Ċ import Ġde . r ki . cor on aw arn app . submission . Sy mptoms Ċ import Ġde . r ki . cor on aw arn app . submission . data . tek history . TE K History Storage Ċ import Ġde . r ki . cor on aw arn app . task . Task Controller Ċ import Ġde . r ki . cor on aw arn app . util . Device UIState Ċ import Ġde . r ki . cor on aw arn app . util . Network Request Wrapper Ċ import Ġde . r ki . cor on aw arn app . util . TimeStamp er Ċ import Ġde . r ki . cor on aw arn app . util . di . App Injector Ċ import Ġde . r ki . cor on aw arn app . util . di . Application Component Ċ import Ġde . r ki . cor on aw arn app . util . formatter . TestResult Ċ import Ġde . r ki . cor on aw arn app . util . security . Encrypted Preferences Factory Ċ import Ġde . r ki . cor on aw arn app . util . security . Encryption Error Reset Tool Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġio . mock k . Mock K Annotations Ċ import Ġio . mock k . Runs Ċ import Ġio . mock k . co Every Ċ import Ġio . mock k . co Verify Ċ import Ġio . mock k . co Verify Order Ċ import Ġio . mock k . every Ċ import Ġio . mock k . impl . annotations . Mock K Ċ import Ġio . mock k . just Ċ import Ġio . mock k . mock k Object Ċ import Ġio . mock k . verify Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . flow . empty Flow Ċ import Ġkotlinx . coroutines . flow . first Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . joda . time . Instant Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġtest helpers . Base Test Ċ import Ġtest helpers . preferences . mock Flow Preference Ċ Ċ class ĠSubmission Repository Test Ġ: ĠBaseTest () Ġ{ ĊĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġsubmission Settings : ĠSubmission Settings ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġsubmission Service : ĠSubmission Service ĊĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġbackground Noise : ĠBackground Noise ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġapp Component : ĠApplication Component ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġtask Controller : ĠTask Controller ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġtek History Storage : ĠT EK History Storage ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġtime Stamp er : ĠTime Stamp er ĊĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġencrypted Preferences Factory : ĠEn crypted Preferences Factory ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġencryption Error Reset Tool : ĠEncryption Error Reset Tool ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġdead man Notification Scheduler : ĠDead man Notification Scheduler ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġanalytics Key Submission Collector : ĠAnalytics Key Submission Collector ĊĊĠĠĠ Ġprivate Ġval Ġguid Ġ= Ġ" 1 2 3 4 5 6 - 1 2 3 4 5 6 7 8 - 1 2 3 4 - 4 DA 7 - B 1 6 6 - B 8 6 D 8 5 4 7 5 0 6 4 " ĊĠĠĠ Ġprivate Ġval Ġtan Ġ= Ġ" 1 2 3 4 5 6 - 1 2 3 4 5 6 7 8 - 1 2 3 4 - 4 DA 7 - B 1 6 6 - B 8 6 D 8 5 4 7 5 0 6 4 " ĊĠĠĠ Ġprivate Ġval Ġregistration Token Ġ= Ġ" as dj n sk j fd ni ue wb he bo qu dn so jd ff " ĊĠĠĠ Ġprivate Ġval Ġtest Result Ġ= ĠTest Result . PENDING ĊĠĠĠ Ġprivate Ġval Ġregistration Data Ġ= ĠSubmission Service . Registration Data ( registration Token , Ġtest Result ) ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠMock K Annotations . init ( this ) ĊĊĠĠĠĠĠĠĠ Ġmock k Object ( App Injector ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠApp Injector . component Ġ} Ġreturns Ġapp Component ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġapp Component . encrypted Preferences Factory Ġ} Ġreturns Ġencrypted Preferences Factory ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġapp Component . error Reset Tool Ġ} Ġreturns Ġencryption Error Reset Tool ĊĊĠĠĠĠĠĠĠ Ġmock k Object ( Background Noise . Companion ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠBackground Noise . getInstance () Ġ} Ġreturns Ġbackground Noise ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġbackground Noise . schedule Dummy Pattern () Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġmock k Object ( Local Data ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . registration Token ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . device Pair ing Successful Timestamp ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . initial TestResult Received Timestamp () Ġ} Ġreturns Ġ 1 L ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġsubmission Settings . has Given Consent Ġ} Ġreturns Ġmock Flow Preference ( false ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġsubmission Settings . has View ed TestResult Ġ} Ġreturns Ġmock Flow Preference ( false ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġsubmission Settings . sy mptoms Ġ} Ġreturns Ġmock Flow Preference ( Sy mptoms . NO _ INFO _ G IV EN ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġsubmission Settings . clear () Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġtask Controller . tasks Ġ} Ġreturns Ġempty Flow () ĊĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġtek History Storage . clear () Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġtime Stamp er . now UTC Ġ} Ġreturns ĠInstant . EPOCH ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcreate Instance ( scope : ĠCor outine Scope ) Ġ= ĠSubmission Repository ( ĊĠĠĠĠĠĠĠ Ġscope Ġ= Ġscope , ĊĠĠĠĠĠĠĠ Ġsubmission Settings Ġ= Ġsubmission Settings , ĊĠĠĠĠĠĠĠ Ġsubmission Service Ġ= Ġsubmission Service , ĊĠĠĠĠĠĠĠ Ġtime Stamp er Ġ= Ġtime Stamp er , ĊĠĠĠĠĠĠĠ Ġtek History Storage Ġ= Ġtek History Storage , ĊĠĠĠĠĠĠĠ Ġdead man Notification Scheduler Ġ= Ġdead man Notification Scheduler , ĊĠĠĠĠĠĠĠ Ġanalytics Key Submission Collector Ġ= Ġanalytics Key Submission Collector ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Test From Device Suc ceeds () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . initial Polling For TestResult TimeStamp ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . initial TestResult Received Timestamp ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . is Allowed To Submit Di agnosis Keys ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . is TestResult Available Notification Sent ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ ĠLocal Data . numberOf Successful Sub missions ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġanalytics Key Submission Collector . reset () Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġsubmission Repository . remove Test From Device () ĊĊĠĠĠĠĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . registration Token ( null ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . device Pair ing Successful Timestamp ( 0 L ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . initial Polling For TestResult TimeStamp ( 0 L ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . initial TestResult Received Timestamp ( 0 L ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . is Allowed To Submit Di agnosis Keys ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . is TestResult Available Notification Sent ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . numberOf Successful Sub missions ( 0 ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġregistration With GUID Suc ceeds () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġsubmission Service . async Register Device Via GUID ( guid ) Ġ} Ġreturns Ġregistration Data ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġanalytics Key Submission Collector . report Test Registered () Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĊĠĠĠĠĠĠĠ Ġsubmission Repository . async Register Device Via GUID ( guid ) ĊĊĠĠĠĠĠĠĠ Ġverify Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . device Pair ing Successful Timestamp ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . registration Token ( registration Token ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbackground Noise . schedule Dummy Pattern () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubmission Repository . update TestResult ( test Result ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġregistration With Tele T AN Suc ceeds () Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġsubmission Service . async Register Device Via T AN ( tan ) Ġ} Ġreturns Ġregistration Data ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġanalytics Key Submission Collector . report Test Registered () Ġ} Ġjust ĠRuns ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġanalytics Key Submission Collector . report Registered With Tele T AN () Ġ} Ġjust ĠRuns ĊĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĊĠĠĠĠĠĠĠ Ġsubmission Repository . async Register Device Via T AN ( tan ) ĊĊĠĠĠĠĠĠĠ Ġco Verify Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . device Pair ing Successful Timestamp ( any ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLocal Data . registration Token ( registration Token ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbackground Noise . schedule Dummy Pattern () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubmission Repository . update TestResult ( test Result ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` reset Ġclears Ġtek Ġhistory Ġand Ġsettings `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġinstance Ġ= Ġcreate Instance ( this ) ĊĠĠĠĠĠĠĠ Ġinstance . reset () ĊĊĠĠĠĠĠĠĠ Ġinstance . device UIState Flow . first () ĠshouldBe ĠNetwork Request Wrapper . Request Idle ĊĊĠĠĠĠĠĠĠ Ġco Verify Order Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtek History Storage . clear () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsubmission Settings . clear () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ui Ġstate Ġis ĠSUB MIT TED _ FINAL Ġwhen Ġsubmission Ġwas Ġdone `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . submission Was Successful () Ġ} Ġreturns Ġtrue ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġsubmission Repository . device UIState Flow . first () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNetwork Request Wrapper . Request Successful ( Device UIState . SUBMIT TED _ FINAL ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ui Ġstate Ġis ĠUN P AI RED Ġwhen Ġno Ġtoken Ġis Ġpresent `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . submission Was Successful () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . registration Token () Ġ} Ġreturns Ġnull ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġsubmission Repository . device UIState Flow . first () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNetwork Request Wrapper . Request Successful ( Device UIState . UN P AI RED ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` ui Ġstate Ġis ĠP AI RED _ POSITIVE Ġwhen Ġallowed Ġto Ġsubmit `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . submission Was Successful () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . registration Token () Ġ} Ġreturns Ġ" token " ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . is Allowed To Submit Di agnosis Keys () Ġ} Ġreturns Ġtrue ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġsubmission Repository . device UIState Flow . first () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNetwork Request Wrapper . Request Successful ( Device UIState . P AI RED _ POSITIVE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` refresh Ġwhen Ġstate Ġis ĠP AI RED _ NO _ RESULT `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . submission Was Successful () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . registration Token () Ġ} Ġreturns Ġ" token " ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . is Allowed To Submit Di agnosis Keys () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġsubmission Service . async Request TestResult ( any ()) Ġ} Ġreturns ĠTest Result . PENDING ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġsubmission Repository . device UIState Flow . first () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNetwork Request Wrapper . Request Successful ( Device UIState . P AI RED _ NO _ RESULT ) ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġsubmission Service . async Request TestResult ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` refresh Ġwhen Ġstate Ġis ĠUN P AI RED `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . submission Was Successful () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . registration Token () Ġ} Ġreturns Ġnull ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . is Allowed To Submit Di agnosis Keys () Ġ} Ġreturns Ġfalse ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġsubmission Service . async Request TestResult ( any ()) Ġ} Ġreturns ĠTest Result . PENDING ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġsubmission Repository . device UIState Flow . first () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNetwork Request Wrapper . Request Successful ( Device UIState . UN P AI RED ) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . registration Token () Ġ} Ġreturns Ġ" token " ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġsubmission Service . async Request TestResult ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` no Ġrefresh Ġwhen Ġstate Ġis ĠSUB MIT TED _ FINAL `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ ĠLocal Data . submission Was Successful () Ġ} Ġreturns Ġtrue ĊĠĠĠĠĠĠĠ Ġval Ġsubmission Repository Ġ= Ġcreate Instance ( scope Ġ= Ġthis ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġsubmission Repository . device UIState Flow . first () ĠshouldBe ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNetwork Request Wrapper . Request Successful ( Device UIState . SUBMIT TED _ FINAL ) ĊĠĠĠĠĠĠĠ Ġsubmission Repository . refresh Device UIState () ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġsubmission Service . async Request TestResult ( any ()) Ġ} ĊĠĠĠ Ġ} Ċ } Ċ