/* Ċ Ġ* Ġ ĠCopyright Ġ 2 0 1 9 ĠArc us ĠProject . Ċ Ġ* Ċ Ġ* Ġ ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġ Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* Ġ ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* Ġ ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġ Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* Ġ ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* Ġ ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġ Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġar cus . presentation . pair ing . device . custom ization . h alo Ċ Ċ import Ġcom . google . common . truth . Truth Ċ import Ġar cus . cor nea . device . smoke and co . h alo . H alo Location Controller Ċ import Ġar cus . cor nea . utils . Looper Executor Ċ import Ġcom . iris . client . Client Event Ċ import Ġcom . iris . client . bean . Same State Ċ import Ġcom . iris . client . event . Client Future Ċ import Ġar cus . presentation . d ynam ite Ċ import Ġar cus . presentation . pair ing . device . custom ization . h alo . state county . H alo Count y Ċ import Ġar cus . presentation . pair ing . device . custom ization . h alo . state county . H alo State And Code Ċ import Ġar cus . presentation . pair ing . device . custom ization . h alo . state county . H alo State Count y Select Presenter Impl Ċ import Ġar cus . presentation . pair ing . device . custom ization . h alo . state county . H alo State Count y Select View Ċ import Ġar cus . presentation . success Ċ import Ġcom . n ha ar man . mockito _ kotlin . argument Captor Ċ import Ġorg . junit . Test Ċ Ċ import Ġorg . junit . Before Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito . mock Ċ import Ġkotlin . properties . Deleg ates Ċ Ċ class ĠH alo State Count y Select Presenter Impl Test Ġ{ ĊĠĠĠ Ġprivate Ġval Ġstates For Bean Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠSame State ( map Of ( Same State . ATTR _ STATE Ġto Ġ" California ", ĠSame State . ATTR _ STATE CODE Ġto Ġ" CA ")), ĊĠĠĠĠĠĠĠ ĠSame State ( map Of ( Same State . ATTR _ STATE Ġto Ġ" North ĠCar ol ina ", ĠSame State . ATTR _ STATE CODE Ġto Ġ" NC ")), ĊĠĠĠĠĠĠĠ ĠSame State ( map Of ( Same State . ATTR _ STATE Ġto Ġ" F ederated ĠStates Ġof ĠM ic ron es ia ", ĠSame State . ATTR _ STATE CODE Ġto Ġ" FM ")) ĊĠĠĠ Ġ) ĊĠĠĠ Ġprivate Ġval Ġstates Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠH alo State And Code (" California ", Ġ" CA "), ĊĠĠĠĠĠĠĠ ĠH alo State And Code (" North ĠCar ol ina ", Ġ" NC ", true ), ĊĠĠĠĠĠĠĠ ĠH alo State And Code (" F ederated ĠStates Ġof ĠM ic ron es ia ", Ġ" FM ") ĊĠĠĠ Ġ) ĊĠĠĠ Ġprivate Ġval Ġcount ies Ġ= ĠlistOf (" Ch u uk * "," K os ra e "," Po hn pe it * "," Y ap ") ĊĠĠĠ Ġprivate Ġval Ġh alo Count ies Ġ= ĠlistOf ( ĊĠĠĠĠĠĠĠ ĠH alo Count y ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Ch u uk *", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠH alo Count y ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" K os ra e ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠH alo Count y ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Po hn pe it *", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠH alo Count y ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" Y ap ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfalse ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠĠĠ Ġprivate Ġval Ġmock Controller Ġ= ĠMock H alo Location Controller () ĊĠĠĠ Ġprivate Ġval Ġh alo Presenter Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠH alo State Count y Select Presenter Impl ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġmock Controller Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġ" NC " Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ{ Ġ"" Ġ}) ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval Ġh alo View Ġ= Ġmock ( H alo State Count y Select View :: class . java ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġdo Before () Ġ{ ĊĠĠĠĠĠĠĠ ĠL ooper Executor . set Main Executor ({ Ġit . run () Ġ}) ĊĠĠĠĠĠĠĠ Ġh alo Presenter . setView ( h alo View ) ĊĠĠĠĠĠĠĠ Ġh alo Presenter . load From Device Address ("") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload States Success () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Controller . state Response Ġ= Ġsuccess ( states For Bean ) ĊĠĠĠĠĠĠĠ Ġh alo Presenter . load States () ĊĊĠĠĠĠĠĠĠ Ġval Ġstates Captor Ġ= Ġargument Captor < List < H alo State And Code >>() ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( h alo View ). on States Loaded ( states Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( h alo View ) ĊĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( states Captor . all Values ). contains Exactly ( states ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload States Failure () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Controller . state Response Ġ= Ġd ynam ite () ĊĠĠĠĠĠĠĠ Ġh alo Presenter . load States () ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( h alo View ). on States Failed To Load () ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( h alo View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload Count ies () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Controller . count ies Response Ġ= Ġsuccess ( count ies ) ĊĠĠĠĠĠĠĠ Ġh alo Presenter . load Count ies ( states [ 2 ]) ĊĊĠĠĠĠĠĠĠ Ġval Ġcount y Captor Ġ= Ġargument Captor < List < H alo Count y >>() ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( h alo View ). on Count ies Loaded ( county Captor . capture ()) ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( h alo View ) ĊĊĠĠĠĠĠĠĠ ĠTr uth . assertThat ( county Captor . all Values ). contains Exactly ( h alo Count ies ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġload Count ies Failure () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Controller . count ies Response Ġ= Ġd ynam ite () ĊĠĠĠĠĠĠĠ Ġh alo Presenter . load Count ies ( states [ 2 ]) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( h alo View ). on Count ies Failed To Load () ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( h alo View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetSelected State And Count y Success () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Controller . setLocation Response Ġ= Ġsuccess ( Client Event ("", Ġ"")) ĊĠĠĠĠĠĠĠ Ġh alo Presenter . setView ( h alo View ) ĊĊĠĠĠĠĠĠĠ Ġh alo Presenter . load From Device Address ("") ĊĠĠĠĠĠĠĠ Ġh alo Presenter . setSelected State And Count y ( states [ 2 ], Ġcount ies [ 1 ]) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( h alo View ). on Selection Saved () ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( h alo View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetSelected State And Count y Failure () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Controller . setLocation Response Ġ= Ġd ynam ite () ĊĠĠĠĠĠĠĠ Ġh alo Presenter . setSelected State And Count y ( states [ 2 ], Ġcount ies [ 1 ]) ĊĊĠĠĠĠĠĠĠ ĠMockito . verify ( h alo View ). on Selection Save Failed () ĊĠĠĠĠĠĠĠ ĠMockito . verify No More Interactions ( h alo View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠMock H alo Location Controller Ġ: ĠH alo Location Controller Ġ{ ĊĠĠĠĠĠĠĠ Ġvar Ġstate Response Ġby ĠDeleg ates . notNull < Client Future < List < Same State >> >() ĊĠĠĠĠĠĠĠ Ġvar Ġcount ies Response Ġby ĠDeleg ates . notNull < Client Future < List < String >> >() ĊĠĠĠĠĠĠĠ Ġvar Ġset Location Response Ġby ĠDeleg ates . notNull < Client Future < Client Event >>() ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun ĠgetState Names (): ĠClient Future < List < Same State >> Ġ= Ġstate Response ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġget Count ies For ( state Code : ĠString ): ĠClient Future < List < String >> Ġ= Ġcount ies Response ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġset Location Using ( state Code : ĠString , Ġcount y : ĠString ): ĠClient Future < Client Event > Ġ= Ġset Location Response ĊĠĠĠ Ġ} Ċ }