package Ġcom . mapbox . maps Ċ Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Frame Layout Ċ import Ġcom . mapbox . bindgen . Expected Factory Ċ import Ġcom . mapbox . geojson . Geometry Ċ import Ġcom . mapbox . geojson . Point Ċ import Ġcom . mapbox . maps . View Annotation ManagerImpl . Companion . EXCEPTION _ TEXT _ ASS OCI ATED _ FEATURE _ ID _ AL READY _ EXISTS Ċ import Ġcom . mapbox . maps . view annotation . view Annotation Options Ċ import Ġio . mock k .* Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ Ċ class ĠView Annotation Manager Test Ġ{ ĊĠ Ġprivate Ġval Ġmap box Map : ĠMap box Map Ġ= Ġmock k ( relax Unit Fun Ġ= Ġtrue ) ĊĠ Ġprivate Ġval Ġmap View : ĠMap View Ġ= Ġmock k ( relax Unit Fun Ġ= Ġtrue ) ĊĊĠ Ġprivate Ġlateinit Ġvar Ġview Annotation Manager : ĠView Annotation ManagerImpl ĊĠ Ġprivate Ġlateinit Ġvar Ġframe LayoutParams : ĠFrame Layout . LayoutParams ĊĠ Ġprivate Ġlateinit Ġvar Ġview : ĠView ĊĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġmap View . getMap box Map () Ġ} Ġreturns Ġmap box Map ĊĠĠĠ Ġevery Ġ{ Ġmap View . map Controller . plugin Registry . view Plugins Ġ} Ġreturns Ġmutable Map Of () ĊĠĠĠ Ġview Annotation Manager Ġ= ĠView Annotation ManagerImpl ( map View ) ĊĠĠĠ Ġframe LayoutParams Ġ= Ġmock k () ĊĠĠĠ Ġframe LayoutParams . width Ġ= Ġ 2 0 ĊĠĠĠ Ġframe LayoutParams . height Ġ= Ġ 2 0 ĊĠĠĠ Ġview Ġ= Ġmock k () ĊĠĠĠ Ġevery Ġ{ Ġview . layout Params Ġ} Ġreturns Ġframe LayoutParams ĊĠĠĠ Ġevery Ġ{ Ġview . visibility Ġ} Ġreturns ĠView . VISIBLE ĊĠĠĠ Ġevery Ġ{ Ġview . view Tree Observer Ġ} Ġreturns Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠ Ġevery Ġ{ Ġmap View . context Ġ} Ġreturns Ġmock k () ĊĠĠĠ Ġevery Ġ{ Ġview . add On Attach State ChangeListener ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . addView Annotation ( any (), Ġany ()) Ġ} Ġreturns ĠExpected Factory . create None () ĊĠ Ġ} ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . remove View Annotation ( any ()) Ġ} Ġreturns ĠExpected Factory . create None () ĊĠĠĠ Ġevery Ġ{ Ġview . remove On Attach State ChangeListener ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠ Ġview Annotation Manager . destroy () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġadd View Annotation With Duplicate View () Ġ{ ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠ Ġview , ĊĠĠĠĠĠ Ġview Annotation Options Ġ{ ĊĠĠĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġexception Ġ= ĠassertThrows ( RuntimeException :: class . java ) Ġ{ ĊĠĠĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠĠĠ Ġview , ĊĠĠĠĠĠĠĠ Ġview Annotation Options Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ Ġ" Trying Ġto Ġadd Ġview Ġannotation Ġthat Ġwas Ġalready Ġadded Ġbefore ! Ġ" Ġ+ ĊĠĠĠĠĠĠĠ Ġ" Please Ġconsider Ġdeleting Ġannotation Ġview Ġ($ view ) Ġbefore hand .", ĊĠĠĠĠĠ Ġexception . message ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġadd View Annotation With Duplicate Associated Feature Id () Ġ{ ĊĠĠĠ Ġval Ġassociated Feature Id Ġ= Ġ" associated Feature Id " ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġassociated Feature Id ( associated Feature Id ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠ Ġview , ĊĠĠĠĠĠ Ġview Annotation Options ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġid Ġ= Ġview Annotation Manager . id Lookup Map [ view ] !! ĊĠĠĠ Ġval Ġanother View Ġ= Ġmock k < View >() ĊĠĠĠ Ġevery Ġ{ Ġanother View . layout Params Ġ} Ġreturns Ġframe LayoutParams ĊĠĠĠ Ġevery Ġ{ Ġanother View . visibility Ġ} Ġreturns ĠView . VISIBLE ĊĠĠĠ Ġevery Ġ{ Ġanother View . view Tree Observer Ġ} Ġreturns Ġmock k ( relax ed Ġ= Ġtrue ) ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( id ) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ Ġval Ġexception Ġ= ĠassertThrows ( RuntimeException :: class . java ) Ġ{ ĊĠĠĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠĠĠ Ġanother View , ĊĠĠĠĠĠĠĠ Ġview Annotation Options ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠString . format ( ĊĠĠĠĠĠĠĠ ĠEXCEPTION _ TEXT _ ASS OCI ATED _ FEATURE _ ID _ AL READY _ EXISTS , ĊĠĠĠĠĠĠĠ Ġassociated Feature Id ĊĠĠĠĠĠ Ġ), ĊĠĠĠĠĠ Ġexception . message ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġupdate View Annotation With Duplicate Associated Feature Id () Ġ{ ĊĠĠĠ Ġval Ġassociated Feature Id Ġ= Ġ" associated Feature Id " ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġassociated Feature Id ( associated Feature Id ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠ Ġview , ĊĠĠĠĠĠ Ġview Annotation Options ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġid Ġ= Ġview Annotation Manager . id Lookup Map [ view ] !! ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( id ) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ Ġval Ġexception Ġ= ĠassertThrows ( RuntimeException :: class . java ) Ġ{ ĊĠĠĠĠĠ Ġview Annotation Manager . update View Annotation ( ĊĠĠĠĠĠĠĠ Ġview , ĊĠĠĠĠĠĠĠ Ġview Annotation Options Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġassociated Feature Id ( associated Feature Id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertEquals ( ĊĠĠĠĠĠ ĠString . format ( ĊĠĠĠĠĠĠĠ ĠEXCEPTION _ TEXT _ ASS OCI ATED _ FEATURE _ ID _ AL READY _ EXISTS , ĊĠĠĠĠĠĠĠ Ġassociated Feature Id ĊĠĠĠĠĠ Ġ), ĊĠĠĠĠĠ Ġexception . message ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġupdate View Annotation Success () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . update View Annotation ( any (), Ġany ()) Ġ} Ġreturns ĠExpected Factory . create None () ĊĠĠĠ Ġval Ġupdated Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġoffset X ( 1 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠ Ġview , ĊĠĠĠĠĠ Ġview Annotation Options Ġ{ ĊĠĠĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġupdate Actual Result Ġ= Ġview Annotation Manager . update View Annotation ( view , Ġupdated Options ) ĊĠĠĠ ĠassertEquals ( true , Ġupdate Actual Result ) ĊĠĠĠ Ġval Ġid Ġ= Ġview Annotation Manager . id Lookup Map [ view ] ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġmap box Map . update View Annotation ( id !! , Ġupdated Options ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġupdate View Annotation Failure () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . update View Annotation ( any (), Ġany ()) Ġ} Ġreturns ĠExpected Factory . create None () ĊĠĠĠ Ġval Ġupdated Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġoffset X (- 1 0 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġupdate Actual Result Ġ= Ġview Annotation Manager . update View Annotation ( mock k (), Ġupdated Options ) ĊĠĠĠ ĠassertEquals ( false , Ġupdate Actual Result ) ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġmap box Map . update View Annotation ( any (), Ġupdated Options ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġremove View Annotation Success () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . remove View Annotation ( any ()) Ġ} Ġreturns ĠExpected Factory . create None () ĊĠĠĠ Ġevery Ġ{ Ġview . remove On Attach State ChangeListener ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( ĊĠĠĠĠĠ Ġview , ĊĠĠĠĠĠ Ġview Annotation Options Ġ{ ĊĠĠĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ) ĊĠĠĠ Ġval Ġid Ġ= Ġview Annotation Manager . id Lookup Map [ view ] ĊĠĠĠ Ġval Ġremove Actual Result Ġ= Ġview Annotation Manager . remove View Annotation ( view ) ĊĠĠĠ ĠassertEquals ( true , Ġremove Actual Result ) ĊĠĠĠ ĠassertNull ( view Annotation Manager . id Lookup Map [ view ]) ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġview . remove On Attach State ChangeListener ( any ()) Ġ} ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġmap box Map . remove View Annotation ( id !! ) Ġ} ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 1 ) Ġ{ Ġmap View . remove View ( view ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġremove View Annotation Failure () Ġ{ ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . remove View Annotation ( any ()) Ġ} Ġreturns ĠExpected Factory . create None () ĊĠĠĠ Ġval Ġremove Actual Result Ġ= Ġview Annotation Manager . remove View Annotation ( mock k ()) ĊĠĠĠ ĠassertEquals ( false , Ġremove Actual Result ) ĊĠĠĠ Ġverify ( exact ly Ġ= Ġ 0 ) Ġ{ Ġmap box Map . remove View Annotation ( any ()) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation By Feature Id Success () Ġ{ ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġassociated Feature Id ( FEATURE _ ID ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( view , Ġview Annotation Options ) ĊĠĠĠ Ġval Ġview Id Ġ= Ġview Annotation Manager . id Lookup Map [ view ] ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( view Id !! ) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ ĠassertEquals ( view , Ġview Annotation Manager . getView Annotation By Feature Id ( FEATURE _ ID )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation By Feature Id Failure No Feature Id () Ġ{ ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( view , Ġview Annotation Options ) ĊĠĠĠ Ġval Ġview Id Ġ= Ġview Annotation Manager . id Lookup Map [ view ] ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( view Id !! ) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ ĠassertNull ( view Annotation Manager . getView Annotation By Feature Id ( FEATURE _ ID )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation By Feature Id Failure No View () Ġ{ ĊĠĠĠ ĠassertNull ( view Annotation Manager . getView Annotation By Feature Id ( FEATURE _ ID )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation Options By Feature Id Success () Ġ{ ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠĠĠ Ġassociated Feature Id ( FEATURE _ ID ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( view , Ġview Annotation Options ) ĊĠĠĠ Ġval Ġview Id Ġ= Ġview Annotation Manager . id Lookup Map [ view ] ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( view Id !! ) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ ĠassertEquals ( view Annotation Options , Ġview Annotation Manager . getView Annotation Options By Feature Id ( FEATURE _ ID )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation Options By Feature Id Failure No Feature Id () Ġ{ ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( view , Ġview Annotation Options ) ĊĠĠĠ Ġval Ġview Id Ġ= Ġview Annotation Manager . id Lookup Map [ view ] ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( view Id !! ) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ ĠassertNull ( view Annotation Manager . getView Annotation Options By Feature Id ( FEATURE _ ID )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation Options By Feature Id Failure No View () Ġ{ ĊĠĠĠ ĠassertNull ( view Annotation Manager . getView Annotation Options By Feature Id ( FEATURE _ ID )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation Options By View Success () Ġ{ ĊĠĠĠ Ġval Ġview Annotation Options Ġ= Ġview Annotation Options Ġ{ ĊĠĠĠĠĠ Ġgeometry ( DEFAULT _ GEOMETRY ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġview Annotation Manager . addView Annotation ( view , Ġview Annotation Options ) ĊĠĠĠ Ġevery Ġ{ Ġmap box Map . getView Annotation Options ( any ()) Ġ} Ġreturns ĠExpected Factory . create Value ( view Annotation Options ) ĊĠĠĠ ĠassertEquals ( view Annotation Options , Ġview Annotation Manager . getView Annotation Options By View ( view )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġget View Annotation Options By View No View Failure () Ġ{ ĊĠĠĠ ĠassertNull ( view Annotation Manager . getView Annotation Options By View ( view )) ĊĠ Ġ} ĊĊĠ Ġprivate Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġconst Ġval ĠFEATURE _ ID Ġ= Ġ" feature Id " ĊĠĠĠ Ġval ĠDEFAULT _ GEOMETRY : ĠGeometry Ġ= ĠPoint . from Lng Lat ( 0 . 0 , Ġ 0 . 0 ) ĊĠ Ġ} Ċ }