1+ package software .amazon .lambda .powertools .core .internal ;
2+
3+ import org .aspectj .lang .ProceedingJoinPoint ;
4+ import org .aspectj .lang .Signature ;
5+ import org .junit .jupiter .api .Test ;
6+
7+ import static org .assertj .core .api .Assertions .assertThat ;
8+ import static org .mockito .Mockito .mock ;
9+ import static org .mockito .Mockito .when ;
10+
11+ class LambdaHandlerProcessorTest {
12+
13+ @ Test
14+ void shouldTreatProfilerHandlerMethodAsValid () {
15+ ProceedingJoinPoint pjpMock = mock (ProceedingJoinPoint .class );
16+ Signature signature = mock (Signature .class );
17+ when (signature .getName ()).thenReturn ("requestHandler" );
18+ when (pjpMock .getSignature ()).thenReturn (signature );
19+
20+ assertThat (LambdaHandlerProcessor .isHandlerMethod (pjpMock ))
21+ .isTrue ();
22+ }
23+
24+ @ Test
25+ void shouldTreatDefaultHandlerMethodAsValid () {
26+ ProceedingJoinPoint pjpMock = mock (ProceedingJoinPoint .class );
27+ Signature signature = mock (Signature .class );
28+ when (signature .getName ()).thenReturn ("handleRequest" );
29+ when (pjpMock .getSignature ()).thenReturn (signature );
30+
31+ assertThat (LambdaHandlerProcessor .isHandlerMethod (pjpMock ))
32+ .isTrue ();
33+ }
34+
35+ @ Test
36+ void shouldNotTreatOtherMethodNamesAsValidHandlerMethod () {
37+ ProceedingJoinPoint pjpMock = mock (ProceedingJoinPoint .class );
38+ Signature signature = mock (Signature .class );
39+ when (signature .getName ()).thenReturn ("handleRequestInvalid" );
40+ when (pjpMock .getSignature ()).thenReturn (signature );
41+
42+ assertThat (LambdaHandlerProcessor .isHandlerMethod (pjpMock ))
43+ .isFalse ();
44+ }
45+ }
0 commit comments