package Ġjet brains . datal ore . maps . liv emap . entities . regions Ċ Ċ import Ġjet brains . datal ore . base . async . Simple Async Ċ import Ġjet brains . datal ore . base . spatial . Lon Lat Ċ import Ġjet brains . datal ore . base . spatial . Quad Key Ċ import Ġjet brains . datal ore . jetbrains . liv emap . Live Map TestBase Ċ import Ġjet brains . datal ore . jetbrains . liv emap . Mocks Ċ import Ġjet brains . datal ore . jetbrains . liv emap . Mocks . Fragments Response Async Ċ import Ġjet brains . datal ore . jetbrains . liv emap . entities . regions . Fragment Spec Ċ import Ġjet brains . datal ore . maps . Utils . square Ċ import Ġjet brains . gis . geo protocol . Fragment Ċ import Ġjet brains . liv emap . core . ecs . E cs System Ċ import Ġjet brains . liv emap . core . mult it ask ing . Scheduler System Ċ import Ġjet brains . liv emap . fragment .* Ċ import Ġjet brains . liv emap . map engine . camera . Camera Component Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito Ċ import Ġjava . util .* Ċ import Ġjava . util . function . Consumer Ċ import Ġjava . util . stream . Collectors Ċ import Ġkotlin . reflect . K Class Ċ Ċ class ĠFragment Downloading Service Test Ġ: ĠLive Map TestBase () Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmy Fragment Provider : ĠFragment Provider ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfragment Foo 0 : ĠFragment Spec ĊĠĠĠ Ġprivate Ġfun Ġassert Requests Count ( count : ĠInt , Ġvar arg Ġspecs : ĠFragment Spec ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ( first , Ġsecond ) Ġ= Ġget Fragment Request Params ( listOf (* specs )) ĊĠĠĠĠĠĠĠ ĠMockito . verify ( my Fragment Provider , ĠMockito . times ( count )). get Fragments ( first , Ġsecond ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠĠĠĠĠ Ġmy Fragment Provider Ġ= ĠMockito . mock ( Fragment Provider :: class . java ) ĊĠĠĠĠĠĠĠ Ġadd System ( Fragment Downloading System ( 9 9 9 , Ġmy Fragment Provider , Ġcomponent Manager )) ĊĠĠĠĠĠĠĠ Ġcreate Entity ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Fragments Change ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠChanged Fragments Component (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEmpty Fragments Component (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠStreaming Fragments Component (), ĊĠĠĠĠĠĠĠĠĠĠĠ ĠCached Fragments Component () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcreate Entity (" Camera ", ĠCamera Component ( my Camera )) ĊĠĠĠĠĠĠĠ Ġfragment Foo 0 Ġ= ĠFragment Spec ( FOO _ REGION _ ID , ĠQU AD _ 0 ). set Ge ometries ( square ( 1 , Ġ 2 , Ġ 3 0 , Ġ 4 0 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġsystems Order : ĠList < K Class < out ĠE cs System >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠFragment Downloading System :: class , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠScheduler System :: class ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġalready Streaming Fragments ShouldBe Requested () Ġ{ ĊĠĠĠĠĠĠĠ Ġconfig Tile Geometry Response ( fragment Foo 0 ) Ġ// Ġno Ġsuccess Ġ- Ġwaiting Ġfor Ġresponse ĊĠĠĠĠĠĠĠ Ġupdate ( Mocks . changed Fragments ( this ). requested ( fragment Foo 0 )) ĊĠĠĠĠĠĠĠ Ġupdate ( Mocks . changed Fragments ( this ). requested ( fragment Foo 0 )) ĊĠĠĠĠĠĠĠ Ġ// Ġassert Requests Count ( 1 , Ġfragment Foo 0 ); Ġ// ĠTODO : Ġfix Ġit Ġlater ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġconfig Tile Geometry Response ( var arg Ġqueries : ĠFragment Spec ): ĠF rag ments Response Async Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġconfig Tile Geometry Response ( Arrays . asList (* queries )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġconfig Tile Geometry Response ( queries : ĠList < Fragment Spec >): ĠF rag ments Response Async Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponses : ĠMutable Map < String , ĠMutable List < Fragment >> Ġ= ĠHashMap < String , ĠMutable List < Fragment >>() ĊĠĠĠĠĠĠĠ Ġqueries . forEach ( Consumer Ġ{ Ġq : ĠFragment Spec Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ(! responses . containsKey ( q . region Id ())) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġresponses [ q . region Id ()] Ġ= ĠArrayList < Fragment >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresponses [ q . region Id ()] !!. add ( Fragment ( q . quad (), ĠlistOf ( q . ge ometries ()))) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġval Ġasync : ĠSimple Async < Map < String , ĠList < Fragment >>> Ġ= ĠSimple Async < Map < String , ĠList < Fragment >> >() ĊĠĠĠĠĠĠĠ Ġval Ġ( first , Ġsecond ) Ġ= Ġget Fragment Request Params ( queries ) ĊĠĠĠĠĠĠĠ ĠMockito .` when `( my Fragment Provider . get Fragments ( first , Ġsecond )). thenReturn ( async ) ĊĠĠĠĠĠĠĠ Ġreturn ĠF rag ments Response Async ( async , Ġresponses ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Fragment Request Params ( queries : ĠList < Fragment Spec >): ĠPair < List < String >, ĠSet < Quad Key < Lon Lat >>> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġids Ġ= Ġqueries . stream (). map Ġ{ Ġobj : ĠFragment Spec Ġ-> Ġobj . region Id () Ġ}. distinct (). collect ( Collectors . toList ()) ĊĠĠĠĠĠĠĠ Ġval Ġqu ads Ġ= Ġqueries . stream (). map Ġ{ Ġobj : ĠFragment Spec Ġ-> Ġobj . quad () Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. distinct (). collect ( Collectors . toSet ()) ĊĠĠĠĠĠĠĠ Ġreturn ĠPair ( ids , Ġqu ads ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠF OO _ REGION _ ID Ġ= Ġ" 1 2 3 1 2 3 " ĊĠĠĠĠĠĠĠ Ġprivate Ġval ĠQU AD _ 0 : ĠQuad Key < Lon Lat > Ġ= ĠQuad Key (" 0 ") ĊĠĠĠ Ġ} Ċ }