package Ġcom . pk . ys f . api . service . mapper . booking Ċ Ċ import Ġcom . pk . ys f . api . data .* Ċ import Ġcom . pk . ys f . api . repository . S oc cer Field Repository Ċ import Ġcom . pk . ys f . api . model . dto . Booking Input Ċ import Ġcom . pk . ys f . api . model . entity . Booking Ċ import Ġcom . pk . ys f . api . util . dateTime ToString Ċ import Ġorg . junit . Before Ċ import Ġkotlin . test . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Inject Mocks Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . springframework . test . context . junit 4 . Spring Runner Ċ import Ġjava . time . format . DateTime Formatter Ċ import Ġjava . time . format . DateTime ParseException Ċ import Ġjava . util .* Ċ import Ġkotlin . test . assertEquals Ċ import Ġkotlin . test . assertNotNull Ċ Ċ @ RunWith ( Spring Runner :: class ) Ċ class ĠBook ing Input To Booking Test Ġ{ ĊĊĠĠĠ Ġ@ Inject Mocks ĊĠĠĠ Ġlateinit Ġvar Ġbooking Input To Booking : ĠBook ing Input To Booking ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġlateinit Ġvar Ġsoc cer Field Repository : ĠS oc cer Field Repository ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġinit () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito .` when `( soc cer Field Repository . findById ( SO CC ER _ FIELD _ ID )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. thenReturn ( Optional . of Nullable ( soc cer Field Mock ())) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcorrect Map Booking Input () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbooking : ĠBook ing Ġ= Ġbooking Input To Booking . map ( booking Input Mock ()) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( USER _ CODE , Ġbooking . user Code ) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( booking . startDate ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( START _ DATE _ STRING , ĠdateTime ToString ( booking . startDate )) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( booking . execution Time ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( EXEC UTION _ TIME _ STRING , Ġbooking . execution Time . toString ()) ĊĠĠĠĠĠĠĠ ĠassertNotNull ( booking . amount ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( AMOUNT _ STRING , Ġbooking . amount . toString ()) ĊĠĠĠĠĠĠĠ ĠassertEquals ( IS _ PAY ED , Ġbooking . is Pay ed ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ ID , Ġbooking . soc cer Field . id ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ NAME , Ġbooking . soc cer Field . name ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ WIDTH , Ġbooking . soc cer Field . width ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ LENGTH , Ġbooking . soc cer Field . length ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( PRICE , Ġbooking . soc cer Field . price ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ IS _ LIGHT ING , Ġbooking . soc cer Field . is Lighting ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ IS _ F ENC ED , Ġbooking . soc cer Field . is F enced ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ IS _ LOCK ER _ ROOM , Ġbooking . soc cer Field . is Locker Room ) ĊĠĠĠĠĠĠĠ ĠassertEquals ( DESCRIPTION , Ġbooking . soc cer Field . description ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcorrect Map All () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbook ings : ĠCollection < Booking > Ġ= Ġbooking Input To Booking . map All ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( booking Input Mock (), Ġbooking Input Mock (), Ġbooking Input Mock ()) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġbook ings . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( USER _ CODE , Ġit . user Code ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( it . startDate ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( START _ DATE _ STRING , ĠdateTime ToString ( it . startDate )) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( it . execution Time ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( EXEC UTION _ TIME _ STRING , Ġit . execution Time . toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertNotNull ( it . amount ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( AMOUNT _ STRING , Ġit . amount . toString ()) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( IS _ PAY ED , Ġit . is Pay ed ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertEquals ( SO CC ER _ FIELD _ ID , Ġit . soc cer Field . id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠDateTime ParseException :: class ) ĊĠĠĠ Ġfun Ġbad DateFormat Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbad Start DateFormat Ġ= Ġ" 2 0 1 9 - 0 1 - 0 1 T 1 3 : 0 0 " ĊĠĠĠĠĠĠĠ Ġval Ġincorrect Booking Input : ĠBook ing Input Ġ= ĠBook ing Input . build Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠstartDate Ġ= Ġbad Start DateFormat ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġbooking Input To Booking . map ( incorrect Booking Input ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠDateTime ParseException :: class ) ĊĠĠĠ Ġfun Ġbad DateFormat Test 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbad Start DateFormat Ġ= Ġ" 2 0 1 9 - 0 1 - 0 1 " ĊĠĠĠĠĠĠĠ Ġval Ġincorrect Booking Input : ĠBook ing Input Ġ= ĠBook ing Input . build Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠstartDate Ġ= Ġbad Start DateFormat ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġbooking Input To Booking . map ( incorrect Booking Input ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠDateTime ParseException :: class ) ĊĠĠĠ Ġfun Ġbad Execution Time Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbad Execution Time Ġ= Ġ" 1 : 5 0 " ĊĠĠĠĠĠĠĠ Ġval Ġincorrect Booking Input : ĠBook ing Input Ġ= ĠBook ing Input . build Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexecution Time Ġ= Ġbad Execution Time ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġbooking Input To Booking . map ( incorrect Booking Input ) ĊĠĠĠ Ġ} Ċ }