package Ġde . r ki . cor on aw arn app . contact di ary . retention Ċ Ċ import Ġde . r ki . cor on aw arn app . contact di ary . model . Contact Di ary Location Visit Ċ import Ġde . r ki . cor on aw arn app . contact di ary . model . Contact Di ary Person Encounter Ċ import Ġde . r ki . cor on aw arn app . contact di ary . storage . repo . Default Contact Di ary Repository Ċ import Ġde . r ki . cor on aw arn app . util . TimeStamp er Ċ import Ġio . kot est . matchers . shouldBe Ċ import Ġio . mock k . Mock K Annotations Ċ import Ġio . mock k . clear All Mocks Ċ import Ġio . mock k . co Every Ċ import Ġio . mock k . co Verify Ċ import Ġio . mock k . every Ċ import Ġio . mock k . impl . annotations . Mock K Ċ import Ġio . mock k . just Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . runs Ċ import Ġkotlinx . coroutines . flow . flow Of Ċ import Ġkotlinx . coroutines . test . run Blocking Test Ċ import Ġorg . joda . time . Instant Ċ import Ġorg . joda . time . LocalDate Ċ import Ġorg . junit . jupiter . api . After Each Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġtest helpers . Base Test Ċ Ċ class ĠContact Di ary Data Retention Calculation Test Ġ: ĠBaseTest () Ġ{ ĊĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġtime Stamp er : ĠTime Stamp er ĊĠĠĠ Ġ@ Mock K Ġlateinit Ġvar Ġcontact Di ary Repository : ĠDefault Contact Di ary Repository ĊĊĠĠĠ Ġprivate Ġval Ġtest Dates Ġ= Ġarray ListOf < String >(" 2 0 2 0 - 0 8 - 2 0 T 1 4 : 0 0 : 0 0 . 0 0 0 Z ", ĊĠĠĠĠĠĠĠ Ġ" 2 0 2 0 - 0 8 - 2 0 T 1 3 : 0 0 : 0 0 . 0 0 0 Z ", ĊĠĠĠĠĠĠĠ Ġ" 2 0 2 0 - 0 8 - 1 9 T 1 4 : 0 0 : 0 0 . 0 0 0 Z ", ĊĠĠĠĠĠĠĠ Ġ" 2 0 2 0 - 0 8 - 0 5 T 1 4 : 0 0 : 0 0 . 0 0 0 Z ", ĊĠĠĠĠĠĠĠ Ġ" 2 0 2 0 - 0 8 - 0 4 T 1 4 : 0 0 : 0 0 . 0 0 0 Z ", ĊĠĠĠĠĠĠĠ Ġ" 2 0 2 0 - 0 8 - 0 3 T 1 4 : 0 0 : 0 0 . 0 0 0 Z " ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ ĠMock K Annotations . init ( this ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġtime Stamp er . now UTC Ġ} Ġreturns ĠInstant . parse (" 2 0 2 0 - 0 8 - 2 0 T 2 3 : 0 0 : 0 0 . 0 0 0 Z ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After Each ĊĠĠĠ Ġfun Ġteardown () Ġ{ ĊĠĠĠĠĠĠĠ Ġclear All Mocks () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Instance () Ġ= ĠContact Di ary Retention Calculation ( ĊĠĠĠĠĠĠĠ Ġtime Stamp er Ġ= Ġtime Stamp er , ĊĠĠĠĠĠĠĠ Ġrepository Ġ= Ġcontact Di ary Repository ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġdays Ġdiff `() Ġ{ ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġtime Stamp er . now UTC Ġ} Ġreturns ĠInstant . parse (" 2 0 2 0 - 0 8 - 2 0 T 1 4 : 0 0 : 0 0 . 0 0 0 Z ") ĊĊĠĠĠĠĠĠĠ Ġval Ġinstance Ġ= Ġcreate Instance () ĊĊĠĠĠĠĠĠĠ Ġinstance . get Days Diff ( LocalDate ( Instant . parse (" 2 0 2 0 - 0 8 - 2 0 T 1 4 : 0 0 : 0 0 . 0 0 0 Z "))) ĠshouldBe Ġ 0 ĊĠĠĠĠĠĠĠ Ġinstance . get Days Diff ( LocalDate ( Instant . parse (" 2 0 2 0 - 0 8 - 2 0 T 1 3 : 0 0 : 0 0 . 0 0 0 Z "))) ĠshouldBe Ġ 0 ĊĠĠĠĠĠĠĠ Ġinstance . get Days Diff ( LocalDate ( Instant . parse (" 2 0 2 0 - 0 8 - 1 9 T 1 4 : 0 0 : 0 0 . 0 0 0 Z "))) ĠshouldBe Ġ 1 ĊĠĠĠĠĠĠĠ Ġinstance . get Days Diff ( LocalDate ( Instant . parse (" 2 0 2 0 - 0 8 - 0 5 T 1 4 : 0 0 : 0 0 . 0 0 0 Z "))) ĠshouldBe Ġ 1 5 ĊĠĠĠĠĠĠĠ Ġinstance . get Days Diff ( LocalDate ( Instant . parse (" 2 0 2 0 - 0 8 - 0 4 T 1 4 : 0 0 : 0 0 . 0 0 0 Z "))) ĠshouldBe Ġ 1 6 ĊĠĠĠĠĠĠĠ Ġinstance . get Days Diff ( LocalDate ( Instant . parse (" 2 0 2 0 - 0 8 - 0 3 T 1 4 : 0 0 : 0 0 . 0 0 0 Z "))) ĠshouldBe Ġ 1 7 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġlocation Ġvisit Ġdeletion `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlist : ĠList < Contact Di ary Location Visit > Ġ= Ġtest Dates . map Ġ{ Ġcreate Contact Di ary Location Visit ( Instant . parse ( it )) Ġ} ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcontact Di ary Repository . location Vis its Ġ} Ġreturns Ġflow Of ( list ) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġcontact Di ary Repository . delete Location Vis its ( any ()) Ġ} Ġjust Ġruns ĊĊĠĠĠĠĠĠĠ Ġval Ġinstance Ġ= Ġcreate Instance () ĊĠĠĠĠĠĠĠ Ġinstance . filter Contact Di ary Location Vis its ( list ). size ĠshouldBe Ġ 1 ĊĊĠĠĠĠĠĠĠ Ġinstance . clear Obsolete Contact Di ary Location Vis its () ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġcontact Di ary Repository . delete Location Vis its ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Contact Di ary Location Visit ( date : ĠInstant ): ĠContact Di ary Location Visit Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlocation Visit : ĠContact Di ary Location Visit Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġlocation Visit . date Ġ} Ġreturns ĠLocalDate ( date ) ĊĠĠĠĠĠĠĠ Ġreturn Ġlocation Visit ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` test Ġperson Ġencounter s `() Ġ= Ġrun Blocking Test Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlist : ĠList < Contact Di ary Person Encounter > Ġ= Ġtest Dates . map Ġ{ Ġcreate Contact Di ary Person Encounter ( Instant . parse ( it )) Ġ} ĊĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġcontact Di ary Repository . person En counters Ġ} Ġreturns Ġflow Of ( list ) ĊĠĠĠĠĠĠĠ Ġco Every Ġ{ Ġcontact Di ary Repository . delete Person En counters ( any ()) Ġ} Ġjust Ġruns ĊĊĠĠĠĠĠĠĠ Ġval Ġinstance Ġ= Ġcreate Instance () ĊĠĠĠĠĠĠĠ Ġinstance . filter Contact Di ary Person En counters ( list ). size ĠshouldBe Ġ 1 ĊĠĠĠĠĠĠĠ Ġinstance . clear Obsolete Contact Di ary Person En counters () ĊĠĠĠĠĠĠĠ Ġco Verify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġcontact Di ary Repository . delete Person En counters ( any ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Contact Di ary Person Encounter ( date : ĠInstant ): ĠContact Di ary Person Encounter Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġperson Encounter : ĠContact Di ary Person Encounter Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġperson Encounter . date Ġ} Ġreturns ĠLocalDate ( date ) ĊĠĠĠĠĠĠĠ Ġreturn Ġperson Encounter ĊĠĠĠ Ġ} Ċ } Ċ