package Ġcom . mb ien ie k . facebook image picker . controllers Ċ Ċ import Ġandroid . support . v 7 . widget . RecyclerView Ċ import Ġcom . facebook . AccessToken Ċ import Ġcom . mb ien ie k . facebook image picker . Build Config Ċ import Ġcom . mb ien ie k . facebook image picker . Test Facebook Image Picker Application Ċ import Ġcom . mb ien ie k . facebook image picker . facebook . adapters . Facebook Image Adapter Ċ import Ġcom . mb ien ie k . facebook image picker . facebook . controllers . Facebook Image Picker Controller Ċ import Ġcom . mb ien ie k . facebook image picker . facebook . data . Facebook DataManager Ċ import Ġcom . mb ien ie k . facebook image picker . facebook . models . Facebook Picture Ċ import Ġcom . mb ien ie k . facebook image picker . util . Default Config Ċ import Ġcom . mb ien ie k . facebook image picker . util . Rx Schedulers Override Rule Ċ import Ġio . reactivex . Observable Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . annotation . Config Ċ import Ġjunit . framework . Assert . assertEquals Ċ import Ġorg . junit . Rule Ċ import Ġorg . mockito . Mockito .* Ċ import Ġorg . mockito . junit . Mockito JUnit ĊĊ Ċ /** Ċ Ġ* ĠCreated Ġby Ġm ichael bi enie k Ġon Ġ 3 / 3 0 / 1 8 . Ċ Ġ*/ Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ @ Config ( constants Ġ= ĠBuild Config :: class , Ġsdk Ġ= Ġ[ Default Config . EM UL ATE _ SDK ], Ġapplication Ġ= ĠTest Facebook Image Picker Application :: class ) Ċ class ĠFacebook Image Picker Controller Test Ġ{ ĊĊĠĠĠ Ġ@ Rule Ġ@ Jvm Field ĊĠĠĠ Ġvar Ġrule Ġ= ĠMockito JUnit . rule () ĊĊĠĠĠ Ġ@ Rule Ġ@ Jvm Field ĊĠĠĠ Ġval Ġoverride Schedulers Rule Ġ= ĠRx Schedulers Override Rule () ĊĊĠĠĠ Ġlateinit Ġvar Ġcontroller : ĠFacebook Image Picker Controller ĊĠĠĠ Ġvar Ġdata Manager Mock Ġ: ĠFacebook DataManager Ġ= Ġmock ( Facebook DataManager :: class . java ) ĊĠĠĠ Ġvar Ġimage Selected Listener Param Ġ= Ġ 0 ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġcontroller Ġ= Ġspy ( Facebook Image Picker Controller (" 1 2 3 ", Ġobject Ġ: ĠFacebook Image Adapter . Image Selected Listener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġimage Selected List Updated ( numberOf Images Selected : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġimage Selected Listener Param Ġ= ĠnumberOf Images Selected ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ})) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest BindView () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġre cyclerView Ġ= Ġmock ( RecyclerView :: class . java ) ĊĠĠĠĠĠĠĠ Ġcontroller . bind View ( re cyclerView ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( re cyclerView , Ġcontroller . facebook Image RecyclerView ) ĊĠĠĠĠĠĠĠ Ġverify ( re cyclerView ). setAdapter ( controller . facebook Image Adapter ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Load P ictures () Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠaccessToken Ġ= ĠAccess Token (" test ", Ġ" test ", Ġ" test ", Ġnull , Ġnull , Ġnull , Ġnull , Ġnull , Ġnull ) ĊĠĠĠĠĠĠĠ Ġval Ġresult List Ġ= ĠArrayList < Facebook Picture >() ĊĠĠĠĠĠĠĠ Ġresult List . add ( Facebook Picture (" preview Url ", Ġ" source Url ", Ġ" 1 2 3 ")) ĊĠĠĠĠĠĠĠ Ġresult List . add ( Facebook Picture (" preview Url 2 ", Ġ" source Url 2 ", Ġ" 4 5 6 ")) ĊĠĠĠĠĠĠĠ Ġcontroller . facebook DataManager Ġ= Ġdata Manager Mock ĊĠĠĠĠĠĠĠ Ġdo Return ( accessToken ). ` when `( controller ). get AccessToken () ĊĠĠĠĠĠĠĠ Ġ` when `( data Manager Mock . request P ictures (" 1 2 3 ", ĠaccessToken )). thenReturn ( Observable . just ( result List )) ĊĊĠĠĠĠĠĠĠ Ġcontroller . load P ictures () ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( 2 , Ġcontroller . facebook Image Adapter . item Count ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( true , Ġcontroller . facebook Image Adapter . selected ImageList . isEmpty ()) ĊĠĠĠ Ġ} Ċ }