1616
1717package org .springframework .ai .mcp .annotation .spring .scan ;
1818
19+ import java .lang .annotation .Annotation ;
20+ import java .lang .annotation .ElementType ;
21+ import java .lang .annotation .Retention ;
22+ import java .lang .annotation .RetentionPolicy ;
23+ import java .lang .annotation .Target ;
24+ import java .util .Collections ;
25+ import java .util .HashSet ;
26+ import java .util .Set ;
27+
1928import org .junit .jupiter .api .BeforeEach ;
2029import org .junit .jupiter .api .Test ;
2130import org .junit .jupiter .api .extension .ExtendWith ;
2231import org .mockito .ArgumentCaptor ;
2332import org .mockito .Mock ;
2433import org .mockito .junit .jupiter .MockitoExtension ;
25- import org .springframework .aop .framework .ProxyFactory ;
2634
27- import java .lang .annotation .*;
28- import java .util .Collections ;
29- import java .util .HashSet ;
30- import java .util .Set ;
31-
32- import static org .junit .jupiter .api .Assertions .*;
35+ import static org .junit .jupiter .api .Assertions .assertEquals ;
36+ import static org .junit .jupiter .api .Assertions .assertSame ;
37+ import static org .junit .jupiter .api .Assertions .assertThrows ;
38+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3339import static org .mockito .ArgumentMatchers .any ;
34- import static org .mockito .Mockito .*;
40+ import static org .mockito .Mockito .never ;
41+ import static org .mockito .Mockito .same ;
42+ import static org .mockito .Mockito .times ;
43+ import static org .mockito .Mockito .verify ;
44+
45+ import org .springframework .aop .framework .ProxyFactory ;
3546
3647/**
3748 * Unit Tests for {@link AbstractAnnotatedMethodBeanPostProcessor}.
@@ -50,17 +61,17 @@ class AbstractAnnotatedMethodBeanPostProcessorTests {
5061
5162 @ BeforeEach
5263 void setUp () {
53- targetAnnotations = new HashSet <>();
54- targetAnnotations .add (TestAnnotation .class );
64+ this . targetAnnotations = new HashSet <>();
65+ this . targetAnnotations .add (TestAnnotation .class );
5566
56- processor = new AbstractAnnotatedMethodBeanPostProcessor (registry , targetAnnotations ) {
67+ this . processor = new AbstractAnnotatedMethodBeanPostProcessor (this . registry , this . targetAnnotations ) {
5768 };
5869 }
5970
6071 @ Test
6172 void testConstructorWithNullRegistry () {
6273 IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> {
63- new AbstractAnnotatedMethodBeanPostProcessor (null , targetAnnotations ) {
74+ new AbstractAnnotatedMethodBeanPostProcessor (null , this . targetAnnotations ) {
6475 };
6576 });
6677 assertEquals ("AnnotatedBeanRegistry must not be null" , exception .getMessage ());
@@ -69,7 +80,7 @@ void testConstructorWithNullRegistry() {
6980 @ Test
7081 void testConstructorWithEmptyTargetAnnotations () {
7182 IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> {
72- new AbstractAnnotatedMethodBeanPostProcessor (registry , Collections .emptySet ()) {
83+ new AbstractAnnotatedMethodBeanPostProcessor (this . registry , Collections .emptySet ()) {
7384 };
7485 });
7586 assertEquals ("Target annotations must not be empty" , exception .getMessage ());
@@ -79,30 +90,30 @@ void testConstructorWithEmptyTargetAnnotations() {
7990 void testPostProcessAfterInitializationWithoutAnnotations () {
8091 NoAnnotationBean bean = new NoAnnotationBean ();
8192
82- Object result = processor .postProcessAfterInitialization (bean , "testBean" );
93+ Object result = this . processor .postProcessAfterInitialization (bean , "testBean" );
8394
8495 assertSame (bean , result );
85- verify (registry , never ()).addMcpAnnotatedBean (any (), any ());
96+ verify (this . registry , never ()).addMcpAnnotatedBean (any (), any ());
8697 }
8798
8899 @ Test
89100 void testPostProcessAfterInitializationWithAnnotations () {
90101 AnnotatedBean bean = new AnnotatedBean ();
91102
92- Object result = processor .postProcessAfterInitialization (bean , "testBean" );
103+ Object result = this . processor .postProcessAfterInitialization (bean , "testBean" );
93104
94105 assertSame (bean , result );
95- verify (registry , times (1 )).addMcpAnnotatedBean (any (), any ());
106+ verify (this . registry , times (1 )).addMcpAnnotatedBean (any (), any ());
96107 }
97108
98109 @ Test
99110 void testPostProcessAfterInitializationWithMultipleMethods () {
100111 MultipleAnnotationBean bean = new MultipleAnnotationBean ();
101112
102- Object result = processor .postProcessAfterInitialization (bean , "testBean" );
113+ Object result = this . processor .postProcessAfterInitialization (bean , "testBean" );
103114
104115 assertSame (bean , result );
105- verify (registry , times (1 )).addMcpAnnotatedBean (any (), any ());
116+ verify (this . registry , times (1 )).addMcpAnnotatedBean (any (), any ());
106117 }
107118
108119 @ Test
@@ -112,20 +123,20 @@ void testPostProcessAfterInitializationWithProxy() {
112123 proxyFactory .setProxyTargetClass (true );
113124 Object proxy = proxyFactory .getProxy ();
114125
115- Object result = processor .postProcessAfterInitialization (proxy , "testBean" );
126+ Object result = this . processor .postProcessAfterInitialization (proxy , "testBean" );
116127
117128 assertSame (proxy , result );
118- verify (registry , times (1 )).addMcpAnnotatedBean (any (), any ());
129+ verify (this . registry , times (1 )).addMcpAnnotatedBean (any (), any ());
119130 }
120131
121132 @ Test
122133 void testCorrectAnnotationsAreCaptured () {
123134 AnnotatedBean bean = new AnnotatedBean ();
124135
125- processor .postProcessAfterInitialization (bean , "testBean" );
136+ this . processor .postProcessAfterInitialization (bean , "testBean" );
126137
127138 ArgumentCaptor <Set <Class <? extends Annotation >>> annotationsCaptor = ArgumentCaptor .forClass (Set .class );
128- verify (registry ).addMcpAnnotatedBean (same (bean ), annotationsCaptor .capture ());
139+ verify (this . registry ).addMcpAnnotatedBean (same (bean ), annotationsCaptor .capture ());
129140
130141 Set <Class <? extends java .lang .annotation .Annotation >> capturedAnnotations = annotationsCaptor .getValue ();
131142 assertEquals (1 , capturedAnnotations .size ());
0 commit comments