/* Ċ Ġ* Ġ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 . build . output Ċ Ċ import Ġcom . android . tools . idea . gradle . project . sync . quick Fixes . Open Link Quick Fix Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . intellij . build . events . Build Event Ċ import Ġcom . intellij . build . events . Build Issue Event Ċ import Ġcom . intellij . build . output . Build Output Instant Reader Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Argument Captor Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito .` when ` Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġjava . util . function . Consumer Ċ Ċ class ĠInstant Execution Report Parser Test Ġ{ ĊĠ Ġ@ Mock ĊĠ Ġlateinit Ġvar Ġreader : ĠBuild Output Instant Reader ĊĠ Ġ@ Mock ĊĠ Ġlateinit Ġvar Ġmessage Consumer : ĠConsumer < in ĠBuild Event ?> ĊĊĠ Ġprivate Ġlateinit Ġvar Ġparser : ĠInstant Execution Report Parser ĊĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠ Ġparser Ġ= ĠInstant Execution Report Parser () ĊĠĠĠ Ġ` when `( reader . parent EventId ). thenReturn (" test Id ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` No Ġerrors Ġreturn Ġfalse `() Ġ{ ĊĠĠĠ ĠassertThat ( parser . parse (" This Ġis Ġnot Ġan ĠInstant Ġexecution Ġerror Ġline ", Ġreader , Ġmessage Consumer )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` No Ġline Ġreturn Ġfalse `() Ġ{ ĊĠĠĠ ĠassertThat ( parser . parse ( null , Ġreader , Ġmessage Consumer )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` No Ġreader Ġreturn Ġfalse `() Ġ{ ĊĠĠĠ Ġval Ġurl Report Ġ= Ġ" file :/// path / to / instant - execution - report . html " ĊĠĠĠ Ġval Ġerror Line Ġ= Ġ" See Ġthe Ġcomplete Ġreport Ġat Ġ$ url Report " ĊĠĠĠ ĠassertThat ( parser . parse ( error Line , Ġnull , Ġmessage Consumer )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` No Ġmessage Consumer Ġreturn Ġfalse `() Ġ{ ĊĠĠĠ Ġval Ġurl Report Ġ= Ġ" file :/// path / to / instant - execution - report . html " ĊĠĠĠ Ġval Ġerror Line Ġ= Ġ" See Ġthe Ġcomplete Ġreport Ġat Ġ$ url Report " ĊĠĠĠ ĠassertThat ( parser . parse ( error Line , Ġreader , Ġnull )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` No Ġinstant Ġexecution Ġreport Ġhtml Ġreturn Ġfalse `() Ġ{ ĊĠĠĠ Ġval Ġurl Report Ġ= Ġ" file :/// path / to / other - report . html " ĊĠĠĠ Ġval Ġerror Line Ġ= Ġ" See Ġthe Ġcomplete Ġreport Ġat Ġ$ url Report " ĊĠĠĠ ĠassertThat ( parser . parse ( error Line , Ġreader , Ġmessage Consumer )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Extra Ġcharacters Ġreturn Ġfalse `() Ġ{ ĊĠĠĠ Ġval Ġurl Report Ġ= Ġ" file :/// path / to / instant - execution - report . html " ĊĠĠĠ Ġval Ġerror Line Ġ= Ġ" See Ġthe Ġcomplete Ġreport Ġat Ġ$ url Report . ĠThis Ġis Ġan Ġadditional Ġmessage ." ĊĠĠĠ ĠassertThat ( parser . parse ( error Line , Ġreader , Ġmessage Consumer )). isFalse () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Report Ġlink Ġis Ġcreated `() Ġ{ ĊĠĠĠ Ġval Ġurl Report Ġ= Ġ" file :/// path / to / instant - execution - report . html " ĊĠĠĠ Ġval Ġerror Line Ġ= Ġ" See Ġthe Ġcomplete Ġreport Ġat Ġ$ url Report " ĊĠĠĠ Ġverify Link ( url Report , Ġerror Line ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` Report Ġlink Ġis Ġcreated Ġwith Ġwhite Ġspaces `() Ġ{ ĊĠĠĠ Ġval Ġurl Report Ġ= Ġ" file :/// path / to / instant - execution - report . html " ĊĠĠĠ Ġval Ġerror Line Ġ= Ġ" Ġ ĠSee Ġthe Ġcomplete Ġreport Ġat Ġ$ url Report Ġ\ n " ĊĠĠĠ Ġverify Link ( url Report , Ġerror Line ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġverify Link ( url Report : ĠString , Ġerror Line : ĠString ) Ġ{ ĊĠĠĠ Ġval Ġcapt or Ġ= ĠArgument Captor . for Class ( Build Event :: class . java ) ĊĠĠĠ ĠassertThat ( parser . parse ( error Line , Ġreader , Ġmessage Consumer )). isTrue () ĊĠĠĠ Ġverify ( message Consumer ). accept ( capt or . capture ()) ĊĠĠĠ Ġval Ġevents Ġ= Ġcapt or . all Values ĊĠĠĠ ĠassertThat ( events ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( events [ 0 ]). isInstanceOf ( Build Issue Event :: class . java ) ĊĠĠĠ Ġval Ġquick Fixes Ġ= Ġ( events [ 0 ] Ġas ĠBuild Issue Event ). issue . quick Fixes ĊĠĠĠ ĠassertThat ( quick Fixes ). has Size ( 1 ) ĊĠĠĠ ĠassertThat ( quick Fixes [ 0 ]). isInstanceOf ( Open Link Quick Fix :: class . java ) ĊĠĠĠ ĠassertThat (( quick Fixes [ 0 ] Ġas ĠOpen Link Quick Fix ). link ). isEqualTo ( url Report ) ĊĠ Ġ} Ċ }