package Ġcom . github . aw st est kit . sns . junit 5 Ċ Ċ import Ġcom . github . aw st est kit . Aws Client Factory Ċ import Ġorg . junit . jupiter . api . extension . After All Callback Ċ import Ġorg . junit . jupiter . api . extension . After Each Callback Ċ import Ġorg . junit . jupiter . api . extension . Before All Callback Ċ import Ġorg . junit . jupiter . api . extension . BeforeEach Callback Ċ import Ġorg . junit . jupiter . api . extension . Extension Context Ċ import Ġorg . junit . platform . commons . util . Annotation Utils Ċ import Ġsoftware . amazon . aw ssdk . services . sns . S ns Client Ċ import Ġsoftware . amazon . aw ssdk . services . sns . S ns Client Builder Ċ import Ġjava . lang . reflect . Annotated Element Ċ Ċ class ĠS ns Setup Extension Ġ: ĠBefore All Callback , ĠAfter All Callback , ĠBefore Each Callback , ĠAfter Each Callback Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġsns Client : ĠSimple S ns Client ĊĊĠĠĠ Ġoverride Ġfun Ġbefore All ( context : ĠExtension Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfactory Ġ= ĠAws Client Factory < S ns Client Builder , ĠS ns Client >( S ns Client . builder ()) ĊĠĠĠĠĠĠĠ Ġsns Client Ġ= ĠSimple S ns Client ( factory . create ( context )) ĊĊĠĠĠĠĠĠĠ Ġcreate Resources ( context . required TestClass ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġafter All ( context : ĠExtension Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdelete Resources ( context . required TestClass ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠbeforeEach ( context : ĠExtension Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcreate Resources ( context . required TestMethod ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠafterEach ( context : ĠExtension Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdelete Resources ( context . required TestMethod ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Resources ( annotated Element : ĠAnnot ated Element ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtopics Ġ= Ġfind Topics ( annotated Element ) ĊĠĠĠĠĠĠĠ Ġtopics . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsns Client . create Topic ( it . value ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġdelete Resources ( annotated Element : ĠAnnot ated Element ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtopics Ġ= Ġfind Topics ( annotated Element ) ĊĠĠĠĠĠĠĠ Ġtopics . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsns Client . delete Topic ( it . value ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfind Topics ( annotated Element : ĠAnnot ated Element ): ĠList < S ns Topic > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtopic Ġ= Ġfind S ns Topic ( annotated Element ) ĊĠĠĠĠĠĠĠ Ġtopic ?. apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠlistOf ( topic ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġfind S ns Topics ( annotated Element ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfind S ns Topic ( annotated Element : ĠAnnot ated Element ): ĠS ns Topic ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠAnnotation Utils . find Annotation ( annotated Element , ĠS ns Topic :: class . java ). orElse ( null ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfind S ns Topics ( annotated Element : ĠAnnot ated Element ): ĠList < S ns Topic > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtopics Ġ= ĠAnnotation Utils . find Annotation ( annotated Element , ĠS ns Topics :: class . java ) ĊĠĠĠĠĠĠĠ Ġif Ġ( topics . isPresent ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġtopics . get (). value . toList () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġempty List () ĊĠĠĠ Ġ} Ċ } Ċ