package Ġcom . re mb ert ime . notification . domain . notification Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . net . Uri Ċ import Ġandroid . os . Build Ċ import Ġandroid . util . Log Ċ import Ġandroidx . core . app . Notification Compat . FLAG _ ONLY _ ALERT _ ON CE Ċ import Ġandroidx . test . core . app . Application Provider Ċ import Ġandroidx . work . Configuration Ċ import Ġandroidx . work . testing . S ynchronous Executor Ċ import Ġandroidx . work . testing . Work Manager Test Init Helper Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . re mb ert ime . notification . domain . model . Work Notification Model Ċ import Ġcom . re mb ert ime . notification . util . extensions . create Open Share Pending Intent Ċ import Ġjunit . framework . Assert . assertEquals Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . ro bo lectric . Ro bo lectric TestRunner Ċ import Ġorg . ro bo lectric . annotation . Config Ċ import Ġjava . util . UUID Ċ Ċ @ Config ( sdk Ġ= Ġ[ Build . VERSION _ CODES . M ]) Ċ @ RunWith ( Ro bo lectric TestRunner :: class ) Ċ internal Ġclass ĠNotification Factory Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġfactory : ĠNotification Factory ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmodel : ĠWork Notification Model ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġcontext : ĠContext ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġcontext Ġ= ĠApplication Provider . getApplicationContext () ĊĠĠĠĠĠĠĠ Ġfactory Ġ= ĠNotification Factory ( context ) ĊĠĠĠĠĠĠĠ Ġval Ġconfig Ġ= ĠConfiguration . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. setMinimum Logging Level ( Log . DEBUG ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Executor ( S ynchronous Executor ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠ ĠWork Manager Test Init Helper . initialize Test Work Manager ( context , Ġconfig ) ĊĠĠĠĠĠĠĠ Ġmodel Ġ= Ġcreate Work Notification Model () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Create Pending Notification Then Retrieve Notification With Cancel Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuuid : ĠUUID Ġ= Ġmock () ĊĊĠĠĠĠĠĠĠ Ġval Ġnotification Builder Ġ= Ġfactory . create Pending Notification ( model , Ġuuid ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( notification Builder . build (). actions [ 0 ]. title , Ġ" CANCEL ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ( expected Ġ= ĠNoSuch Method Error :: class ) ĊĠĠĠ Ġfun Ġgiven Create Notification On Api LessThan Q Then Retrieve Notification Without Channel Id () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuuid : ĠUUID Ġ= Ġmock () ĊĊĠĠĠĠĠĠĠ Ġval Ġnotification Builder Ġ= Ġfactory . create Pending Notification ( model , Ġuuid ) ĊĊĠĠĠĠĠĠĠ Ġnotification Builder . build (). channelId ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Create Success Notification Then Retrieve Open Share Intent Notification () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuri : ĠUri Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġnotification Builder Ġ= Ġfactory . create Success Notification ( model , Ġuri ) ĊĊĠĠĠĠĠĠĠ Ġassert ( notification Builder . build (). content Intent Ġ== Ġcontext . create Open Share Pending Intent ( model . fileName , Ġuri )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Create Success Notification Then Retrieve Only Alert Once Notification () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġuri : ĠUri Ġ= Ġmock () ĊĠĠĠĠĠĠĠ Ġval Ġnotification Builder Ġ= Ġfactory . create Success Notification ( model , Ġuri ) ĊĊĠĠĠĠĠĠĠ Ġassert ( notification Builder . build (). flags Ġ== ĠFLAG _ ONLY _ ALERT _ ON CE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġgiven Create Error Notification Then Retrieve Only Alert Once Notification () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnotification Builder Ġ= Ġfactory . create Error Notification ( model , Ġ" error ") ĊĊĠĠĠĠĠĠĠ Ġassert ( notification Builder . build (). flags Ġ== ĠFLAG _ ONLY _ ALERT _ ON CE ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Work Notification Model () Ġ= ĠWork Notification Model (). apply Ġ{ ĊĠĠĠĠĠĠĠ ĠfilePath Ġ= Ġ" http :// www . domain . com / book . pdf " ĊĠĠĠĠĠĠĠ ĠfileName Ġ= Ġ" book . pdf " ĊĠĠĠĠĠĠĠ Ġchannel Id Ġ= Ġ" channelId " ĊĠĠĠĠĠĠĠ Ġchannel Name Ġ= Ġ" Download " ĊĠĠĠĠĠĠĠ Ġnotification Id Ġ= Ġ 0 ĊĠĠĠĠĠĠĠ Ġnotification Title Ġ= Ġ" book " ĊĠĠĠĠĠĠĠ Ġnotification Content Ġ= Ġ" content " ĊĠĠĠĠĠĠĠ Ġapplication Icon Ġ= Ġ 1 ĊĠĠĠ Ġ} Ċ }