package Ġfr . free . n rw . commons . campaign s Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . view . View Ċ import Ġfr . free . n rw . commons . Test App Adapter Ċ import Ġfr . free . n rw . commons . Test Common s Application Ċ import Ġfr . free . n rw . commons . cont ributions . MainActivity Ċ 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 Annotations Ċ import Ġorg . ro bo lectric . Ro bo lectric Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . android . controller . Activity Controller Ċ import Ġorg . ro bo lectric . annotation . Config Ċ import Ġorg . wikipedia . App Adapter Ċ import Ġjava . lang . reflect . Method Ċ Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ @ Config ( sdk Ġ= Ġ[ 2 1 ], Ġapplication Ġ= ĠTest Common s Application :: class ) Ċ class ĠCampaign View UnitTests Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġactivity Controller : ĠActivity Controller < Activity > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġactivity : ĠMainActivity ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcampaign View : ĠCampaign View ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcampaign : ĠCampaign ĊĊĠĠĠ Ġ@ Mock ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview : ĠView ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠMockito Annotations . init Mocks ( this ) ĊĊĠĠĠĠĠĠĠ ĠApp Adapter . set ( Test App Adapter ()) ĊĊĠĠĠĠĠĠĠ Ġactivity Controller Ġ= ĠRo bo lectric . build Activity ( Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġactivity Ġ= ĠRo bo lectric . build Activity ( MainActivity :: class . java ). create (). get () ĊĊĠĠĠĠĠĠĠ Ġcampaign View Ġ= ĠCampaign View ( activity ) ĊĠĠĠĠĠĠĠ Ġcampaign View Ġ= ĠCampaign View ( activity , Ġnull ) ĊĠĠĠĠĠĠĠ Ġcampaign View Ġ= ĠCampaign View ( activity , Ġnull , Ġ 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun ĠcheckNotNull () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( campaign View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Set Campaign NonNull Non Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġcampaign Ġ= ĠCampaign ("", Ġ"", Ġ" 2 0 0 0 - 0 1 - 0 1 ", Ġ" 2 0 0 0 - 0 1 - 0 2 ", Ġ"") ĊĠĠĠĠĠĠĠ Ġcampaign View . set Campaign ( campaign ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Set Campaign NonNull Exception () Ġ{ ĊĠĠĠĠĠĠĠ Ġcampaign Ġ= ĠCampaign ("", Ġ"", Ġ"", Ġ"", Ġ"") ĊĠĠĠĠĠĠĠ Ġcampaign View . set Campaign ( campaign ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Set Campaign Null () Ġ{ ĊĠĠĠĠĠĠĠ Ġcampaign View . set Campaign ( null ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest On Swipe () Ġ{ ĊĠĠĠĠĠĠĠ Ġcampaign View . on Swipe ( view ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ Throws ( Exception :: class ) ĊĠĠĠ Ġfun Ġtest Init () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmethod : ĠMethod Ġ= ĠCampaign View :: class . java . getDeclared Method ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" init " ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġmethod . is Accessible Ġ= Ġtrue ĊĠĠĠĠĠĠĠ Ġmethod . invoke ( campaign View ) ĊĠĠĠ Ġ} Ċ Ċ }