package Ġcom . app . practice . domain Ċ Ċ import Ġcom . app . practice . commons . utils . Constant Test . Companion . CAR _ ADDRESS Ċ import Ġcom . app . practice . commons . utils . Constant Test . Companion . CAR _ INTER IOR Ċ import Ġcom . app . practice . commons . utils . Constant Test . Companion . CAR _ LAT IT UDE Ċ import Ġcom . app . practice . commons . utils . Constant Test . Companion . CAR _ LONG IT UDE Ċ import Ġcom . app . practice . commons . utils . Constant Test . Companion . CAR _ NAME Ċ import Ġcom . app . practice . commons . utils . Constant Test . Companion . CAR _ VE H IC LE _ NUMBER Ċ import Ġcom . app . practice . commons . utils . Sequence List Ċ import Ġcom . app . practice . domain . entities . Car Generator Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġorg . mockito . Mockito Ċ import Ġretrofit 2 . Response Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠCar Repository Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcar Repository : ĠCar Repository Ġ= Ġmock () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġverify ApiModel To Entity Model Must Return Same Values () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠResponse . success ( Car Generator . get Success Car Data ()) ĊĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMockito .` when `( car Repository . getLocation ()). then Answer ( Sequence List ( listOf ( response ))) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 2 , Ġresponse . body ()?. place Marks ?. size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( CAR _ ADDRESS , Ġresponse . body ()?. place Marks ?. get ( 0 )?. address ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( response . body ()?. place Marks ?. get ( 0 )?. coordinates ?. get ( 0 ) Ġ== ĠCAR _ LONG IT UDE ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( response . body ()?. place Marks ?. get ( 0 )?. coordinates ?. get ( 1 ) Ġ== ĠCAR _ LAT IT UDE ) ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ("", Ġresponse . body ()?. place Marks ?. get ( 1 )?. address ) ĊĠĠĠĠĠĠĠ ĠAssert . assertFalse ( response . body ()?. place Marks ?. get ( 0 )?. name Ġ== ĠCAR _ NAME ) ĊĠĠĠĠĠĠĠ ĠAssert . assertFalse ( response . body ()?. place Marks ?. get ( 0 )?. vehicle Ins urance Ġ== ĠCAR _ VE H IC LE _ NUMBER ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( response . body ()?. place Marks ?. get ( 1 )?. inter ior Ġ== ĠCAR _ INTER IOR ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġverify Result When Repo Mock Return Empty State () Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= ĠResponse . success ( Car Generator . get Empty Car Data ()) ĊĊĠĠĠĠĠĠĠ Ġrun Blocking Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMockito .` when `( car Repository . getLocation ()). then Answer ( Sequence List ( listOf ( response ))) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġexpected Result Ġ= ĠResponse . success ( Car Generator . get Empty Car Data ()) ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( expected Result . body (), Ġresponse . body ()) ĊĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 0 , Ġresponse . body ()?. place Marks ?. size ) ĊĠĠĠĠĠĠĠ Ġresponse . body ()?. place Marks ?. isNull OrEmpty ()?. let Ġ{ ĠAssert . assertTrue ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġresponse . body ()?. place Marks ?. isNotEmpty ()?. let Ġ{ ĠAssert . assertFalse ( it ) Ġ} ĊĠĠĠ Ġ} Ċ }