/* Ċ Ġ* Ġ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 . sync . errors Ċ Ċ import Ġcom . android . tools . idea . gradle . project . build . output . Test Message Event Consumer Ċ import Ġcom . android . tools . idea . testing . Android Gradle TestCase Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . intellij . util . System Properties Ċ import Ġorg . jetbrains . plugins . gradle . issue . Gradle Issue Data Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġjava . io . File Ċ Ċ class ĠFailed To Parse Sdk Issue Checker Test : ĠAndroid Gradle TestCase () Ġ{ ĊĠ Ġprivate Ġval Ġfailed To Parse Sdk Issue Checker Ġ= ĠFailed To Parse Sdk Issue Checker () ĊĊĠ Ġfun Ġtest Check Issue Without Broken Sdk () Ġ{ ĊĠĠĠ Ġval Ġissue Data Ġ= ĠGradle Issue Data ( project FolderPath . path , ĠRuntimeException (" failed Ġto Ġparse ĠSDK "), Ġnull , Ġnull ) ĊĠĠĠ Ġval Ġbuild Issue Ġ= Ġfailed To Parse Sdk Issue Checker . check ( issue Data ) ĊĊĠĠĠ ĠassertThat ( build Issue ). isNotNull () ĊĠĠĠ ĠassertThat ( build Issue !!. description ). contains (" failed Ġto Ġparse ĠSDK ") ĊĠĠĠ ĠassertThat ( build Issue . quick Fixes ). has Size ( 0 ) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Check Issue With Broken Sdk Android No Write Access () Ġ{ ĊĠĠĠ Ġval Ġsdk Path : ĠFile Ġ= Ġobject Ġ: ĠFile ("/ path / to / sdk / home ") Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġcan Write (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġfalse ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġmock Checker Ġ= ĠMockito . spy ( failed To Parse Sdk Issue Checker ) ĊĠĠĠ Ġ` when `( mock Checker . find Path Of Sdk Without Addons Folder ( project FolderPath . path )). thenReturn ( sdk Path ) ĊĊĠĠĠ Ġval Ġissue Data Ġ= ĠGradle Issue Data ( project FolderPath . path , ĠRuntimeException (" failed Ġto Ġparse ĠSDK "), Ġnull , Ġnull ) ĊĠĠĠ Ġval Ġbuild Issue Ġ= Ġmock Checker . check ( issue Data ) ĊĊĠĠĠ ĠassertThat ( build Issue ). isNotNull () ĊĠĠĠ ĠassertThat ( build Issue !!. description ). contains ( ĊĠĠĠĠĠ Ġ(" The Ġdirectory Ġ' add - ons ', Ġin Ġthe ĠAndroid ĠSDK Ġat Ġ'/ path / to / sdk / home ', Ġis Ġeither Ġmissing Ġor Ġempty \ n \ n " Ġ+ ĊĠĠĠĠĠĠ Ġ" Current Ġuser Ġ(' ${ System Properties . getUser Name ()} ') Ġdoes Ġnot Ġhave Ġwrite Ġaccess Ġto Ġthe ĠSDK Ġdirectory .")) ĊĠĠĠ ĠassertThat ( build Issue . quick Fixes ). has Size ( 0 ) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Check Issue With Broken Sdk Android Write Access () Ġ{ ĊĠĠĠ Ġval Ġsdk Path : ĠFile Ġ= Ġobject Ġ: ĠFile ("/ path / to / sdk / home ") Ġ{ ĊĠĠĠĠĠ Ġoverride Ġfun Ġcan Write (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġmock Checker Ġ= ĠMockito . spy ( failed To Parse Sdk Issue Checker ) ĊĠĠĠ Ġ` when `( mock Checker . find Path Of Sdk Without Addons Folder ( project FolderPath . path )). thenReturn ( sdk Path ) ĊĊĠĠĠ Ġval Ġissue Data Ġ= ĠGradle Issue Data ( project FolderPath . path , ĠRuntimeException (" failed Ġto Ġparse ĠSDK "), Ġnull , Ġnull ) ĊĠĠĠ Ġval Ġbuild Issue Ġ= Ġmock Checker . check ( issue Data ) ĊĊĠĠĠ ĠassertThat ( build Issue ). isNotNull () ĊĠĠĠ ĠassertThat ( build Issue !!. description ). contains ( ĊĠĠĠĠĠ Ġ" The Ġdirectory Ġ' add - ons ', Ġin Ġthe ĠAndroid ĠSDK Ġat Ġ'/ path / to / sdk / home ', Ġis Ġeither Ġmissing Ġor Ġempty ") ĊĠĠĠ ĠassertThat ( build Issue . quick Fixes ). has Size ( 0 ) ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Check Issue Handled () Ġ{ ĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġfailed To Parse Sdk Issue Checker . consume Build Output Failure Message ( ĊĠĠĠĠĠĠĠ Ġ" Build Ġfailed Ġwith ĠException ", ĊĠĠĠĠĠĠĠ Ġ" Build Ġfailed Ġwith ĠException : Ġfailed Ġto Ġparse ĠSDK ", ĊĠĠĠĠĠĠĠ Ġ" Cause d Ġby : Ġjava . lang . RuntimeException ", ĊĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠ ĠTest Message Event Consumer () ĊĠĠĠĠĠ Ġ )). isEqualTo ( true ) ĊĊĠĠĠ ĠassertThat ( ĊĠĠĠĠĠ Ġfailed To Parse Sdk Issue Checker . consume Build Output Failure Message ( ĊĠĠĠĠĠĠĠ Ġ" Build Ġfailed Ġwith ĠException ", ĊĠĠĠĠĠĠĠ Ġ" Build Ġfailed Ġwith ĠException : Ġfailed Ġto Ġparse ĠSDK ", ĊĠĠĠĠĠĠĠ Ġ" Cause d Ġby : Ġjava . net . Socket Exception ", ĊĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠ Ġ"", ĊĠĠĠĠĠĠĠ ĠTest Message Event Consumer () ĊĠĠĠĠĠ Ġ )). isEqualTo ( false ) ĊĠ Ġ} Ċ }