package Ġwatch . craft Ċ Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . any Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . do Return Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . stub Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . jupiter . api . Assertions . assertEquals Ċ import Ġorg . junit . jupiter . api . Nested Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġwatch . craft . storage . Object Store Ċ Ċ class ĠStorage Structure Test Ġ{ ĊĠ Ġprivate Ġval Ġfirst Level Ġ= Ġmock < Object Store >() ĊĠ Ġprivate Ġval Ġsecond Level Ġ= Ġmock < Object Store >() ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass ĠNo Force Download Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` no Ġexisting Ġentries Ġfor Ġtoday `() Ġ{ ĊĠĠĠĠĠ Ġmock Listing ( emptyList ()) ĊĊĠĠĠĠĠ Ġval Ġstructure Ġ= Ġcreate Structure ( false ) ĊĊĠĠĠĠĠ ĠassertEquals ("/ downloads / foo / 2 0 2 0 - 0 1 - 0 1 ", Ġget Downloads Path ( structure )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` one Ġexisting Ġentry Ġfor Ġtoday `() Ġ{ ĊĠĠĠĠĠ Ġmock Listing ( listOf (" 2 0 2 0 - 0 1 - 0 1 ")) ĊĊĠĠĠĠĠ Ġval Ġstructure Ġ= Ġcreate Structure ( false ) ĊĊĠĠĠĠĠ ĠassertEquals ("/ downloads / foo / 2 0 2 0 - 0 1 - 0 1 ", Ġget Downloads Path ( structure )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` multiple Ġexisting Ġentries Ġfor Ġtoday `() Ġ{ ĊĠĠĠĠĠ Ġmock Listing ( listOf (" 2 0 2 0 - 0 1 - 0 1 -- 0 0 1 ", Ġ" 2 0 2 0 - 0 1 - 0 1 ")) ĊĊĠĠĠĠĠ Ġval Ġstructure Ġ= Ġcreate Structure ( false ) ĊĊĠĠĠĠĠ ĠassertEquals ("/ downloads / foo / 2 0 2 0 - 0 1 - 0 1 -- 0 0 1 ", Ġget Downloads Path ( structure )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass ĠForce Download Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` no Ġexisting Ġentries Ġfor Ġtoday `() Ġ{ ĊĠĠĠĠĠ Ġmock Listing ( emptyList ()) ĊĊĠĠĠĠĠ Ġval Ġstructure Ġ= Ġcreate Structure ( true ) ĊĊĠĠĠĠĠ ĠassertEquals ("/ downloads / foo / 2 0 2 0 - 0 1 - 0 1 ", Ġget Downloads Path ( structure )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` one Ġexisting Ġentry Ġfor Ġtoday `() Ġ{ ĊĠĠĠĠĠ Ġmock Listing ( listOf (" 2 0 2 0 - 0 1 - 0 1 ")) ĊĊĠĠĠĠĠ Ġval Ġstructure Ġ= Ġcreate Structure ( true ) ĊĊĠĠĠĠĠ ĠassertEquals ("/ downloads / foo / 2 0 2 0 - 0 1 - 0 1 -- 0 0 1 ", Ġget Downloads Path ( structure )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` multiple Ġexisting Ġentries Ġfor Ġtoday `() Ġ{ ĊĠĠĠĠĠ Ġmock Listing ( listOf (" 2 0 2 0 - 0 1 - 0 1 -- 0 0 1 ", Ġ" 2 0 2 0 - 0 1 - 0 1 ")) ĊĊĠĠĠĠĠ Ġval Ġstructure Ġ= Ġcreate Structure ( true ) ĊĊĠĠĠĠĠ ĠassertEquals ("/ downloads / foo / 2 0 2 0 - 0 1 - 0 1 -- 0 0 2 ", Ġget Downloads Path ( structure )) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmock Listing ( entries : ĠList < String >) Ġ= Ġsecond Level . stub Ġ{ ĊĠĠĠ Ġon Blocking Ġ{ Ġlist ( any ()) Ġ} Ġdo Return Ġentries ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġget Downloads Path ( structure : ĠStorage Structure ) Ġ= Ġrun Blocking Ġ{ Ġstructure . downloads (" foo "). path Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Structure ( force Download : ĠBoolean ) Ġ= ĠStorage Structure ( ĊĠĠĠ Ġdate String Ġ= Ġ" 2 0 2 0 - 0 1 - 0 1 ", ĊĠĠĠ Ġforce Download Ġ= Ġforce Download , ĊĠĠĠ Ġlocal Store Ġ= Ġfirst Level , ĊĠĠĠ Ġremote Store Ġ= Ġsecond Level ĊĠ Ġ) Ċ } Ċ