package Ġcom . j ep pe man . glob ally dynamic . server Ċ Ċ import Ġcom . android . bundle . Devices Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . google . gson . Gson Ċ import Ġcom . j ep pe man . glob ally dynamic . server . extensions . delete Comp let ely Ċ import Ġcom . j ep pe man . glob ally dynamic . server . extensions . unzip Ċ 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 . spy Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġorg . junit . jupiter . api . After Each Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . junit . jupiter . api . io . TempDir Ċ import Ġorg . junit . platform . runner . JUnit Platform Ċ import Ġorg . junit . runner . RunWith Ċ import Ġjava . nio . file . Path Ċ Ċ @ RunWith ( JUnit Platform :: class ) Ċ class ĠBundle ManagerImpl Test Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbundle Manager : ĠBundle ManagerImpl ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġspy Storage Backend : ĠStorage Backend ĊĠĠĠ Ġ@ TempDir ĊĠĠĠ Ġlateinit Ġvar Ġtemp Dir : ĠPath ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġspy Storage Backend Ġ= Ġspy ( LocalStorage Backend ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Base Storage Path ( temp Dir ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build ()) ĊĠĠĠĠĠĠĠ Ġbundle Manager Ġ= Ġspy ( Bundle ManagerImpl ( Gson (), Ġspy Storage Backend , ĠLogger (), Ġfalse )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After Each ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġtemp Dir . delete Comp let ely () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Features And Languages Are Empty _ generate Compressed Spl its Should Return Missing Features And Languages Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompressed Spl its Result Ġ= Ġbundle Manager . generate Compressed Spl its ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Id Ġ= Ġ" application Id ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġversion Ġ= Ġ 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvariant Ġ= Ġ" variant ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevice Spec Ġ= ĠDevices . Device Spec . getDefaultInstance (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlanguages Ġ= ĠarrayOf (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Ġ= ĠarrayOf (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinclude Missing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compressed Spl its Result ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Bundle Manager . Result . Error . Missing Features And Languages :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Bundle DoesNotExist _ generate Compressed Spl its Should Return Bundle NotFoundError () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompressed Spl its Result Ġ= Ġbundle Manager . generate Compressed Spl its ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Id Ġ= Ġ" application Id ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġversion Ġ= Ġ 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvariant Ġ= Ġ" variant ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevice Spec Ġ= ĠDevices . Device Spec . getDefaultInstance (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlanguages Ġ= ĠarrayOf (""), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Ġ= ĠarrayOf (""), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinclude Missing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compressed Spl its Result ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Bundle Manager . Result . Error . Bundle NotFound :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwhen Signing Config DoesNotExist _ generate Compressed Spl its Should Return Signing Config NotFoundError () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompressed Spl its Result Ġ= Ġbundle Manager . generate Compressed Spl its ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Id Ġ= Ġ" application Id ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġversion Ġ= Ġ 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvariant Ġ= Ġ" variant ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevice Spec Ġ= ĠDevices . Device Spec . getDefaultInstance (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlanguages Ġ= ĠarrayOf (""), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Ġ= ĠarrayOf (""), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinclude Missing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( compressed Spl its Result ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. isInstanceOf ( Bundle Manager . Result . Error . Bundle NotFound :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgenerate Compressed Spl its _ should Generate Spl its By Languages And Features () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġapplication Id Ġ= Ġ" application " ĊĠĠĠĠĠĠĠ Ġval Ġversion Ġ= Ġ 2 3 ĊĠĠĠĠĠĠĠ Ġval Ġvariant Ġ= Ġ" variant " ĊĠĠĠĠĠĠĠ Ġval Ġsigning Config Ġ= Ġ"{ store Password : Ġ\" pass \", Ġkey Password : Ġ\" key pass \", Ġkey Alias : Ġ\" key alias \" }" ĊĠĠĠĠĠĠĠ Ġval Ġfake Bundle Ġ= Ġtemp Dir . resolve (" bundle . aab "). to File (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwrite Text (" Hi , ĠI Ġam Ġa Ġlittle Ġbundle ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġfake Ke yst ore Ġ= Ġtemp Dir . resolve (" bundle . keystore "). to File (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwrite Text (" Hi , ĠI Ġam Ġa Ġlittle Ġkeystore ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġunzip Dir Ġ= Ġtemp Dir . resolve (" un z ipped _ ap ks ") ĊĠĠĠĠĠĠĠ Ġval Ġfiles Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemp Dir . resolve (" base - se . apk "). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġto File (). write Text (" file 1 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemp Dir . resolve (" feature - master . apk "). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġto File (). write Text (" file 2 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtemp Dir . resolve (" file 3 "). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġto File (). write Text (" file 3 ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġap ks Ġ= Ġtemp Dir . resolve (" temp . ap ks "). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġto File (). write Text (" ap ks ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġdo Return ( ap ks ). wh enever ( bundle Manager ). build A pk s ( any (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany ()) ĊĠĠĠĠĠĠĠ Ġdo Return ( files ). wh enever ( bundle Manager ). extract A pk s ( any (), Ġany (), Ġany (), Ġany ()) ĊĠĠĠĠĠĠĠ Ġbundle Manager . store Bundle ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġversion , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvariant , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsigning Config , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfake Bundle . inputStream (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfake Ke yst ore . inputStream () ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġval Ġcompressed Spl its Result Ġ= Ġbundle Manager . generate Compressed Spl its ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapplication Id Ġ= Ġapplication Id , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġversion Ġ= Ġversion , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġvariant Ġ= Ġvariant , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdevice Spec Ġ= ĠDevices . Device Spec . getDefaultInstance (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlanguages Ġ= ĠarrayOf (" se "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfeatures Ġ= ĠarrayOf (" feature "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinclude Missing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ) Ġas ĠBundle Manager . Result . Success ĊĠĠĠĠĠĠĠ Ġcompressed Spl its Result . path . to File (). unzip ( unzip Dir . toString ()) ĊĠĠĠĠĠĠĠ Ġval Ġun z ipped Spl its Ġ= Ġunzip Dir . to File (). list Files () !!. toList (). map Ġ{ Ġit . read Text () Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertThat ( un z ipped Spl its ). contains (" file 1 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( un z ipped Spl its ). contains (" file 2 ") ĊĠĠĠĠĠĠĠ ĠassertThat ( un z ipped Spl its ). does Not Contain (" file 3 ") ĊĠĠĠ Ġ} Ċ } ĊĊ