package Ġcom . bad oo . common . ri bs . rx 2 Ċ Ċ import Ġandroid . view . ViewGroup Ċ import Ġcom . bad oo . ri bs . test . Interactor TestHelper Ċ import Ġcom . bad oo . ri bs . client helper . inter actor . Interactor Ċ import Ġcom . bad oo . ri bs . core . R ib Ċ import Ġcom . bad oo . ri bs . core . view . R ib View Ċ import Ġcom . bad oo . ri bs . rx 2 . client helper . connector . Connect able Ċ import Ġcom . jak ew h art on . rx relay 2 . Publish Relay Ċ import Ġcom . jak ew h art on . rx relay 2 . Relay Ċ import Ġio . reactivex . Observable Source Ċ import Ġio . reactivex . Observer Ċ import Ġorg . mockito . Argument Matchers . any Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito . mock Ċ import Ġorg . mockito . Mockito .` when ` Ġas Ġwhenever ĊĊ Ċ inline Ġfun Ġ< re ified ĠView , ĠView Event > Ġcreate Interactor TestHelper ( ĊĠĠĠ Ġinter actor : ĠInter actor < *, ĠView >, ĊĠĠĠ Ġview Event Relay : ĠRelay < View Event > Ċ ): ĠInter actor TestHelper < View > Ġwhere ĠView Ġ: ĠR ib View , ĠView Ġ: ĠObservable Source < View Event > Ġ{ ĊĠĠĠ Ġval Ġview : ĠView Ġ= Ġview Event Relay . subscribed View () ĊĠĠĠ Ġreturn ĠInter actor TestHelper ( inter actor , Ġ{ Ġview Ġ}) Ċ } Ċ Ċ inline Ġfun Ġ< re ified ĠR , Ġre ified ĠInput , Ġre ified ĠOutput > ĠInter actor < R , Ġ* >. mock IO ( ĊĠĠĠ Ġinput Relay : ĠRelay < Input > Ġ= ĠPublish Relay . create (), ĊĠĠĠ Ġoutput Relay : ĠRelay < Output > Ġ= ĠPublish Relay . create () Ċ ) Ġwhere ĠR Ġ: ĠR ib , ĠR Ġ: ĠConnect able < Input , ĠOutput > Ġ{ ĊĠĠĠ Ġval Ġ rib Ġ= Ġmock ( R :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġwhenever ( input ). thenReturn ( input Relay ) ĊĠĠĠĠĠĠĠ Ġwhenever ( output ). thenReturn ( output Relay ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġinit ( rib ) Ċ } Ċ Ċ inline Ġfun Ġ< re ified ĠR View , ĠView Event > ĠRelay < View Event >. subscribed View (): ĠR View Ġwhere ĠR View Ġ: ĠR ib View , ĠR View Ġ: ĠObservable Source < View Event > Ġ= ĊĠĠĠ Ġmock ( R View :: class . java ). apply Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito .` when `( this . android View ). thenReturn ( mock ( ViewGroup :: class . java )) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( this . subscribe ( any ())). then Answer Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġobserver Ġ= Ġit . get Argument < Observer < View Event >>( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis @ subscribed View . subscribe ( observer ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ