package Ġeu . w aw r zy c ze k . find fl ights . fl ights . search Ċ Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġeu . w aw r zy c ze k . find fl ights . common . Simple Date Ċ import Ġeu . w aw r zy c ze k . find fl ights . common . Simple DateTime Ċ import Ġeu . w aw r zy c ze k . find fl ights . fl ights . model . F are Type Ċ import Ġeu . w aw r zy c ze k . find fl ights . fl ights . model . Flight Ċ import Ġeu . w aw r zy c ze k . find fl ights . fl ights . model . Price Ċ import Ġeu . w aw r zy c ze k . find fl ights . fl ights . search . dto .* Ċ import Ġeu . w aw r zy c ze k . find fl ights . search . model . Search Data Ċ import Ġeu . w aw r zy c ze k . find fl ights . search . model . Station Ċ import Ġio . reactivex . Single Ċ import Ġorg . junit . Test Ċ import Ġjava . math . BigDecimal Ċ import Ġjava . util .* Ċ Ċ class ĠSearch Repository Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġf are Dto A Ġ= ĠF are Dto ( F are Type . CH D , Ġ 5 , ĠBigDecimal ( 1 2 ), Ġ 2 0 ) ĊĠĠĠ Ġprivate Ġval Ġf are Dto B Ġ= ĠF are Dto ( F are Type . AD T , Ġ 1 , ĠBigDecimal ( 1 5 ), Ġ 2 5 ) ĊĠĠĠ Ġprivate Ġval Ġregular F are Ġ= ĠRegular F are Dto (" W ", ĠlistOf ( f are Dto A , Ġf are Dto B )) ĊĠĠĠ Ġprivate Ġval Ġflight Dto Ġ= ĠFlight Dto ( 1 , Ġ 1 , Ġregular F are , Ġ" NR ", Ġ" 1 2 : 3 0 ") ĊĠĠĠ Ġprivate Ġval Ġtrip Date Dto Ġ= ĠTrip Date Dto ( Date ( 0 ), ĠlistOf ( flight Dto )) ĊĠĠĠ Ġprivate Ġval Ġtrip Dto A Ġ= ĠTrip Dto (" A ", Ġ" AA ", Ġ" B ", Ġ" BB ", ĠlistOf ( trip Date Dto )) ĊĠĠĠ Ġprivate Ġval Ġtrip Dto B Ġ= ĠTrip Dto (" C ", Ġ" CC ", Ġ" D ", Ġ" DD ", ĠlistOf ( trip Date Dto )) ĊĠĠĠ Ġprivate Ġval Ġfl ights Dto Ġ= ĠF lights Dto (" PL N ", ĠlistOf ( trip Dto A , Ġtrip Dto B )) ĊĠĠĠ Ġprivate Ġval Ġsearch Data Ġ= ĠSearch Data ( ĊĠĠĠĠĠĠĠ ĠStation (" A ", Ġ" AA "), ĠStation (" B ", Ġ" BB "), ĊĠĠĠĠĠĠĠ ĠSimple Date ( 2 0 1 8 , Ġ 1 , Ġ 2 ), Ġ 1 , Ġ 2 , Ġ 3 ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġprivate Ġval Ġclient : ĠSearch Client Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠ Ġon Ġ{ Ġget Fl ights ( any (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany (), Ġany ()) Ġ}. thenReturn ( Single . just ( fl ights Dto )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġsearch Repository Ġ= ĠSearch Repository ( client ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Fl ights Ġshould Ġmake Ġrequest Ġwith Ġcorrect Ġparameters `() Ġ{ ĊĠĠĠĠĠĠĠ Ġsearch Repository . get Fl ights ( search Data ). test (). await () ĊĊĠĠĠĠĠĠĠ Ġverify ( client ). get Fl ights (" A ", Ġ" B ", Ġ" 2 0 1 8 - 0 1 - 0 2 ", Ġ 1 , Ġ 2 , Ġ 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse , Ġ 3 , Ġ 3 , Ġ 3 , Ġ 3 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` get Fl ights Ġshould Ġmap Ġdto Ġinto Ġmodel Ġclass `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrency Ġ= ĠCurrency . getInstance (" PL N ") ĊĠĠĠĠĠĠĠ Ġval Ġdate Ġ= ĠSimple DateTime ( 1 9 7 0 , Ġ 1 , Ġ 1 , Ġ 1 , Ġ 0 ) ĊĠĠĠĠĠĠĠ Ġval Ġprice Ġ= Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠF are Type . AD T Ġto ĠPrice ( BigDecimal ( 1 5 ), Ġ 2 5 , Ġcurrency ), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠF are Type . CH D Ġto ĠPrice ( BigDecimal ( 6 0 ), Ġ 2 0 , Ġcurrency ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected A Ġ= ĠFlight ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdate , Ġ" NR ", Ġ" 1 2 : 3 0 ", Ġprice , Ġcurrency , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStation (" A ", Ġ" AA "), ĠStation (" B ", Ġ" BB "), Ġ 1 , Ġ" W " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġexpected B Ġ= Ġexpected A . copy ( origin Ġ= ĠStation (" C ", Ġ" CC "), Ġdestination Ġ= ĠStation (" D ", Ġ" DD ")) ĊĊĠĠĠĠĠĠĠ Ġval Ġfl ights Test Ġ= Ġsearch Repository . get Fl ights ( search Data ). test () ĊĠĠĠĠĠĠĠ Ġfl ights Test . assert Value ( listOf ( expected A , Ġexpected B )) ĊĠĠĠ Ġ} Ċ }