package Ġcom . radix d lt . client . core . network Ċ Ċ import Ġio . reactivex . Single Ċ import Ġio . reactivex . ob servers . Test Observer Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . mock Ċ import Ġjava . io . IOException Ċ Ċ class ĠPe ers From Seed Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Find Peers () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpeer Ġ= Ġmock ( Rad ix Peer :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġclient Ġ= Ġmock ( Rad ix Json Rpc Client :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġdata Ġ= Ġmock ( Node Runner Data :: class . java ) ĊĠĠĠĠĠĠĠ Ġ` when `( peer . radix Client ). thenReturn ( client ) ĊĠĠĠĠĠĠĠ Ġ` when `( peer . location ). thenReturn (" some where ") ĊĠĠĠĠĠĠĠ Ġ` when `( client . self ). thenReturn ( Single . just ( data )) ĊĠĠĠĠĠĠĠ Ġ` when `( client . live Peers ). thenReturn ( Single . just ( emptyList ())) ĊĊĠĠĠĠĠĠĠ Ġval Ġtest Observer Ġ= ĠTest Observer . create < Rad ix Peer >() ĊĠĠĠĠĠĠĠ Ġval Ġpeers From Seed Ġ= ĠPe ers From Seed ( peer ) ĊĠĠĠĠĠĠĠ Ġpeers From Seed . find Peers (). subscribe ( test Observer ) ĊĊĠĠĠĠĠĠĠ Ġtest Observer . assert Value Ġ{ Ġp Ġ-> Ġp . location Ġ== Ġ" some where " Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Find Peers Fail () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpeer Ġ= Ġmock ( Rad ix Peer :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġclient Ġ= Ġmock ( Rad ix Json Rpc Client :: class . java ) ĊĠĠĠĠĠĠĠ Ġ` when `( peer . radix Client ). thenReturn ( client ) ĊĠĠĠĠĠĠĠ Ġ` when `( peer . location ). thenReturn (" some where ") ĊĠĠĠĠĠĠĠ Ġ` when `( client . self ). thenReturn ( Single . error ( IOException ())) ĊĠĠĠĠĠĠĠ Ġ` when `( client . live Peers ). thenReturn ( Single . error ( IOException ())) ĊĊĠĠĠĠĠĠĠ Ġval Ġtest Observer Ġ= ĠTest Observer . create < Rad ix Peer >() ĊĠĠĠĠĠĠĠ Ġval Ġpeers From Seed Ġ= ĠPe ers From Seed ( peer ) ĊĠĠĠĠĠĠĠ Ġpeers From Seed . find Peers (). subscribe ( test Observer ) ĊĊĠĠĠĠĠĠĠ Ġtest Observer . assert Error Ġ{ Ġe Ġ-> Ġe Ġis ĠIOException Ġ} ĊĠĠĠ Ġ} Ċ } Ċ