3737import org .mockito .junit .jupiter .MockitoExtension ;
3838
3939import com .amazonaws .services .lambda .runtime .Context ;
40- import software .amazon .lambda .powertools .common .stubs .TestLambdaContext ;
4140import com .fasterxml .jackson .core .JsonProcessingException ;
4241import com .fasterxml .jackson .databind .JsonNode ;
4342
43+ import software .amazon .lambda .powertools .common .stubs .TestLambdaContext ;
4444import software .amazon .lambda .powertools .idempotency .Constants ;
4545import software .amazon .lambda .powertools .idempotency .Idempotency ;
4646import software .amazon .lambda .powertools .idempotency .IdempotencyConfig ;
6262import software .amazon .lambda .powertools .utilities .JsonConfig ;
6363
6464@ ExtendWith (MockitoExtension .class )
65- public class IdempotencyAspectTest {
65+ class IdempotencyAspectTest {
6666
6767 private Context context = new TestLambdaContext ();
6868
6969 @ Mock
7070 private BasePersistenceStore store ;
7171
7272 @ Test
73- public void firstCall_shouldPutInStore () {
73+ void firstCall_shouldPutInStore () {
7474 Idempotency .config ()
7575 .withPersistenceStore (store )
7676 .withConfig (IdempotencyConfig .builder ()
@@ -100,12 +100,13 @@ public void firstCall_shouldPutInStore() {
100100 }
101101
102102 @ Test
103- public void firstCall_shouldPutInStoreAndNotApplyResponseHook () {
103+ void firstCall_shouldPutInStoreAndNotApplyResponseHook () {
104104 Idempotency .config ()
105105 .withPersistenceStore (store )
106106 .withConfig (IdempotencyConfig .builder ()
107107 .withEventKeyJMESPath ("id" )
108- // This hook will add a second product to the basket. It should not run here. Only for
108+ // This hook will add a second product to the basket. It should not run here.
109+ // Only for
109110 // idempotent responses.
110111 .withResponseHook ((responseData , dataRecord ) -> {
111112 final Basket basket = (Basket ) responseData ;
@@ -137,7 +138,7 @@ public void firstCall_shouldPutInStoreAndNotApplyResponseHook() {
137138 }
138139
139140 @ Test
140- public void secondCall_notExpired_shouldGetFromStore () throws JsonProcessingException {
141+ void secondCall_notExpired_shouldGetFromStore () throws JsonProcessingException {
141142 // GIVEN
142143 Idempotency .config ()
143144 .withPersistenceStore (store )
@@ -168,7 +169,7 @@ public void secondCall_notExpired_shouldGetFromStore() throws JsonProcessingExce
168169 }
169170
170171 @ Test
171- public void secondCall_notExpired_shouldNotGetFromStoreIfPresentOnIdempotencyException ()
172+ void secondCall_notExpired_shouldNotGetFromStoreIfPresentOnIdempotencyException ()
172173 throws JsonProcessingException {
173174 // GIVEN
174175 Idempotency .config ()
@@ -187,12 +188,13 @@ public void secondCall_notExpired_shouldNotGetFromStoreIfPresentOnIdempotencyExc
187188 JsonConfig .get ().getObjectMapper ().writer ().writeValueAsString (b ),
188189 null );
189190
190- // A data record on this exception should take precedence over fetching a record from the store / cache
191+ // A data record on this exception should take precedence over fetching a record
192+ // from the store / cache
191193 doThrow (new IdempotencyItemAlreadyExistsException (
192194 "Test message" ,
193195 new RuntimeException ("Test Cause" ),
194196 dr ))
195- .when (store ).saveInProgress (any (), any (), any ());
197+ .when (store ).saveInProgress (any (), any (), any ());
196198
197199 // WHEN
198200 IdempotencyEnabledFunction function = new IdempotencyEnabledFunction ();
@@ -201,12 +203,13 @@ public void secondCall_notExpired_shouldNotGetFromStoreIfPresentOnIdempotencyExc
201203 // THEN
202204 assertThat (basket ).isEqualTo (b );
203205 assertThat (function .handlerCalled ()).isFalse ();
204- // Should never call the store because item is already present on IdempotencyItemAlreadyExistsException
206+ // Should never call the store because item is already present on
207+ // IdempotencyItemAlreadyExistsException
205208 verify (store , never ()).getRecord (any (), any ());
206209 }
207210
208211 @ Test
209- public void secondCall_notExpired_shouldGetStringFromStore () {
212+ void secondCall_notExpired_shouldGetStringFromStore () {
210213 // GIVEN
211214 Idempotency .config ()
212215 .withPersistenceStore (store )
@@ -236,7 +239,7 @@ public void secondCall_notExpired_shouldGetStringFromStore() {
236239 }
237240
238241 @ Test
239- public void secondCall_notExpired_shouldGetStringFromStoreWithResponseHook () {
242+ void secondCall_notExpired_shouldGetStringFromStoreWithResponseHook () {
240243 // GIVEN
241244 final String RESPONSE_HOOK_SUFFIX = " ResponseHook" ;
242245 Idempotency .config ()
@@ -271,7 +274,7 @@ public void secondCall_notExpired_shouldGetStringFromStoreWithResponseHook() {
271274 }
272275
273276 @ Test
274- public void secondCall_inProgress_shouldThrowIdempotencyAlreadyInProgressException ()
277+ void secondCall_inProgress_shouldThrowIdempotencyAlreadyInProgressException ()
275278 throws JsonProcessingException {
276279 // GIVEN
277280 Idempotency .config ()
@@ -303,7 +306,7 @@ public void secondCall_inProgress_shouldThrowIdempotencyAlreadyInProgressExcepti
303306 }
304307
305308 @ Test
306- public void secondCall_inProgress_lambdaTimeout_timeoutExpired_shouldThrowInconsistentState ()
309+ void secondCall_inProgress_lambdaTimeout_timeoutExpired_shouldThrowInconsistentState ()
307310 throws JsonProcessingException {
308311 // GIVEN
309312 Idempotency .config ()
@@ -335,7 +338,7 @@ public void secondCall_inProgress_lambdaTimeout_timeoutExpired_shouldThrowIncons
335338 }
336339
337340 @ Test
338- public void functionThrowException_shouldDeleteRecord_andThrowFunctionException () {
341+ void functionThrowException_shouldDeleteRecord_andThrowFunctionException () {
339342 // GIVEN
340343 Idempotency .config ()
341344 .withPersistenceStore (store )
@@ -356,7 +359,7 @@ public void functionThrowException_shouldDeleteRecord_andThrowFunctionException(
356359
357360 @ Test
358361 @ SetEnvironmentVariable (key = Constants .IDEMPOTENCY_DISABLED_ENV , value = "true" )
359- public void testIdempotencyDisabled_shouldJustRunTheFunction () {
362+ void testIdempotencyDisabled_shouldJustRunTheFunction () {
360363 // GIVEN
361364 Idempotency .config ()
362365 .withPersistenceStore (store )
@@ -377,7 +380,7 @@ public void testIdempotencyDisabled_shouldJustRunTheFunction() {
377380 }
378381
379382 @ Test
380- public void idempotencyOnSubMethodAnnotated_firstCall_shouldPutInStore () {
383+ void idempotencyOnSubMethodAnnotated_firstCall_shouldPutInStore () {
381384 Idempotency .config ()
382385 .withPersistenceStore (store )
383386 .configure ();
@@ -405,7 +408,7 @@ public void idempotencyOnSubMethodAnnotated_firstCall_shouldPutInStore() {
405408 }
406409
407410 @ Test
408- public void idempotencyOnSubMethodAnnotated_firstCall_contextNotRegistered_shouldPutInStore () {
411+ void idempotencyOnSubMethodAnnotated_firstCall_contextNotRegistered_shouldPutInStore () {
409412 Idempotency .config ()
410413 .withPersistenceStore (store )
411414 .configure ();
@@ -433,7 +436,7 @@ public void idempotencyOnSubMethodAnnotated_firstCall_contextNotRegistered_shoul
433436 }
434437
435438 @ Test
436- public void idempotencyOnSubMethodAnnotated_secondCall_notExpired_shouldGetFromStore ()
439+ void idempotencyOnSubMethodAnnotated_secondCall_notExpired_shouldGetFromStore ()
437440 throws JsonProcessingException {
438441 // GIVEN
439442 Idempotency .config ()
@@ -462,7 +465,7 @@ public void idempotencyOnSubMethodAnnotated_secondCall_notExpired_shouldGetFromS
462465 }
463466
464467 @ Test
465- public void idempotencyOnSubMethodAnnotated_keyJMESPath_shouldPutInStoreWithKey () {
468+ void idempotencyOnSubMethodAnnotated_keyJMESPath_shouldPutInStoreWithKey () {
466469 BasePersistenceStore persistenceStore = spy (BasePersistenceStore .class );
467470
468471 Idempotency .config ()
@@ -484,7 +487,7 @@ public void idempotencyOnSubMethodAnnotated_keyJMESPath_shouldPutInStoreWithKey(
484487 }
485488
486489 @ Test
487- public void idempotencyOnSubMethodAnnotated_keyJMESPathArray_shouldPutInStoreWithKey () {
490+ void idempotencyOnSubMethodAnnotated_keyJMESPathArray_shouldPutInStoreWithKey () {
488491 BasePersistenceStore persistenceStore = spy (BasePersistenceStore .class );
489492
490493 Idempotency .config ()
@@ -506,7 +509,7 @@ public void idempotencyOnSubMethodAnnotated_keyJMESPathArray_shouldPutInStoreWit
506509 }
507510
508511 @ Test
509- public void idempotencyOnSubMethodNotAnnotated_shouldThrowException () {
512+ void idempotencyOnSubMethodNotAnnotated_shouldThrowException () {
510513 Idempotency .config ()
511514 .withPersistenceStore (store )
512515 .withConfig (IdempotencyConfig .builder ().build ()).configure ();
@@ -521,7 +524,7 @@ public void idempotencyOnSubMethodNotAnnotated_shouldThrowException() {
521524 }
522525
523526 @ Test
524- public void idempotencyOnSubMethodVoid_shouldThrowException () {
527+ void idempotencyOnSubMethodVoid_shouldThrowException () {
525528 Idempotency .config ()
526529 .withPersistenceStore (store )
527530 .withConfig (IdempotencyConfig .builder ().build ()).configure ();
0 commit comments