39
39
*/
40
40
class ClientRegistrationIdProcessorTests {
41
41
42
+ private static final String REGISTRATION_ID = "registrationId" ;
43
+
42
44
ClientRegistrationIdProcessor processor = ClientRegistrationIdProcessor .DEFAULT_INSTANCE ;
43
45
44
46
@ Test
@@ -48,32 +50,42 @@ void processWhenClientRegistrationIdPresentThenSet() {
48
50
this .processor .process (hasClientRegistrationId , null , null , builder );
49
51
50
52
String registrationId = ClientAttributes .resolveClientRegistrationId (builder .build ().getAttributes ());
51
- assertThat (registrationId ).isEqualTo (RestService . REGISTRATION_ID );
53
+ assertThat (registrationId ).isEqualTo (REGISTRATION_ID );
52
54
}
53
55
54
56
@ Test
55
57
void processWhenMetaClientRegistrationIdPresentThenSet () {
56
58
HttpRequestValues .Builder builder = HttpRequestValues .builder ();
57
- Method hasClientRegistrationId = ReflectionUtils .findMethod (RestService .class , "hasMetaClientRegistrationId" );
58
- this .processor .process (hasClientRegistrationId , null , null , builder );
59
+ Method hasMetaClientRegistrationId = ReflectionUtils .findMethod (RestService .class ,
60
+ "hasMetaClientRegistrationId" );
61
+ this .processor .process (hasMetaClientRegistrationId , null , null , builder );
59
62
60
63
String registrationId = ClientAttributes .resolveClientRegistrationId (builder .build ().getAttributes ());
61
- assertThat (registrationId ).isEqualTo (RestService . REGISTRATION_ID );
64
+ assertThat (registrationId ).isEqualTo (REGISTRATION_ID );
62
65
}
63
66
64
67
@ Test
65
68
void processWhenNoClientRegistrationIdPresentThenNull () {
66
69
HttpRequestValues .Builder builder = HttpRequestValues .builder ();
67
- Method hasClientRegistrationId = ReflectionUtils .findMethod (RestService .class , "noClientRegistrationId" );
68
- this .processor .process (hasClientRegistrationId , null , null , builder );
70
+ Method noClientRegistrationId = ReflectionUtils .findMethod (RestService .class , "noClientRegistrationId" );
71
+ this .processor .process (noClientRegistrationId , null , null , builder );
69
72
70
73
String registrationId = ClientAttributes .resolveClientRegistrationId (builder .build ().getAttributes ());
71
74
assertThat (registrationId ).isNull ();
72
75
}
73
76
74
- interface RestService {
77
+ @ Test
78
+ void processWhenClientRegistrationIdPresentOnDeclaringClassThenSet () {
79
+ HttpRequestValues .Builder builder = HttpRequestValues .builder ();
80
+ Method declaringClassHasClientRegistrationId = ReflectionUtils .findMethod (AnnotatedRestService .class ,
81
+ "declaringClassHasClientRegistrationId" );
82
+ this .processor .process (declaringClassHasClientRegistrationId , null , null , builder );
83
+
84
+ String registrationId = ClientAttributes .resolveClientRegistrationId (builder .build ().getAttributes ());
85
+ assertThat (registrationId ).isEqualTo (REGISTRATION_ID );
86
+ }
75
87
76
- String REGISTRATION_ID = "registrationId" ;
88
+ interface RestService {
77
89
78
90
@ ClientRegistrationId (REGISTRATION_ID )
79
91
void hasClientRegistrationId ();
@@ -86,9 +98,16 @@ interface RestService {
86
98
}
87
99
88
100
@ Retention (RetentionPolicy .RUNTIME )
89
- @ ClientRegistrationId (RestService . REGISTRATION_ID )
101
+ @ ClientRegistrationId (REGISTRATION_ID )
90
102
@interface MetaClientRegistrationId {
91
103
92
104
}
93
105
106
+ @ ClientRegistrationId (REGISTRATION_ID )
107
+ interface AnnotatedRestService {
108
+
109
+ void declaringClassHasClientRegistrationId ();
110
+
111
+ }
112
+
94
113
}
0 commit comments