package Ġbr . com . rail an x isto . ch uck facts Ċ Ċ import Ġbr . com . rail an x isto . ch uck facts . data . remote . Ch uck Fact s Service Ċ import Ġbr . com . rail an x isto . ch uck facts . data . remote . model . Fact s Response Ċ import Ġbr . com . rail an x isto . ch uck facts . domain . Fact Ċ import Ġio . reactivex . Single Ċ import Ġokhttp 3 . MediaType Ċ import Ġokhttp 3 . ResponseBody Ċ import Ġorg . mockito . Mockito Ċ import Ġretrofit 2 . Response Ċ Ċ class ĠMock Service ( private Ġval Ġch uck Fact s Service : ĠCh uck Fact s Service ) Ġ{ ĊĊĠĠĠ Ġval ĠQUERY Ġ= Ġ" food " ĊĠĠĠ Ġval ĠQUERY _ EMPTY Ġ= Ġ" QUERY _ EMPTY " ĊĠĠĠ Ġval ĠQUERY _ ERROR Ġ= Ġ" QUERY _ ERROR " ĊĊĠĠĠ Ġval ĠlistOf Categories Ġ= ĠlistOf (" food ", Ġ" dev ") ĊĠĠĠ Ġval ĠlistOf Fact s Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠFact (" 1 ", Ġ" url ", Ġ" Fact ", Ġnull , Ġ" icon "), ĊĠĠĠĠĠĠĠ ĠFact (" 2 ", Ġ" url ", Ġ" Fact 2 ", ĠlistOf (" food "), Ġ" icon ") ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Response Of Fact s () ĊĠĠĠĠĠĠĠ Ġmock Response Of Get Categories () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmock Response Of Fact s () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠResponse . success ( Fact s Response ( 2 , ĠlistOf Fact s )) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Empty Ġ= ĠResponse . success ( Fact s Response ( 2 , ĠlistOf ())) ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected ResponseBody Ġ= ĠResponse Body . create ( MediaType . get (" text / plain "), Ġ" Internal Ġserver Ġerror ") ĊĠĠĠĠĠĠĠ Ġval Ġerror Response Ġ= ĠResponse . error < Fact s Response >( 5 0 0 , Ġexpected ResponseBody ) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( ch uck Fact s Service . get Fact s ( QUERY )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Single . just ( response )) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( ch uck Fact s Service . get Fact s ( QUERY _ EMPTY )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Single . just ( response Empty )) ĊĊĠĠĠĠĠĠĠ ĠMockito .` when `( ch uck Fact s Service . get Fact s ( QUERY _ ERROR )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Single . just ( error Response )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġmock Response Of Get Categories () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito .` when `( ch uck Fact s Service . getC ategories ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Single . just ( listOf Categories )) ĊĠĠĠ Ġ} Ċ }