/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 8 ĠThe ĠAndroid ĠOpen ĠSource Ġ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 Ġcom . android . tools . idea . gradle . structure . model Ċ Ċ import Ġcom . android . tools . idea . gradle . structure . model . android . Ps Android Module Ċ import Ġcom . android . tools . idea . gradle . structure . model . android . as Parsed Ċ import Ġcom . android . tools . idea . gradle . structure . model . helpers . boolean Values Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . Annotated Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . Dsl Text Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . Known Values Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . Model Property Context Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . Parsed Value Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . Value Descriptor Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . annotate WithError Ċ import Ġcom . android . tools . idea . gradle . structure . model . meta . annotated Ċ import Ġcom . android . tools . idea . testing . Android Gradle TestCase Ċ import Ġcom . android . tools . idea . testing . Test Project Paths Ċ import Ġcom . google . common . util . concurrent . List enable Future Ċ import Ġorg . hamcrest . Core Matchers . equalTo Ċ import Ġorg . hamcrest . Core Matchers . null Value Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . junit . Ass ume . assume That Ċ import Ġjava . math . BigDecimal Ċ Ċ class ĠP s Variables Test Ġ: ĠAndroid Gradle TestCase () Ġ{ ĊĊĠ Ġfun ĠtestGet Build Script Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġvariables Ġ= Ġps Project . build Script Variables ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġvariables . map Ġ{ Ġit . name Ġto Ġit . value Ġ}, ĊĠĠĠĠĠ ĠequalTo ( listOf ( ĊĠĠĠĠĠĠĠ Ġ" script Var 1 " Ġto Ġ 1 . as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" script Var 2 " Ġto Ġ" 2 ". as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" script Bool " Ġto Ġtrue . as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" ag p Version X " Ġto Ġ" 3 . 4 . x ". as Parsed () ĊĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġfun ĠtestGet Project Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġvariables Ġ= Ġps Project . variables ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġvariables . map Ġ{ Ġit . name Ġto Ġit . value Ġ}, ĊĠĠĠĠĠ ĠequalTo ( listOf ( ĊĠĠĠĠĠĠĠ Ġ" some Var " Ġto Ġ" Present ". as Parsed < Any >(), ĊĠĠĠĠĠĠĠ Ġ" root Bool " Ġto Ġ(" script Bool " Ġto Ġtrue ). as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" root Bool 3 " Ġto Ġ(" root Bool " Ġto Ġtrue ). as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" root Bool 2 " Ġto Ġ(" root Bool 3 " Ġto Ġtrue ). as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" root Float " Ġto ĠBigDecimal (" 3 . 1 4 "). as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" list Prop " Ġto ĠlistOf ( 1 5 . as Parsed (), 1 6 . as Parsed (), 4 5 . as Parsed ()). as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" map Prop " Ġto Ġmap Of (" key 1 " Ġto Ġ" val 1 ". as Parsed (), Ġ" key 2 " Ġto Ġ" val 2 ". as Parsed ()). as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" bool Root " Ġto Ġtrue . as Parsed (), ĊĠĠĠĠĠĠĠ Ġ" dependency Version " Ġto Ġ" 2 8 . 0 . 0 ". as Parsed () ĊĠĠĠĠĠ Ġ)) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġfun ĠtestGet Module Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġvariables . map Ġ{ Ġit . name Ġ}, ĊĠĠĠĠĠ ĠequalTo ( listOf ( ĊĠĠĠĠĠĠĠ Ġ" my Variable ", ĊĠĠĠĠĠĠĠ Ġ" variable 1 ", ĊĠĠĠĠĠĠĠ Ġ" another Variable ", ĊĠĠĠĠĠĠĠ Ġ" var Int ", ĊĠĠĠĠĠĠĠ Ġ" var Bool ", ĊĠĠĠĠĠĠĠ Ġ" var Ref String ", ĊĠĠĠĠĠĠĠ Ġ" var Pro Guard Files ", ĊĠĠĠĠĠĠĠ Ġ" local List ", ĊĠĠĠĠĠĠĠ Ġ" local Map ", ĊĠĠĠĠĠĠĠ Ġ" val Version ", ĊĠĠĠĠĠĠĠ Ġ" version Val ", ĊĠĠĠĠĠĠĠ Ġ" more Variable ", ĊĠĠĠĠĠĠĠ Ġ" map Variable ")) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest List Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġval Ġlist Variable Ġ= Ġvariables . findElement (" var Pro Guard Files ") !! ĊĊĠĠĠ ĠassertThat ( list Variable . list Items . map Ġ{ Ġit . value Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠequalTo ( listOf (" pro guard - rules . txt ". as Parsed < Any >(), Ġ" pro guard - rules 2 . txt ". as Parsed < Any >() ))) ĊĊĠĠĠ Ġlist Variable . list Items . findElement ( 0 ) !!. delete () ĊĊĠĠĠ ĠassertThat ( list Variable . list Items . map Ġ{ Ġit . value Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠequalTo ( listOf (" pro guard - rules 2 . txt ". as Parsed < Any >() ))) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Adding List Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġvar Ġref reshed Ġ= Ġ 0 ĊĠĠĠ Ġvariables . onChange ( test Root Disposable ) Ġ{ Ġref reshed ++ Ġ} ĊĠĠĠ Ġval Ġlist Var Ġ= Ġvariables . add New List Variable (" new List 1 ") ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 1 )) ĊĠĠĠ Ġlist Var . add List Value (" v 1 ". as Parsed ()) ĊĠĠĠ Ġlist Var . add List Value (" v 2 ". as Parsed ()) ĊĠĠĠ ĠassertThat ( list Var . list Items . map Ġ{ Ġit . value Ġ}, ĠequalTo ( listOf (" v 1 ". as Parsed < Any >(), Ġ" v 2 ". as Parsed < Any >() ))) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Adding List Variables _ via Empty Item State () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġvar Ġref reshed Ġ= Ġ 0 ĊĠĠĠ Ġvariables . onChange ( this . test Root Disposable ) Ġ{ Ġref reshed ++ Ġ} ĊĠĠĠ Ġval Ġlist Var Ġ= Ġvariables . add New List Variable (" new List 1 ") ĊĠĠĠ Ġlist Var . list Items . onChange ( test Root Disposable ) Ġ{ Ġref reshed ++ Ġ} ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 1 )) ĊĊĠĠĠ Ġval Ġnew Item 1 Ġ= Ġlist Var . add List Value ( Parsed Value . Not Set ) ĊĠĠĠ Ġ// ĠThe Ġnew Ġitem Ġis Ġnot Ġadded Ġuntil Ġa Ġvalue Ġis Ġset . ĊĠĠĠ ĠassertThat ( list Var . list Items . map Ġ{ Ġit . value Ġ}, ĠequalTo ( listOf ())) ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 1 )) ĊĊĠĠĠ Ġnew Item 1 . value Ġ= Ġ" v 1 ". as Parsed () ĊĠĠĠ ĠassertThat ( list Var . list Items . map Ġ{ Ġit . value Ġ}, ĠequalTo ( listOf (" v 1 ". as Parsed < Any >() ))) ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 2 )) ĊĊĠĠĠ Ġval Ġnew Item 2 Ġ= Ġlist Var . add List Value ( Parsed Value . Not Set ) ĊĠĠĠ ĠassertThat ( list Var . list Items . map Ġ{ Ġit . value Ġ}, ĠequalTo ( listOf (" v 1 ". as Parsed < Any >() ))) ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 2 )) ĊĊĠĠĠ Ġnew Item 2 . value Ġ= Ġ" v 2 ". as Parsed () ĊĠĠĠ ĠassertThat ( list Var . list Items . map Ġ{ Ġit . value Ġ}, ĠequalTo ( listOf (" v 1 ". as Parsed < Any >(), Ġ" v 2 ". as Parsed < Any >() ))) ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 3 )) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Adding Map Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġvar Ġref reshed Ġ= Ġ 0 ĊĠĠĠ Ġvariables . onChange ( test Root Disposable ) Ġ{ Ġref reshed ++ Ġ} ĊĠĠĠ Ġval Ġmap Var Ġ= Ġvariables . add New Map Variable (" new Map 1 ") ĊĠĠĠ ĠassertThat ( ref reshed , ĠequalTo ( 1 )) ĊĠĠĠ Ġmap Var . add Map Value (" a ") ?. value Ġ= Ġ 1 . as Parsed () ĊĠĠĠ Ġmap Var . add Map Value (" b ") ?. value Ġ= Ġ 2 . as Parsed () ĊĠĠĠ ĠassertThat ( map Var . map Entries . entries . map Ġ{ Ġit . key Ġto Ġit . value . value Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠequalTo ( listOf (" a " Ġto Ġ 1 . as Parsed < Any >(), Ġ" b " Ġto Ġ 2 . as Parsed < Any >() ))) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Map Variables () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġval Ġmap Variable Ġ= Ġvariables . findElement (" map Variable ") !! ĊĊĠĠĠ ĠassertThat ( map Variable . map Entries . entries . map Values Ġ{ Ġit . value . value Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠequalTo ( map Of (" a " Ġto Ġ"\" double \" Ġquotes ". as Parsed < Any >(), Ġ" b " Ġto Ġ"' single ' Ġquotes ". as Parsed < Any >() ))) ĊĊĠĠĠ Ġmap Variable . map Entries . findElement (" b ") !!. setName (" Z ") ĊĊĠĠĠ ĠassertThat ( map Variable . map Entries . entries . map Values Ġ{ Ġit . value . value Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠequalTo ( map Of (" a " Ġto Ġ"\" double \" Ġquotes ". as Parsed < Any >(), Ġ" Z " Ġto Ġ"' single ' Ġquotes ". as Parsed < Any >() ))) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Variable Well Known Values () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġroot Variables Ġ= Ġps Project . variables ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġ// ĠVariable 's Ġpossible Ġvalues Ġare Ġinferred Ġfrom Ġits Ġusage Ġin Ġconfig Ġfiles . ĊĠĠĠ Ġval Ġroot Variable Known Values Ġ= ĊĠĠĠĠĠ ĠP s Variable . Descriptors . variable Value . bind Context ( root Variables . get OrCreate Variable (" root Bool ")). get Known Values (). get () ĊĠĠĠ Ġval Ġroot Variable 2 Known Values Ġ= ĊĠĠĠĠĠ ĠP s Variable . Descriptors . variable Value . bind Context ( root Variables . get OrCreate Variable (" root Bool 2 ")). get Known Values (). get () ĊĠĠĠ Ġval Ġroot Variable 3 Known Values Ġ= ĊĠĠĠĠĠ ĠP s Variable . Descriptors . variable Value . bind Context ( root Variables . get OrCreate Variable (" root Bool 3 ")). get Known Values (). get () ĊĠĠĠ Ġval Ġvariable Known Values Ġ= ĊĠĠĠĠĠ ĠP s Variable . Descriptors . variable Value . bind Context ( variables . get OrCreate Variable (" var Bool ")). get Known Values (). get () ĊĊĠĠĠ ĠassertThat ( root Variable Known Values . literals , ĠequalTo < List < Value Descriptor < Any >> >( boolean Values ( null ). get ())) ĊĠĠĠ ĠassertThat ( root Variable 2 Known Values . literals , ĠequalTo < List < Value Descriptor < Any >> >( boolean Values ( null ). get ())) ĊĠĠĠ ĠassertThat ( root Variable 3 Known Values . literals , ĠequalTo < List < Value Descriptor < Any >> >( boolean Values ( null ). get ())) ĊĠĠĠ ĠassertThat ( variable Known Values . literals , ĠequalTo < List < Value Descriptor < Any >> >( boolean Values ( null ). get ())) ĊĠ Ġ} ĊĊĠ Ġfun ĠtestGet Available Variables ForType () Ġ{ ĊĠĠĠ Ġval Ġstring With Dot s Property : ĠModel Property Context < String > Ġ= Ġobject Ġ: ĠModel Property Context < String > Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġparse ( value : ĠString ): ĠAnnot ated < Parsed Value < String >> Ġ= Ġwhen Ġ{ ĊĠĠĠĠĠĠĠ Ġvalue . contains (".") Ġ-> ĠParsed Value . Set . Parsed ( value , ĠD sl Text . Literal ). annotated () ĊĠĠĠĠĠĠĠ Ġelse Ġ-> ĠParsed Value . Set . Parsed ( null , ĠD sl Text . Other Un parsed Dsl Text ( value )). annotate WithError (" invalid ") ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġoverride Ġfun Ġformat ( value : ĠString ): ĠString Ġ= Ġthrow ĠUnsupportedOperationException () ĊĊĠĠĠĠĠ Ġoverride Ġfun Ġget Known Values (): ĠList enable Future < Known Values < String >> Ġ= ĊĠĠĠĠĠĠĠ Ġthrow ĠUnsupportedOperationException () ĊĠĠĠ Ġ} ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġrun Ġ{ ĊĠĠĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables . get Available Variables For ( string With Dot s Property ). toSet () ĊĠĠĠĠĠ ĠassertThat ( ĊĠĠĠĠĠĠĠ Ġvariables , ĊĠĠĠĠĠĠĠ ĠequalTo ( ĊĠĠĠĠĠĠĠĠĠ Ġset Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" ag p Version X " Ġto Ġ" 3 . 4 . x "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" my Variable " Ġto Ġ" 2 6 . 1 . 0 "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" variable 1 " Ġto Ġ" 1 . 3 "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" another Variable " Ġto Ġ" 3 . 0 . 1 "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" root Float " Ġto Ġ" 3 . 1 4 "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" var Ref String " Ġto Ġ" 1 . 3 "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" local Map . K TS App " Ġto Ġ" com . example . text . K TS App "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" local Map . Local App " Ġto Ġ" com . android . local App "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" version Val " Ġto Ġ" 2 8 . 0 . 0 "). as Parsed (). annotated (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ(" dependency Version " Ġto Ġ" 2 8 . 0 . 0 "). as Parsed (). annotated () ĊĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġfun ĠtestGet Variable Scopes () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġscopes Ġ= Ġps App Module . variables . get Variable Scopes () ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġscopes . map Ġ{ Ġit . name Ġ}, ĊĠĠĠĠĠ ĠequalTo ( listOf (" test Get Variable Scopes Ġ( build Ġscript )", Ġ" test Get Variable Scopes Ġ( project )", Ġ": app ")) ĊĠĠĠ Ġ) ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġscopes . map Ġ{ Ġit . title Ġ}, ĊĠĠĠĠĠ ĠequalTo ( listOf (" Build ĠScript : ĠtestGet Variable Scopes ", Ġ" Project : ĠtestGet Variable Scopes ", Ġ" Module : Ġapp ")) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġfun ĠtestGet New Variable Name () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ ĠassertThat ( ps Project . variables . getNew Variable Name (" some Var "), ĠequalTo (" some Var 1 ")) ĊĠĠĠ ĠassertThat ( ps Project . variables . getNew Variable Name (" other Var "), ĠequalTo (" other Var ")) ĊĠ Ġ} ĊĊĠ Ġfun ĠtestGet OrCreate Variable () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġps App Module Ġ= Ġps Project . find Module ByName (" app ") Ġas ĠP s Android Module ĊĠĠĠ Ġval Ġvariables Ġ= Ġps App Module . variables ĊĠĠĠ Ġval Ġtmp 1 2 3 Ġ= Ġvariables . get OrCreate Variable (" tmp 1 2 3 ") ĊĠĠĠ Ġtmp 1 2 3 . setName (" tmp 3 2 1 ") ĊĠĠĠ Ġtmp 1 2 3 . value Ġ= Ġ" 1 2 3 ". as Parsed () ĊĠĠĠ Ġval Ġsecond Tmp 1 2 3 Ġ= Ġvariables . get Variable (" tmp 1 2 3 ") ĊĠĠĠ ĠassertThat ( second Tmp 1 2 3 , Ġnull Value ()) ĊĠĠĠ Ġval Ġtmp 3 2 1 Ġ= Ġvariables . get OrCreate Variable (" tmp 3 2 1 ") ĊĠĠĠ ĠassertThat ( tmp 3 2 1 . value , ĠequalTo (" 1 2 3 ". as Parsed < Any > ())) ĊĠĠĠ Ġval Ġfloat 2 7 1 Ġ= Ġvariables . get OrCreate Variable (" float 2 7 1 ") ĊĠĠĠ Ġfloat 2 7 1 . value Ġ= ĠBigDecimal (" 2 . 7 1 "). as Parsed < Any >() ĊĠĠĠ ĠassertThat ( float 2 7 1 . value , ĠequalTo ( BigDecimal (" 2 . 7 1 "). as Parsed < Any > ())) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Refresh () Ġ{ ĊĠĠĠ Ġload Project ( Test Project Paths . P SD _ SAMPLE _ GRO OV Y ) ĊĠĠĠ Ġval Ġps Project Ġ= ĠP s Project Impl ( project ) ĊĠĠĠ Ġval Ġvariables Ġ= Ġps Project . variables ĊĠĠĠ Ġval Ġother Variables Ġ= ĠP s Variables ( ps Project , Ġ" other ", Ġ" other ", Ġnull ) ĊĊĠĠĠ Ġassume That ( other Variables . entries . keys , ĠequalTo ( set Of (" some Var ", Ġ" root Bool ", Ġ" root Bool 2 ", Ġ" root Bool 3 ", Ġ" root Float ", Ġ" list Prop ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" map Prop ", Ġ" bool Root ", Ġ" dependency Version "))) ĊĊĠĠĠ Ġval Ġsome Var Ġ= Ġvariables . get Variable (" some Var ") ĊĠĠĠ Ġsome Var ?. setName (" tmp 3 2 1 ") ĊĠĠĠ Ġval Ġroot Bool 2 Ġ= Ġvariables . get Variable (" root Bool 2 ") ĊĠĠĠ Ġroot Bool 2 ?. delete () ĊĠĠĠ Ġval Ġtmp 9 9 9 Ġ= Ġvariables . get OrCreate Variable (" tmp 9 9 9 ") ĊĠĠĠ Ġtmp 9 9 9 . value Ġ= Ġ 9 9 9 . as Parsed () ĊĠĠĠ ĠassertThat ( variables . map Ġ{ Ġit . name Ġ}. toSet (), ĠequalTo ( set Of (" tmp 3 2 1 ", Ġ" root Bool ", Ġ" root Bool 3 ", Ġ" tmp 9 9 9 ", Ġ" root Float ", Ġ" list Prop ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" map Prop ", Ġ" bool Root ", Ġ" dependency Version "))) ĊĊĠĠĠ Ġassume That ( other Variables . entries . keys , ĠequalTo ( set Of (" some Var ", Ġ" root Bool ", Ġ" root Bool 2 ", Ġ" root Bool 3 ", Ġ" root Float ", Ġ" list Prop ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" map Prop ", Ġ" bool Root ", Ġ" dependency Version "))) ĊĠĠĠ Ġother Variables . refresh () ĊĠĠĠ ĠassertThat ( other Variables . entries . keys , ĠequalTo ( set Of (" tmp 3 2 1 ", Ġ" root Bool ", Ġ" root Bool 3 ", Ġ" tmp 9 9 9 ", Ġ" root Float ", Ġ" list Prop ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" map Prop ", Ġ" bool Root ", Ġ" dependency Version "))) ĊĠ Ġ} Ċ } Ċ