package Ġdev . ar unk umar . sc abb ard . plugin . processor . graph viz Ċ Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġdagger . Component Ċ import Ġdagger . Sub component Ċ import Ġdev . ar unk umar . sc abb ard . plugin . generated Dot Ċ import Ġdev . ar unk umar . sc abb ard . plugin . generated Graph Ċ import Ġg uru . n idi . graph viz . model . Mutable Graph Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġjavax . inject . Inject Ċ import Ġjavax . inject . Scope Ċ import Ġjavax . inject . Singleton Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠScope Test Ġ{ ĊĊĠ Ġclass ĠNode A Ġ@ Inject Ġconstructor () ĊĊĠ Ġ@ Singleton ĊĠ Ġclass ĠNode B Ġ@ Inject Ġconstructor ( private Ġval Ġnode A : ĠNode A ) ĊĊĠ Ġ@ Singleton ĊĠ Ġ@ Component ĊĠ Ġinterface ĠSimple Component Ġ{ ĊĠĠĠ Ġfun Ġnode B (): ĠNode B ĊĠĠĠ Ġfun Ġsub Component Factory (): ĠSimple Sub Component . Factory ĊĠĠĠ Ġfun Ġun Scoped Component Factory (): ĠUn Scoped Sub Component . Factory ĊĠ Ġ} ĊĊĠ Ġ@ Scope ĊĠ Ġannotation Ġclass ĠSub Scope ĊĊĠ Ġ@ Sub Scope ĊĠ Ġclass ĠAnother Sub component Node Ġ@ Inject Ġconstructor () ĊĊĠ Ġ@ Sub Scope ĊĠ Ġclass ĠSub Component Node ĊĠ Ġ@ Inject ĊĠ Ġconstructor ( ĊĠĠĠ Ġval Ġnode B : ĠNode B , ĊĠĠĠ Ġprivate Ġval Ġanother Sub component Node : ĠAnother Sub component Node ĊĠ Ġ) ĊĊĠ Ġ@ Sub Scope ĊĠ Ġ@ Sub component ĊĠ Ġinterface ĠSimple Sub Component Ġ{ ĊĠĠĠ Ġfun Ġsub component Node (): ĠSub Component Node ĊĊĠĠĠ Ġ@ Sub component . Factory ĊĠĠĠ Ġinterface ĠFactory Ġ{ ĊĠĠĠĠĠ Ġfun Ġcreate (): ĠSimple Sub Component ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġclass ĠUn Scoped Sub Component Node Ġ@ Inject Ġconstructor () ĊĊĠ Ġ@ Sub component ĊĠ Ġinterface ĠUn Scoped Sub Component Ġ{ ĊĠĠĠ Ġfun Ġun Scoped Sub Component Node (): ĠUn Scoped Sub Component Node ĊĊĠĠĠ Ġ@ Sub component . Factory ĊĠĠĠ Ġinterface ĠFactory Ġ{ ĊĠĠĠĠĠ Ġfun Ġcreate (): ĠUn Scoped Sub Component ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġlateinit Ġvar Ġsimple Component : ĠString ĊĠ Ġprivate Ġlateinit Ġvar Ġsimple Sub component : ĠString ĊĠ Ġprivate Ġlateinit Ġvar Ġsimple Graph : ĠMutable Graph ĊĊĠ Ġ@ Before ĊĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠ Ġsimple Component Ġ= Ġgenerated Dot < Simple Component >() ĊĠĠĠ Ġsimple Sub component Ġ= Ġgenerated Dot < Simple Sub Component >() ĊĠĠĠ Ġsimple Graph Ġ= Ġgenerated Graph < Simple Component >() ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġnodes Ġpresent Ġin Ġa Ġscope Ġhave Ġdifferent Ġbut Ġconsistent Ġcolors Ġset `() Ġ{ ĊĠĠĠ ĠassertThat ( simple Sub component ) ĊĠĠĠĠĠ Ġ. contains ("[ label =\" @ Sub Scope \\ n Scope Test . Another Sub component Node \", Ġcolor =\" bis que \"] ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġroot Ġcomponent Ġlinks Ġto Ġall Ġsub components Ġand Ġsub components Ġhave Ġcolors Ġset Ġon Ġthem `() Ġ{ ĊĠĠĠ ĠassertThat ( simple Component ) ĊĠĠĠĠĠ Ġ. contains (" label =\" @ Sub Scope \\ n Scope Test . Simple Sub Component \" ") ĊĠĠĠ ĠassertThat ( simple Component ) ĊĠĠĠĠĠ Ġ. contains (" color =\" aqu amar ine \" ") ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġ` test Ġun scoped Ġsub component Ġhas Ġthe Ġdefault Ġcolor Ġset `() Ġ{ ĊĠĠĠ Ġval Ġsub component Attrs Ġ= Ġsimple Graph . graphs () ĊĠĠĠĠĠ Ġ. first Ġ{ Ġit . name () Ġ== Ġ" Sub components " Ġ} ĊĠĠĠĠĠ Ġ. nodes () ĊĠĠĠĠĠ Ġ. first Ġ{ Ġnode Ġ-> ĊĠĠĠĠĠĠĠ Ġnode . attrs () ĊĠĠĠĠĠĠĠĠĠ Ġ. any Ġ{ Ġit . value . toString (). contains ( Un Scoped Sub Component :: class . java . simple Name ) Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ ĠassertThat ( sub component Attrs ). has Size ( 2 ) ĊĠĠĠ ĠassertThat ( sub component Attrs . none Ġ{ Ġit . key Ġ== Ġ" color " Ġ}) ĊĠ Ġ} Ċ } Ċ