2323
2424import org .springframework .boot .configurationprocessor .metadata .ConfigurationMetadata ;
2525import org .springframework .boot .configurationprocessor .metadata .Metadata ;
26- import org .springframework .boot .configurationsample .Access ;
26+ import org .springframework .boot .configurationsample .TestAccess ;
2727import org .springframework .boot .configurationsample .endpoint .CamelCaseEndpoint ;
2828import org .springframework .boot .configurationsample .endpoint .CustomPropertiesEndpoint ;
2929import org .springframework .boot .configurationsample .endpoint .EnabledEndpoint ;
@@ -54,7 +54,7 @@ class EndpointMetadataGenerationTests extends AbstractMetadataGenerationTests {
5454 void simpleEndpoint () {
5555 ConfigurationMetadata metadata = compile (SimpleEndpoint .class );
5656 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.simple" ).fromSource (SimpleEndpoint .class ));
57- assertThat (metadata ).has (access ("simple" , Access .UNRESTRICTED ));
57+ assertThat (metadata ).has (access ("simple" , TestAccess .UNRESTRICTED ));
5858 assertThat (metadata ).has (cacheTtl ("simple" ));
5959 assertThat (metadata .getItems ()).hasSize (3 );
6060 }
@@ -63,15 +63,15 @@ void simpleEndpoint() {
6363 void enabledEndpoint () {
6464 ConfigurationMetadata metadata = compile (EnabledEndpoint .class );
6565 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.enabled" ).fromSource (EnabledEndpoint .class ));
66- assertThat (metadata ).has (access ("enabled" , Access .UNRESTRICTED ));
66+ assertThat (metadata ).has (access ("enabled" , TestAccess .UNRESTRICTED ));
6767 assertThat (metadata .getItems ()).hasSize (2 );
6868 }
6969
7070 @ Test
7171 void noAccessEndpoint () {
7272 ConfigurationMetadata metadata = compile (NoAccessEndpoint .class );
7373 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.noaccess" ).fromSource (NoAccessEndpoint .class ));
74- assertThat (metadata ).has (access ("noaccess" , Access .NONE ));
74+ assertThat (metadata ).has (access ("noaccess" , TestAccess .NONE ));
7575 assertThat (metadata .getItems ()).hasSize (2 );
7676 }
7777
@@ -80,7 +80,7 @@ void readOnlyAccessEndpoint() {
8080 ConfigurationMetadata metadata = compile (ReadOnlyAccessEndpoint .class );
8181 assertThat (metadata )
8282 .has (Metadata .withGroup ("management.endpoint.readonlyaccess" ).fromSource (ReadOnlyAccessEndpoint .class ));
83- assertThat (metadata ).has (access ("readonlyaccess" , Access .READ_ONLY ));
83+ assertThat (metadata ).has (access ("readonlyaccess" , TestAccess .READ_ONLY ));
8484 assertThat (metadata .getItems ()).hasSize (2 );
8585 }
8686
@@ -89,7 +89,7 @@ void unrestrictedAccessEndpoint() {
8989 ConfigurationMetadata metadata = compile (UnrestrictedAccessEndpoint .class );
9090 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.unrestrictedaccess" )
9191 .fromSource (UnrestrictedAccessEndpoint .class ));
92- assertThat (metadata ).has (access ("unrestrictedaccess" , Access .UNRESTRICTED ));
92+ assertThat (metadata ).has (access ("unrestrictedaccess" , TestAccess .UNRESTRICTED ));
9393 assertThat (metadata .getItems ()).hasSize (2 );
9494 }
9595
@@ -101,7 +101,7 @@ void customPropertiesEndpoint() {
101101 assertThat (metadata ).has (Metadata .withProperty ("management.endpoint.customprops.name" )
102102 .ofType (String .class )
103103 .withDefaultValue ("test" ));
104- assertThat (metadata ).has (access ("customprops" , Access .UNRESTRICTED ));
104+ assertThat (metadata ).has (access ("customprops" , TestAccess .UNRESTRICTED ));
105105 assertThat (metadata ).has (cacheTtl ("customprops" ));
106106 assertThat (metadata .getItems ()).hasSize (4 );
107107 }
@@ -110,7 +110,7 @@ void customPropertiesEndpoint() {
110110 void specificEndpoint () {
111111 ConfigurationMetadata metadata = compile (SpecificEndpoint .class );
112112 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.specific" ).fromSource (SpecificEndpoint .class ));
113- assertThat (metadata ).has (access ("specific" , Access .READ_ONLY ));
113+ assertThat (metadata ).has (access ("specific" , TestAccess .READ_ONLY ));
114114 assertThat (metadata ).has (cacheTtl ("specific" ));
115115 assertThat (metadata .getItems ()).hasSize (3 );
116116 }
@@ -120,7 +120,7 @@ void camelCaseEndpoint() {
120120 ConfigurationMetadata metadata = compile (CamelCaseEndpoint .class );
121121 assertThat (metadata )
122122 .has (Metadata .withGroup ("management.endpoint.pascal-case" ).fromSource (CamelCaseEndpoint .class ));
123- assertThat (metadata ).has (defaultAccess ("PascalCase" , "pascal-case" , Access .UNRESTRICTED ));
123+ assertThat (metadata ).has (defaultAccess ("PascalCase" , "pascal-case" , TestAccess .UNRESTRICTED ));
124124 assertThat (metadata .getItems ()).hasSize (2 );
125125 }
126126
@@ -130,15 +130,15 @@ void incrementalEndpointBuildChangeDefaultAccess() {
130130 ConfigurationMetadata metadata = project .compile ();
131131 assertThat (metadata )
132132 .has (Metadata .withGroup ("management.endpoint.incremental" ).fromSource (IncrementalEndpoint .class ));
133- assertThat (metadata ).has (access ("incremental" , Access .UNRESTRICTED ));
133+ assertThat (metadata ).has (access ("incremental" , TestAccess .UNRESTRICTED ));
134134 assertThat (metadata ).has (cacheTtl ("incremental" ));
135135 assertThat (metadata .getItems ()).hasSize (3 );
136136 project .replaceText (IncrementalEndpoint .class , "id = \" incremental\" " ,
137- "id = \" incremental\" , defaultAccess = org.springframework.boot.configurationsample.Access .NONE" );
137+ "id = \" incremental\" , defaultAccess = org.springframework.boot.configurationsample.TestAccess .NONE" );
138138 metadata = project .compile ();
139139 assertThat (metadata )
140140 .has (Metadata .withGroup ("management.endpoint.incremental" ).fromSource (IncrementalEndpoint .class ));
141- assertThat (metadata ).has (access ("incremental" , Access .NONE ));
141+ assertThat (metadata ).has (access ("incremental" , TestAccess .NONE ));
142142 assertThat (metadata ).has (cacheTtl ("incremental" ));
143143 assertThat (metadata .getItems ()).hasSize (3 );
144144 }
@@ -149,14 +149,14 @@ void incrementalEndpointBuildChangeCacheFlag() {
149149 ConfigurationMetadata metadata = project .compile ();
150150 assertThat (metadata )
151151 .has (Metadata .withGroup ("management.endpoint.incremental" ).fromSource (IncrementalEndpoint .class ));
152- assertThat (metadata ).has (access ("incremental" , Access .UNRESTRICTED ));
152+ assertThat (metadata ).has (access ("incremental" , TestAccess .UNRESTRICTED ));
153153 assertThat (metadata ).has (cacheTtl ("incremental" ));
154154 assertThat (metadata .getItems ()).hasSize (3 );
155155 project .replaceText (IncrementalEndpoint .class , "@Nullable String param" , "String param" );
156156 metadata = project .compile ();
157157 assertThat (metadata )
158158 .has (Metadata .withGroup ("management.endpoint.incremental" ).fromSource (IncrementalEndpoint .class ));
159- assertThat (metadata ).has (access ("incremental" , Access .UNRESTRICTED ));
159+ assertThat (metadata ).has (access ("incremental" , TestAccess .UNRESTRICTED ));
160160 assertThat (metadata .getItems ()).hasSize (2 );
161161 }
162162
@@ -165,13 +165,14 @@ void incrementalEndpointBuildChangeAccessOfSpecificEndpoint() {
165165 TestProject project = new TestProject (SpecificEndpoint .class );
166166 ConfigurationMetadata metadata = project .compile ();
167167 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.specific" ).fromSource (SpecificEndpoint .class ));
168- assertThat (metadata ).has (access ("specific" , Access .READ_ONLY ));
168+ assertThat (metadata ).has (access ("specific" , TestAccess .READ_ONLY ));
169169 assertThat (metadata ).has (cacheTtl ("specific" ));
170170 assertThat (metadata .getItems ()).hasSize (3 );
171- project .replaceText (SpecificEndpoint .class , "defaultAccess = Access.READ_ONLY" , "defaultAccess = Access.NONE" );
171+ project .replaceText (SpecificEndpoint .class , "defaultAccess = TestAccess.READ_ONLY" ,
172+ "defaultAccess = TestAccess.NONE" );
172173 metadata = project .compile ();
173174 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.specific" ).fromSource (SpecificEndpoint .class ));
174- assertThat (metadata ).has (access ("specific" , Access .NONE ));
175+ assertThat (metadata ).has (access ("specific" , TestAccess .NONE ));
175176 assertThat (metadata ).has (cacheTtl ("specific" ));
176177 assertThat (metadata .getItems ()).hasSize (3 );
177178 }
@@ -180,7 +181,7 @@ void incrementalEndpointBuildChangeAccessOfSpecificEndpoint() {
180181 void shouldTolerateEndpointWithSameId () {
181182 ConfigurationMetadata metadata = compile (SimpleEndpoint .class , SimpleEndpoint2 .class );
182183 assertThat (metadata ).has (Metadata .withGroup ("management.endpoint.simple" ).fromSource (SimpleEndpoint .class ));
183- assertThat (metadata ).has (defaultAccess ("simple" , "simple" , Access .UNRESTRICTED ));
184+ assertThat (metadata ).has (defaultAccess ("simple" , "simple" , TestAccess .UNRESTRICTED ));
184185 assertThat (metadata ).has (cacheTtl ("simple" ));
185186 assertThat (metadata .getItems ()).hasSize (3 );
186187 }
@@ -199,17 +200,17 @@ void endpointWithNullableParameter() {
199200 ConfigurationMetadata metadata = compile (NullableParameterEndpoint .class );
200201 assertThat (metadata )
201202 .has (Metadata .withGroup ("management.endpoint.nullable" ).fromSource (NullableParameterEndpoint .class ));
202- assertThat (metadata ).has (access ("nullable" , Access .UNRESTRICTED ));
203+ assertThat (metadata ).has (access ("nullable" , TestAccess .UNRESTRICTED ));
203204 assertThat (metadata ).has (cacheTtl ("nullable" ));
204205 assertThat (metadata .getItems ()).hasSize (3 );
205206 }
206207
207- private Metadata .MetadataItemCondition access (String endpointId , Access defaultValue ) {
208+ private Metadata .MetadataItemCondition access (String endpointId , TestAccess defaultValue ) {
208209 return defaultAccess (endpointId , endpointId , defaultValue );
209210 }
210211
211212 private Metadata .MetadataItemCondition defaultAccess (String endpointId , String endpointSuffix ,
212- Access defaultValue ) {
213+ TestAccess defaultValue ) {
213214 return Metadata .withAccess ("management.endpoint." + endpointSuffix + ".access" )
214215 .withDefaultValue (defaultValue .name ().toLowerCase (Locale .ENGLISH ))
215216 .withDescription ("Permitted level of access for the %s endpoint." .formatted (endpointId ));
0 commit comments