package Ġhu . k rist of . n agy . hi ke book client . view . groups Ċ Ċ import Ġandroidx . core . os . bundle Of Ċ import Ġandroidx . navigation . Nav Controller Ċ import Ġandroidx . navigation . Navigation Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . contrib . RecyclerView Actions Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Medium Test Ċ import Ġdagger . h ilt . android . testing . Bind Value Ċ import Ġdagger . h ilt . android . testing . H ilt Android Rule Ċ import Ġdagger . h ilt . android . testing . H ilt Android Test Ċ import Ġdagger . h ilt . android . testing . Un install Modules Ċ import Ġhu . k rist of . n agy . hi ke book client . R Ċ import Ġhu . k rist of . n agy . hi ke book client . data . repository . IG roup s Repository Ċ import Ġhu . k rist of . n agy . hi ke book client . di . Groups Repository Module Ċ import Ġhu . k rist of . n agy . hi ke book client . launch Fragment In H ilt Container Ċ import Ġhu . k rist of . n agy . hi ke book client . model . Server Response Result Ċ import Ġhu . k rist of . n agy . hi ke book client . util . Constants Ċ import Ġhu . k rist of . n agy . hi ke book client . util . Data Binding Id ling Resource Ċ import Ġhu . k rist of . n agy . hi ke book client . util . Data Binding Id ling Resource Rule Ċ import Ġkotlinx . coroutines . flow . flow Of Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . kotlin . do Return Ċ import Ġorg . mockito . kotlin . mock Ċ import Ġorg . mockito . kotlin . verify Ċ Ċ @ Un install Modules ( Groups Repository Module :: class ) Ċ @ H ilt Android Test Ċ @ Medium Test Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠGroups List Fragment Test Ġ{ ĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġh ilt Rule Ġ= ĠH ilt Android Rule ( this ) ĊĊĠĠĠ Ġprivate Ġval Ġdata Binding Id ling Resource Ġ= ĠData Binding Id ling Resource () ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġdata Binding Id ling Resource Rule Ġ= ĠData Binding Id ling Resource Rule ( data Binding Id ling Resource ) ĊĊĠĠĠ Ġ@ Bind Value ĊĠĠĠ Ġlateinit Ġvar Ġgroups Repository : ĠI Groups Repository ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck List () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Connected Page Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġval Ġgroup 1 Ġ= Ġ" group 1 " ĊĠĠĠĠĠĠĠ Ġval Ġgroup 2 Ġ= Ġ" group 2 " ĊĠĠĠĠĠĠĠ Ġgroups Repository Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlist Groups For LoggedIn User ( isConnected Page ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġdo Return Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠServer Response Result ( true , Ġnull , ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġgroup 1 , Ġgroup 2 ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= Ġbundle Of ( Constants . IS _ CONNECTED _ PAGE _ B UNDLE _ KEY Ġto Ġis Connected Page ) ĊĠĠĠĠĠĠĠ Ġlaunch Fragment In H ilt Container < Groups List Fragment >( bundle , Ġdata Binding Id ling Resource ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . groups RecyclerView )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Child ( with Id ( R . id . groups ListItem GroupName Tv ))))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Child ( with Text ( group 1 ))))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Child ( with Text ( group 2 ))))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Child ( with Id ( R . id . groups ListItem Button ))))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Child ( with Text ( R . string . leave _ text ))))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( has Desc endant ( with Child ( is Clickable ())) )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Not Connected Page General Connect Button () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Connected Page Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġval Ġgroup 1 Ġ= Ġ" group 1 " ĊĠĠĠĠĠĠĠ Ġgroups Repository Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlist Groups For LoggedIn User ( isConnected Page ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġdo Return Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠServer Response Result ( true , Ġnull , ĠlistOf ( group 1 )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= Ġbundle Of ( Constants . IS _ CONNECTED _ PAGE _ B UNDLE _ KEY Ġto Ġis Connected Page ) ĊĠĠĠĠĠĠĠ Ġlaunch Fragment In H ilt Container < Groups List Fragment >( bundle , Ġdata Binding Id ling Resource ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . groups ListItem Button )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Text ( R . string . join _ text ))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġverify Detail Nav () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Connected Page Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġval Ġgroup 1 Ġ= Ġ" group 1 " ĊĠĠĠĠĠĠĠ Ġval Ġgroup 2 Ġ= Ġ" group 2 " ĊĠĠĠĠĠĠĠ Ġgroups Repository Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlist Groups For LoggedIn User ( isConnected Page ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġdo Return Ġflow Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠServer Response Result ( true , Ġnull , ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġgroup 1 , Ġgroup 2 ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= Ġbundle Of ( Constants . IS _ CONNECTED _ PAGE _ B UNDLE _ KEY Ġto Ġis Connected Page ) ĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= ĠMockito . mock ( Nav Controller :: class . java ) ĊĠĠĠĠĠĠĠ Ġlaunch Fragment In H ilt Container < Groups List Fragment >( bundle , Ġdata Binding Id ling Resource ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . setView Nav Controller ( this . view !! , Ġnav Controller ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . groups RecyclerView )). perform ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRecyclerView Actions . action On Item At Position < Groups ListAdapter . ViewHolder >( 0 , Ġclick ()) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġdirections 1 Ġ= ĠGroups Fragment Directions ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. action Groups Fragment To Groups Detail Fragment ( group 1 , Ġis Connected Page ) ĊĠĠĠĠĠĠĠ Ġverify ( nav Controller ). navigate ( directions 1 ) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . groups RecyclerView )). perform ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRecyclerView Actions . action On Item At Position < Groups ListAdapter . ViewHolder >( 1 , Ġclick ()) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġdirections 2 Ġ= ĠGroups Fragment Directions ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. action Groups Fragment To Groups Detail Fragment ( group 2 , Ġis Connected Page ) ĊĠĠĠĠĠĠĠ Ġverify ( nav Controller ). navigate ( directions 2 ) ĊĠĠĠ Ġ} Ċ }