/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 2 0 Ġ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 . project . upgrade Ċ Ċ import Ġcom . android . ide . common . repository . Gradle Version Ċ import Ġcom . android . tools . idea . gradle . project . facet . gradle . Gradle Facet Ċ import Ġcom . android . tools . idea . project system . Project System Service Ċ import Ġcom . android . tools . idea . project system . Project System Sync Manager . Sync Result . SUCCESS Ċ import Ġcom . android . tools . idea . testing . Android Gradle TestCase Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . intellij . openapi . module . Module Manager Ċ import Ġjava . io . File Ċ Ċ class ĠA gp Upgrade Assistant IntegrationTest Ġ: ĠAndroid Gradle TestCase () Ġ{ ĊĠ Ġfun Ġtest Upgrade Basic 4 0 () Ġ{ ĊĠĠĠ Ġload Project (" upgrade / Projects / Basic 4 0 ", Ġnull , Ġ" 6 . 1 . 1 ", Ġ" 4 . 0 . 0 ", Ġ" 1 . 3 . 7 2 ") ĊĊĠĠĠ Ġval Ġapp Module Ġ= ĠModule Manager . getInstance ( project ). modules . first Ġ{ Ġit . name Ġ== Ġ" Basic 4 0 . app " Ġ} ĊĠĠĠ ĠassertThat ( Project System Service . getInstance ( project ). project System . get Sync Manager (). getLast Sync Result ()). isEqualTo ( SUCCESS ) ĊĠĠĠ ĠassertThat ( Gradle Facet . getInstance ( app Module )?. configuration ?. LAST _ SUCCESS FUL _ SYNC _ AG P _ VERSION ). isEqualTo (" 4 . 0 . 0 ") ĊĊĠĠĠ Ġval Ġprocessor Ġ= ĠA gp Upgrade Ref actor ing Processor ( project , ĠGradle Version . parse (" 4 . 0 . 0 "), ĠGradle Version . parse (" 4 . 1 . 0 ")) ĊĠĠĠ Ġprocessor . run () ĊĊĠĠĠ ĠassertThat ( Project System Service . getInstance ( project ). project System . get Sync Manager (). getLast Sync Result ()). isEqualTo ( SUCCESS ) ĊĠĠĠ ĠassertThat ( Gradle Facet . getInstance ( app Module )?. configuration ?. LAST _ SUCCESS FUL _ SYNC _ AG P _ VERSION ). isEqualTo (" 4 . 1 . 0 ") ĊĊĠĠĠ Ġ// ĠWe Ġcan 't Ġstraightforward ly Ġassert Ġthe Ġexact Ġcontents Ġof Ġbuild . gradle , Ġbecause Ġthe Ġtest Ġinfrastructure Ġpatches Ġit Ġwith Ġrepository ĊĠĠĠ Ġ// Ġdeclarations Ġto Ġmake Ġit Ġwork Ġin Ġthe Ġtest Ġenvironment ĊĠĠĠ Ġval Ġproject Build File Ġ= ĠFile ( project . basePath , Ġ" build . gradle ") ĊĠĠĠ Ġval Ġproject Build File Lines Ġ= Ġproject Build File . read Lines (). map Ġ{ Ġit . trim () Ġ} ĊĠĠĠ ĠassertThat ( project Build File Lines ). contains (" classpath Ġ' com . android . tools . build : gradle : 4 . 1 . 0 '") ĊĠĠĠ ĠassertThat ( project Build File Lines ). does Not Contain (" google () ") ĊĠĠĠ ĠassertThat ( project Build File Lines ). contains (" ext . kotlin _ version Ġ= Ġ\" 1 . 3 . 7 2 \" ") ĊĊĠĠĠ Ġval Ġapp Build File Ġ= ĠFile ( File ( project . basePath , Ġ" app "), Ġ" build . gradle ") ĊĠĠĠ ĠassertThat ( app Build File . read Text ()). isEqualTo ( File ( File ( project . basePath , Ġ" app "), Ġ" build . gradle . expected "). read Text ()) ĊĊĠĠĠ Ġval Ġgradle Wrapper File Ġ= ĠFile ( File ( File ( project . basePath , Ġ" gradle "), Ġ" wrapper "), Ġ" gradle - wrapper . properties ") ĊĠĠĠ Ġval Ġdistribution Url Line Ġ= Ġgradle Wrapper File . read Lines (). first Ġ{ Ġit . contains (" distribution Url ") Ġ} ĊĠĠĠ ĠassertThat ( distribution Url Line ). contains (" gradle - 7 . 0 . 2 - bin . zip ") ĊĠ Ġ} Ċ }