package Ġde . br ing me ister . spring . aws . k inesis Ċ Ċ import Ġcom . amazonaws . services . k inesis . client library . lib . worker . Worker Ċ import Ġcom . n ha ar man . mockito _ kotlin . any Ċ import Ġcom . n ha ar man . mockito _ kotlin . do Return Ċ import Ġcom . n ha ar man . mockito _ kotlin . eq Ċ import Ġcom . n ha ar man . mockito _ kotlin . mock Ċ import Ġcom . n ha ar man . mockito _ kotlin . verify Ċ import Ġcom . n ha ar man . mockito _ kotlin . wh enever Ċ import Ġorg . junit . Test Ċ Ċ class ĠAws K inesis Inbound Gateway Test Ġ{ ĊĊĠĠĠ Ġval Ġworker Starter : ĠWorker Starter Ġ= Ġmock Ġ{ Ġ} ĊĠĠĠ Ġval Ġworker Ġ= Ġmock < Worker > Ġ{ Ġ} ĊĠĠĠ Ġprivate Ġval Ġhandler Ġ= ĠTest K inesis Inbound Handler () ĊĠĠĠ Ġval Ġmock Record Deserializer Ġ= Ġmock < Record Deserializer < Any , ĠAny >> Ġ{ Ġ} ĊĠĠĠ Ġval Ġmock Record Deserializer Factory Ġ= Ġmock < Record Deserializer Factory > Ġ{ ĊĠĠĠĠĠĠĠ Ġon Ġ{ Ġde serializer For ( handler ) Ġ} Ġdo Return Ġmock Record Deserializer ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġworker Factory : ĠWorker Factory Ġ= Ġmock Ġ{ ĊĠĠĠĠĠĠĠ Ġon Ġ{ Ġworker ( handler , Ġmock Record Deserializer ) Ġ} Ġdo Return Ġworker ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġinbound Gateway Ġ= ĠAws K inesis Inbound Gateway ( worker Factory , Ġworker Starter , Ġmock Record Deserializer Factory ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġregistering Ġa Ġlistener Ġinstance Ġit Ġshould Ġcreate Ġworker `() Ġ{ ĊĠĠĠĠĠĠĠ Ġinbound Gateway . register ( handler ) ĊĠĠĠĠĠĠĠ Ġverify ( worker Factory ). worker ( handler , Ġmock Record Deserializer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` when Ġregistering Ġa Ġlistener Ġinstance Ġit Ġshould Ġrun Ġworker `() Ġ{ ĊĠĠĠĠĠĠĠ Ġinbound Gateway . register ( handler ) ĊĠĠĠĠĠĠĠ Ġverify ( worker Starter ). start ( worker ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġapply Ġpost Ġprocessors Ġto Ġregistered Ġhandlers `() Ġ{ ĊĊĠĠĠĠĠĠĠ Ġwhenever ( mock Record Deserializer Factory . de serializer For < Any , ĠAny >( any ())). thenReturn ( mock Record Deserializer ) ĊĠĠĠĠĠĠĠ Ġwhenever ( worker Factory . worker ( any (), Ġeq ( mock Record Deserializer ))). thenReturn ( worker ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdecor ated Ġ= ĠTest K inesis Inbound Handler () ĊĠĠĠĠĠĠĠ Ġval Ġinbound Gateway Ġ= ĠAws K inesis Inbound Gateway ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġworker Factory , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġworker Starter , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmock Record Deserializer Factory , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf ( Test Post Processor ( decor ated )) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġinbound Gateway . register ( handler ) ĊĊĠĠĠĠĠĠĠ Ġverify ( mock Record Deserializer Factory ). de serializer For ( decor ated ) ĊĠĠĠĠĠĠĠ Ġverify ( worker Factory ). worker ( decor ated , Ġmock Record Deserializer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġclass ĠTest Post Processor ( ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġdecor ated : ĠK inesis Inbound Handler < *, Ġ*> ĊĠĠĠ Ġ): ĠK inesis Inbound Handler Post Processor Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġpost Process ( handler : ĠK inesis Inbound Handler < *, Ġ* >) Ġ= Ġdecor ated ĊĠĠĠ Ġ} Ċ } Ċ