package Ġcom . ke val p ate l 2 1 0 6 . y ip . edit . color Picker Ċ Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . ke val p ate l 2 1 0 6 . y ip . entity . Deadline Color Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . mockito . Mock Ċ import Ġorg . mockito . Mockito Ċ import Ġorg . mockito . Mockito Annotations Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . Runtime Environment ĊĊ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ class ĠColors Adapter Test Ġ{ ĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġcolor Selected Listener : ĠColor Picker Listener ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġinternal Ġlateinit Ġvar Ġdata Observer : ĠRecyclerView . Adapter Data Observer ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠColors Adapter ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġbefore () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠColors Adapter ( Runtime Environment . application , Ġcolor Selected Listener ) ĊĠĠĠĠĠĠĠ Ġadapter . register Adapter Data Observer ( data Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter . unregister Adapter Data Observer ( data Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck ListOf Colors () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( adapter . colors . isNotEmpty ()) ĊĊĠĠĠĠĠĠĠ Ġval Ġsupported Color Ġ= ĠDead line Color . values () ĊĠĠĠĠĠĠĠ Ġadapter . colors . forEach Indexed Ġ{ Ġindex , Ġcolor States Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( color States , ĠColor States ( supported Color [ index ]. color Int , Ġfalse )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Setting Lock Ref res hes List () Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter . is Locked Ġ= Ġtrue ĊĠĠĠĠĠĠĠ ĠMockito . verify ( data Observer , ĠMockito . times ( 1 )). on Changed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcheck Set Selected Color () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġselected Color Ġ= ĠDead line Color . COLOR _ GRAY . color Int ĊĠĠĠĠĠĠĠ Ġadapter . setSelected Color ( selected Color ) ĊĊĠĠĠĠĠĠĠ Ġadapter . colors . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAssert . assertEquals ( it . color Ġ== Ġselected Color , Ġit . isSelected ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠMockito . verify ( data Observer , ĠMockito . times ( 1 )). on Changed () ĊĠĠĠ Ġ} Ċ } Ċ