package Ġcom . l uk av ille . tooth pick . reflect Ċ Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġorg . hamcrest . Matcher Assert . assertThat Ċ import Ġorg . hamcrest . core . Is Equal Ċ import Ġorg . junit . Ignore Ċ import Ġorg . junit . Test Ċ import Ġtoo th pick . Scope Ċ Ċ class ĠReflect ive Factory Scope Test Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġscope : ĠScope Ġ= Ġmock () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` no Ġscope Ġannotation Ġ- Ġreturns Ġthe Ġsame Ġtarget Ġscope `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Empty Constructor Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġtarget Scope Ġ= Ġfactory . getTarget Scope ( scope ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( target Scope , ĠIs Equal ( scope )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` singleton Ġscope Ġannotation Ġ- Ġreturns Ġroot Ġtarget Ġscope `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġroot Scope Ġ= Ġmock < Scope >() ĊĠĠĠĠĠĠĠ Ġwhenever ( scope . rootScope ). thenReturn ( rootScope ) ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Singleton Empty Constructor Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġtarget Scope Ġ= Ġfactory . getTarget Scope ( scope ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( target Scope , ĠIs Equal ( rootScope )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` custom Ġscope Ġannotation Ġ- Ġreturns Ġparent Ġtarget Ġscope `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġparent Scope Ġ= Ġmock < Scope >() ĊĠĠĠĠĠĠĠ Ġwhenever ( scope . getParent Scope ( Custom Scope :: class . java )). thenReturn ( parent Scope ) ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Custom Scope Empty Constructor Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġtarget Scope Ġ= Ġfactory . getTarget Scope ( scope ) ĊĊĠĠĠĠĠĠĠ ĠassertThat ( target Scope , ĠIs Equal ( parent Scope )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` singleton Ġannotation Ġ- Ġreturns Ġhas Ġscope Ġannotation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Singleton Empty Constructor Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġhas Scope Annotation Ġ= Ġfactory . has Scope Annotation () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( has Scope Annotation , ĠIs Equal ( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` custom Ġscope Ġannotation Ġ- Ġreturns Ġhas Ġscope Ġannotation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Custom Scope Empty Constructor Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġhas Scope Annotation Ġ= Ġfactory . has Scope Annotation () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( has Scope Annotation , ĠIs Equal ( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" provides Ġsingleton Ġin Ġscope Ġannotation Ġis Ġnot Ġavailable Ġin Ġruntime ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` provides Ġsingleton Ġin Ġscope Ġannotation Ġ- Ġreturns Ġhas Ġprovides Ġsingleton Ġin Ġscope Ġannotation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Provides Singleton In Scope Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġhas Provides Singleton In Scope Annotation Ġ= Ġfactory . has Provides Singleton In Scope Annotation () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( has Provides Singleton In Scope Annotation , ĠIs Equal ( true )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Ignore (" provides Ġsingleton Ġin Ġscope Ġannotation Ġis Ġnot Ġavailable Ġin Ġruntime ") ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` no Ġprovides Ġsingleton Ġin Ġscope Ġannotation Ġ- Ġreturns Ġdoes Ġnot Ġhave Ġprovides Ġsingleton Ġin Ġscope Ġannotation `() Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= Ġcreate Factory < Empty Constructor Class >() ĊĊĠĠĠĠĠĠĠ Ġval Ġhas Provides Singleton In Scope Annotation Ġ= Ġfactory . has Provides Singleton In Scope Annotation () ĊĊĠĠĠĠĠĠĠ ĠassertThat ( has Provides Singleton In Scope Annotation , ĠIs Equal ( false )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġinline Ġfun Ġ< re ified ĠT > Ġcreate Factory (): ĠReflect ive Factory < T > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠReflect ive Factory ( T :: class . java ) ĊĠĠĠ Ġ} Ċ } Ċ