package Ġuk . gov . just ice . h mp ps . sqs Ċ Ċ import Ġcom . amazonaws . services . sns . Amazon S NS Ċ import Ġcom . amazonaws . services . sqs . Amazon SQ S Ċ import Ġcom . amazonaws . services . sqs . Amazon SQ S Async Ċ import Ġcom . amazonaws . services . sqs . model . Create Queue Request Ċ import Ġcom . amazonaws . services . sqs . model . Get Queue Attributes Result Ċ import Ġcom . amazonaws . services . sqs . model . Get Queue Url Result Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . any Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . check Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . eq Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . mock Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . verify No More Interactions Ċ import Ġcom . n ha ar man . mock it ok otlin 2 . wh enever Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Nested Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġorg . mockito . Argument Matchers . any Boolean Ċ import Ġorg . mockito . Argument Matchers . any List Ċ import Ġorg . mockito . Argument Matchers . any String Ċ import Ġorg . springframework . beans . factory . config . Configurable List able BeanFactory Ċ import Ġorg . springframework . context . Configurable ApplicationContext Ċ import Ġuk . gov . just ice . h mp ps . sqs . H mp ps S qs Properties . Queue Config Ċ import Ġuk . gov . just ice . h mp ps . sqs . H mp ps S qs Properties . Topic Config Ċ Ċ class ĠH mp ps Queue Factory Test Ġ{ ĊĊĠ Ġprivate Ġval Ġlocal stack Arn Prefix Ġ= Ġ" arn : aws : sns : eu - west - 2 : 0 0 0 0 0 0 0 0 0 0 0 0 :" ĊĊĠ Ġprivate Ġval Ġcontext Ġ= Ġmock < Configurable ApplicationContext >() ĊĠ Ġprivate Ġval Ġbean Factory Ġ= Ġmock < Configurable List able BeanFactory >() ĊĠ Ġprivate Ġval Ġsq s Factory Ġ= Ġmock < Amazon S qs Factory >() ĊĠ Ġprivate Ġval Ġh mp ps Queue Factory Ġ= ĠH mp ps Queue Factory ( context , Ġsq s Factory ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġwhenever ( context . bean Factory ). thenReturn ( bean Factory ) ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create Ġsingle ĠAWS ĠH mp ps Queue ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( queue Name Ġ= Ġ" some Ġqueue Ġname ", Ġqueue Access KeyId Ġ= Ġ" some Ġaccess Ġkey Ġid ", Ġqueue Secret AccessKey Ġ= Ġ" some Ġsecret Ġaccess Ġkey ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ", Ġdl q Access KeyId Ġ= Ġ" dl q Ġaccess Ġkey Ġid ", Ġdl q Secret AccessKey Ġ= Ġ" dl q Ġsecret Ġaccess Ġkey ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( queues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` creates Ġaws Ġsq s Ġdl q Ġclient Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs D lq Client (" some queue id ", Ġ" some Ġdl q Ġname ", Ġ" dl q Ġaccess Ġkey Ġid ", Ġ" dl q Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` creates Ġaws Ġsq s Ġclient Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs Client (" some queue id ", Ġ" some Ġqueue Ġname ", Ġ" some Ġaccess Ġkey Ġid ", Ġ" some Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue Ġdetails `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. id ). isEqualTo (" some queue id ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue ĠAmazon SQ S Ġclient `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs Client ). isEqualTo ( sqs Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue Ġname `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. queue Name ). isEqualTo (" some Ġqueue Ġname ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue Ġurl `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. queue Url ). isEqualTo (" some Ġqueue Ġurl ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġdl q Ġclient `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs D lq Client ). isEqualTo ( sqs D lq Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġdl q Ġname `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. dl q Name ). isEqualTo (" some Ġdl q Ġname ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġdl q Ġurl `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. dl q Url ). isEqualTo (" some Ġdl q Ġurl ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġa Ġhealth Ġindicator `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - health "), Ġany < H mp ps Queue Health >()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġthe Ġsq s Ġclient `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton (" some queue id - sqs - client ", Ġsq s Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġthe Ġsq s Ġdl q Ġclient `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton (" some queue id - sqs - dl q - client ", Ġsq s D lq Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġthe Ġj ms Ġlistener Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - jms - listener - factory "), Ġany < H mp ps Queue Destination Container Factory >()) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create Ġsingle ĠLocal Stack ĠH mp ps Queue ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( queue Name Ġ= Ġ" some Ġqueue Ġname ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( provider Ġ= Ġ" local stack ", Ġqueues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . local Stack S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . local Stack S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Attributes ( any String (), Ġany List ())). thenReturn ( Get Queue Attributes Result (). with Attributes ( map Of (" Queue Arn " Ġto Ġ" some Ġdl q Ġar n "))) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` creates ĠLocal Stack Ġsq s Ġdl q Ġclient Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). local Stack S qs D lq Client ( queue Id Ġ= Ġ" some queue id ", Ġlocal stack Url Ġ= Ġ" http :// localhost : 4 5 6 6 ", Ġregion Ġ= Ġ" eu - west - 2 ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ", Ġasync Client Ġ= Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` creates ĠLocal Stack Ġsq s Ġclient Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). local Stack S qs Client ( queue Id Ġ= Ġ" some queue id ", Ġlocal stack Url Ġ= Ġ" http :// localhost : 4 5 6 6 ", Ġregion Ġ= Ġ" eu - west - 2 ", Ġqueue Name Ġ= Ġ" some Ġqueue Ġname ", Ġasync Client Ġ= Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue Ġdetails `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. id ). isEqualTo (" some queue id ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue ĠAmazon SQ S Ġclient `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs Client ). isEqualTo ( sqs Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue Ġname `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. queue Name ). isEqualTo (" some Ġqueue Ġname ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue Ġurl `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. queue Url ). isEqualTo (" some Ġqueue Ġurl ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġdl q Ġclient `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs D lq Client ). isEqualTo ( sqs D lq Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġdl q Ġname `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. dl q Name ). isEqualTo (" some Ġdl q Ġname ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġdl q Ġurl `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. dl q Url ). isEqualTo (" some Ġdl q Ġurl ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġa Ġhealth Ġindicator `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - health "), Ġany < H mp ps Queue Health >()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġthe Ġsq s Ġclient `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton (" some queue id - sqs - client ", Ġsq s Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġthe Ġsq s Ġdl q Ġclient `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton (" some queue id - sqs - dl q - client ", Ġsq s D lq Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġretrieve Ġthe Ġdl q Ġar n Ġfrom Ġthe Ġdl q Ġclient `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs D lq Client ). get Queue Attributes (" some Ġdl q Ġurl ", ĠlistOf (" Queue Arn ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcreate Ġa Ġqueue Ġwith Ġa Ġred rive Ġpolicy `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Client ). create Queue ( ĊĠĠĠĠĠĠĠ Ġcheck < Create Queue Request > Ġ{ ĊĠĠĠĠĠĠĠĠĠ ĠassertThat ( it . attributes ). contains Entry (" Red rive Policy ", Ġ""" {" dead Letter Target Arn ":" some Ġdl q Ġar n "," max Receive Count ":" 5 "} """) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create Ġmultiple ĠAWS ĠH mp ps Queues ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( queue Name Ġ= Ġ" some Ġqueue Ġname ", Ġqueue Access KeyId Ġ= Ġ" some Ġaccess Ġkey Ġid ", Ġqueue Secret AccessKey Ġ= Ġ" some Ġsecret Ġaccess Ġkey ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ", Ġdl q Access KeyId Ġ= Ġ" dl q Ġaccess Ġkey Ġid ", Ġdl q Secret AccessKey Ġ= Ġ" dl q Ġsecret Ġaccess Ġkey ") ĊĠĠĠ Ġprivate Ġval Ġanother Queue Config Ġ= ĠQueue Config ( queue Name Ġ= Ġ" another Ġqueue Ġname ", Ġqueue Access KeyId Ġ= Ġ" another Ġaccess Ġkey Ġid ", Ġqueue Secret AccessKey Ġ= Ġ" another Ġsecret Ġaccess Ġkey ", Ġdl q Name Ġ= Ġ" another Ġdl q Ġname ", Ġdl q Access KeyId Ġ= Ġ" another Ġdl q Ġaccess Ġkey Ġid ", Ġdl q Secret AccessKey Ġ= Ġ" another Ġdl q Ġsecret Ġaccess Ġkey ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( queues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config , Ġ" another queue id " Ġto Ġanother Queue Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url (" some Ġqueue Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url (" some Ġdl q Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url (" another Ġqueue Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" another Ġqueue Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url (" another Ġdl q Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" another Ġdl q Ġurl ")) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcreate Ġmultiple Ġdl q Ġclients Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs D lq Client (" some queue id ", Ġ" some Ġdl q Ġname ", Ġ" dl q Ġaccess Ġkey Ġid ", Ġ" dl q Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġfalse ) ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs D lq Client (" another queue id ", Ġ" another Ġdl q Ġname ", Ġ" another Ġdl q Ġaccess Ġkey Ġid ", Ġ" another Ġdl q Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcreate Ġmultiple Ġsq s Ġclients Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs Client (" some queue id ", Ġ" some Ġqueue Ġname ", Ġ" some Ġaccess Ġkey Ġid ", Ġ" some Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġfalse ) ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs Client (" another queue id ", Ġ" another Ġqueue Ġname ", Ġ" another Ġaccess Ġkey Ġid ", Ġ" another Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġmultiple Ġqueue Ġdetails `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. id ). isEqualTo (" some queue id ") ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 1 ]. id ). isEqualTo (" another queue id ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġmultiple Ġhealth Ġindicators `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - health "), Ġany < H mp ps Queue Health >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" another queue id - health "), Ġany < H mp ps Queue Health >()) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create ĠAWS ĠH mp ps Queue Ġwith Ġasynchronous ĠS QS Ġclients ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( async Queue Client Ġ= Ġtrue , Ġasync D lq Client Ġ= Ġtrue , Ġqueue Name Ġ= Ġ" some Ġqueue Ġname ", Ġqueue Access KeyId Ġ= Ġ" some Ġaccess Ġkey Ġid ", Ġqueue Secret AccessKey Ġ= Ġ" some Ġsecret Ġaccess Ġkey ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ", Ġdl q Access KeyId Ġ= Ġ" dl q Ġaccess Ġkey Ġid ", Ġdl q Secret AccessKey Ġ= Ġ" dl q Ġsecret Ġaccess Ġkey ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( queues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S Async >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S Async >() ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url (" some Ġqueue Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url (" some Ġdl q Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcreate Ġasync Ġclients Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs D lq Client (" some queue id ", Ġ" some Ġdl q Ġname ", Ġ" dl q Ġaccess Ġkey Ġid ", Ġ" dl q Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġtrue ) ĊĠĠĠĠĠ Ġverify ( sqs Factory ). aws S qs Client (" some queue id ", Ġ" some Ġqueue Ġname ", Ġ" some Ġaccess Ġkey Ġid ", Ġ" some Ġsecret Ġaccess Ġkey ", Ġ" eu - west - 2 ", Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġasync Ġclients `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs Client ). isInstanceOf ( Amazon SQ S Async :: class . java ) ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs D lq Client ). isInstanceOf ( Amazon SQ S Async :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġqueue Ġdetails `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. id ). isEqualTo (" some queue id ") ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. queue Name ). isEqualTo (" some Ġqueue Ġname ") ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. dl q Name ). isEqualTo (" some Ġdl q Ġname ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġa Ġhealth Ġindicator `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - health "), Ġany < H mp ps Queue Health >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - sqs - client "), Ġany < Amazon SQ S >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - sqs - dl q - client "), Ġany < Amazon SQ S >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - jms - listener - factory "), Ġany < H mp ps Queue Destination Container Factory >()) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create ĠLocal Stack ĠH mp ps Queue Ġwith Ġasynchronous ĠS QS Ġclients ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( async Queue Client Ġ= Ġtrue , Ġasync D lq Client Ġ= Ġtrue , Ġqueue Name Ġ= Ġ" some Ġqueue Ġname ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( provider Ġ= Ġ" local stack ", Ġqueues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S Async >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S Async >() ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . local Stack S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . local Stack S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url (" some Ġqueue Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url (" some Ġdl q Ġname ")). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Attributes ( any String (), Ġany List ())). thenReturn ( Get Queue Attributes Result (). with Attributes ( map Of (" Queue Arn " Ġto Ġ" some Ġdl q Ġar n "))) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġcreate Ġasync Ġclients Ġfrom Ġsq s Ġfactory `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sqs Factory ). local Stack S qs D lq Client (" some queue id ", Ġ" some Ġdl q Ġname ", Ġ" http :// localhost : 4 5 6 6 ", Ġ" eu - west - 2 ", Ġtrue ) ĊĠĠĠĠĠ Ġverify ( sqs Factory ). local Stack S qs Client (" some queue id ", Ġ" some Ġqueue Ġname ", Ġ" http :// localhost : 4 5 6 6 ", Ġ" eu - west - 2 ", Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġasync Ġclients `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs Client ). isInstanceOf ( Amazon SQ S Async :: class . java ) ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs D lq Client ). isInstanceOf ( Amazon SQ S Async :: class . java ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġqueue Ġdetails `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. id ). isEqualTo (" some queue id ") ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. queue Name ). isEqualTo (" some Ġqueue Ġname ") ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. dl q Name ). isEqualTo (" some Ġdl q Ġname ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġregister Ġall Ġbe ans Ġcreated `() Ġ{ ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - health "), Ġany < H mp ps Queue Health >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - sqs - client "), Ġany < Amazon SQ S >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - sqs - dl q - client "), Ġany < Amazon SQ S >()) ĊĠĠĠĠĠ Ġverify ( bean Factory ). register Singleton ( eq (" some queue id - jms - listener - factory "), Ġany < H mp ps Queue Destination Container Factory >()) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create ĠLocal Stack ĠH mp ps Queue Ġwith Ġtopic Ġsubscription ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( subscribe Topic Id Ġ= Ġ" some topic id ", Ġsubscribe Filter Ġ= Ġ" some Ġtopic Ġfilter ", Ġqueue Name Ġ= Ġ" some - queue - name ", Ġqueue Access KeyId Ġ= Ġ" some Ġaccess Ġkey Ġid ", Ġqueue Secret AccessKey Ġ= Ġ" some Ġsecret Ġaccess Ġkey ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ", Ġdl q Access KeyId Ġ= Ġ" dl q Ġaccess Ġkey Ġid ", Ġdl q Secret AccessKey Ġ= Ġ" dl q Ġsecret Ġaccess Ġkey ") ĊĠĠĠ Ġprivate Ġval Ġsome Topic Config Ġ= ĠTopic Config ( arn Ġ= Ġ"${ local stack Arn Prefix } some - topic - name ", Ġaccess KeyId Ġ= Ġ" topic Ġaccess Ġkey ", Ġsecret AccessKey Ġ= Ġ" topic Ġsecret ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( provider Ġ= Ġ" local stack ", Ġqueues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config ), Ġtopics Ġ= Ġmap Of (" some topic id " Ġto Ġsome Topic Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsns Client Ġ= Ġmock < Amazon S NS >() ĊĠĠĠ Ġprivate Ġval Ġtopics Ġ= ĠlistOf ( H mp ps Topic ( id Ġ= Ġ" some topic id ", Ġar n Ġ= Ġ" some Ġtopic Ġar n ", Ġsns Client Ġ= Ġsns Client )) ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . local Stack S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . local Stack S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Attributes ( any String (), Ġany List ())). thenReturn ( Get Queue Attributes Result (). with Attributes ( map Of (" Queue Arn " Ġto Ġ" some Ġdl q Ġar n "))) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties , Ġtopics ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue ĠAmazon SQ S Ġclient `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs Client ). isEqualTo ( sqs Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġsubscribe Ġto Ġthe Ġtopic `() Ġ{ ĊĠĠĠĠĠ Ġverify ( sns Client ). subscribe ( ĊĠĠĠĠĠĠĠ Ġcheck Ġ{ Ġsubscribe Request Ġ-> ĊĠĠĠĠĠĠĠĠĠ ĠassertThat ( subscribe Request . topic Arn ). isEqualTo (" some Ġtopic Ġar n ") ĊĠĠĠĠĠĠĠĠĠ ĠassertThat ( subscribe Request . protocol ). isEqualTo (" sqs ") ĊĠĠĠĠĠĠĠĠĠ ĠassertThat ( subscribe Request . endpoint ). isEqualTo (" http :// localhost : 4 5 6 6 / queue / some - queue - name ") ĊĠĠĠĠĠĠĠĠĠ ĠassertThat ( subscribe Request . attributes [" Filter Policy "]). isEqualTo (" some Ġtopic Ġfilter ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Nested ĊĠ Ġinner Ġclass Ġ` Create ĠAWS ĠH mp ps Queue Ġwith Ġtopic Ġsubscription ` Ġ{ ĊĠĠĠ Ġprivate Ġval Ġsome Queue Config Ġ= ĠQueue Config ( subscribe Topic Id Ġ= Ġ" some topic id ", Ġsubscribe Filter Ġ= Ġ" some Ġtopic Ġfilter ", Ġqueue Name Ġ= Ġ" some Ġqueue Ġname ", Ġqueue Access KeyId Ġ= Ġ" some Ġaccess Ġkey Ġid ", Ġqueue Secret AccessKey Ġ= Ġ" some Ġsecret Ġaccess Ġkey ", Ġdl q Name Ġ= Ġ" some Ġdl q Ġname ", Ġdl q Access KeyId Ġ= Ġ" dl q Ġaccess Ġkey Ġid ", Ġdl q Secret AccessKey Ġ= Ġ" dl q Ġsecret Ġaccess Ġkey ") ĊĠĠĠ Ġprivate Ġval Ġsome Topic Config Ġ= ĠTopic Config ( arn Ġ= Ġ" some Ġtopic Ġar n ", Ġaccess KeyId Ġ= Ġ" topic Ġaccess Ġkey ", Ġsecret AccessKey Ġ= Ġ" topic Ġsecret ") ĊĠĠĠ Ġprivate Ġval Ġh mp ps S qs Properties Ġ= ĠH mp ps S qs Properties ( queues Ġ= Ġmap Of (" some queue id " Ġto Ġsome Queue Config ), Ġtopics Ġ= Ġmap Of (" some topic id " Ġto Ġsome Topic Config )) ĊĠĠĠ Ġprivate Ġval Ġsq s Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsq s D lq Client Ġ= Ġmock < Amazon SQ S >() ĊĠĠĠ Ġprivate Ġval Ġsns Client Ġ= Ġmock < Amazon S NS >() ĊĠĠĠ Ġprivate Ġval Ġtopics Ġ= ĠlistOf ( H mp ps Topic ( id Ġ= Ġ" some topic id ", Ġar n Ġ= Ġ" some Ġtopic Ġar n ", Ġsns Client Ġ= Ġsns Client )) ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġh mp ps Queues : ĠList < H mp ps Queue > ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġ` configure Ġmocks Ġand Ġregister Ġqueues `() Ġ{ ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs D lq Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs D lq Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs Factory . aws S qs Client ( any String (), Ġany String (), Ġany String (), Ġany String (), Ġany String (), Ġany Boolean ())) ĊĠĠĠĠĠĠĠ Ġ. thenReturn ( sqs Client ) ĊĠĠĠĠĠ Ġwhenever ( sqs D lq Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġdl q Ġurl ")) ĊĠĠĠĠĠ Ġwhenever ( sqs Client . get Queue Url ( any String ())). thenReturn ( Get Queue Url Result (). with Queue Url (" some Ġqueue Ġurl ")) ĊĊĠĠĠĠĠ Ġh mp ps Queues Ġ= Ġh mp ps Queue Factory . create H mp ps Queues ( h mp ps S qs Properties , Ġtopics ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġreturn Ġthe Ġqueue ĠAmazon SQ S Ġclient `() Ġ{ ĊĠĠĠĠĠ ĠassertThat ( h mp ps Queues [ 0 ]. sqs Client ). isEqualTo ( sqs Client ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġ` should Ġnot Ġsubscribe Ġto Ġthe Ġtopic `() Ġ{ ĊĠĠĠĠĠ Ġverify No More Interactions ( sns Client ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ