Commit a70a8635 authored by Johnny Lim's avatar Johnny Lim Committed by Stephane Nicoll

Polish

Closes gh-6155
parent ed96d142
...@@ -4253,7 +4253,7 @@ reached. ...@@ -4253,7 +4253,7 @@ reached.
[[boot-features-restclient]] [[boot-features-restclient]]
== Calling REST services == Calling REST services
If you need to call remote REST services from your application, you can use Spring If you need to call remote REST services from your application, you can use Spring
Framework's `RestTemplate` class. Since `RestTemplate` instances often needs to be Framework's `RestTemplate` class. Since `RestTemplate` instances often need to be
customized before being used, Spring Boot does not provide any single auto-configured customized before being used, Spring Boot does not provide any single auto-configured
`RestTemplate` bean. It does, however, auto-configure a `RestTemplateBuilder` which can be `RestTemplate` bean. It does, however, auto-configure a `RestTemplateBuilder` which can be
used to create `RestTemplate` instances when needed. The auto-configured used to create `RestTemplate` instances when needed. The auto-configured
...@@ -4273,7 +4273,7 @@ Here's a typical example: ...@@ -4273,7 +4273,7 @@ Here's a typical example:
this.restTemplate = restTemplateBuilder.build(); this.restTemplate = restTemplateBuilder.build();
} }
public String someRestCall(String name) { public Details someRestCall(String name) {
return this.restTemplate.getForObject("/{name}/details", Details.class, name); return this.restTemplate.getForObject("/{name}/details", Details.class, name);
} }
...@@ -5035,7 +5035,7 @@ database you can use the `@AutoConfigureTestDatabase` annotation: ...@@ -5035,7 +5035,7 @@ database you can use the `@AutoConfigureTestDatabase` annotation:
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-client]] [[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-client]]
==== Auto-configured REST clients ==== Auto-configured REST clients
Use `@RestClientTest` annotation can be used if you want to test REST clients. By default Use `@RestClientTest` annotation can be used if you want to test REST clients. By default
it will auto configure Jackson and GSON support, configure a `RestTemplateBuilder` and it will auto-configure Jackson and GSON support, configure a `RestTemplateBuilder` and
add support for `MockRestServiceServer`. The specific beans that you want to test should add support for `MockRestServiceServer`. The specific beans that you want to test should
be specified using `value` or `components` attribute of `@RestClientTest`: be specified using `value` or `components` attribute of `@RestClientTest`:
...@@ -5047,7 +5047,7 @@ be specified using `value` or `components` attribute of `@RestClientTest`: ...@@ -5047,7 +5047,7 @@ be specified using `value` or `components` attribute of `@RestClientTest`:
public class ExampleRestClientTest { public class ExampleRestClientTest {
@Autowired @Autowired
private MyService service; private RemoteVehicleDetailsService service;
@Autowired @Autowired
private MockRestServiceServer server; private MockRestServiceServer server;
......
...@@ -348,9 +348,7 @@ public class AnnotationsPropertySourceTests { ...@@ -348,9 +348,7 @@ public class AnnotationsPropertySourceTests {
static @interface AttributeWithAliasAnnotation { static @interface AttributeWithAliasAnnotation {
@AliasFor(annotation = AliasedAttributeAnnotation.class, attribute = "value") @AliasFor(annotation = AliasedAttributeAnnotation.class, attribute = "value")
String value() String value() default "foo";
default "foo";
String someOtherAttribute() default "shouldNotBeMapped"; String someOtherAttribute() default "shouldNotBeMapped";
......
...@@ -416,7 +416,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda ...@@ -416,7 +416,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
/** /**
* {@link BeanPostProcessor} to handle {@link SpyBean} definitions. Registered as a * {@link BeanPostProcessor} to handle {@link SpyBean} definitions. Registered as a
* separate processor so that it can ordered above AOP post processors. * separate processor so that it can be ordered above AOP post processors.
*/ */
static class SpyPostProcessor extends InstantiationAwareBeanPostProcessorAdapter static class SpyPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
implements PriorityOrdered { implements PriorityOrdered {
...@@ -466,7 +466,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda ...@@ -466,7 +466,7 @@ public class MockitoPostProcessor extends InstantiationAwareBeanPostProcessorAda
} }
/** /**
* An registered field item. * A registered field item.
*/ */
private static class RegisteredField { private static class RegisteredField {
......
...@@ -285,7 +285,7 @@ public class RestTemplateBuilder { ...@@ -285,7 +285,7 @@ public class RestTemplateBuilder {
} }
/** /**
* Set the {@link HttpMessageConverter HttpMessageConverters} that should be applied * Set the {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied
* to the {@link RestTemplate}. Customizers are applied in the order that they were * to the {@link RestTemplate}. Customizers are applied in the order that they were
* added after builder configuration has been applied. Setting this value will replace * added after builder configuration has been applied. Setting this value will replace
* any previously configured customizers. * any previously configured customizers.
...@@ -301,7 +301,7 @@ public class RestTemplateBuilder { ...@@ -301,7 +301,7 @@ public class RestTemplateBuilder {
} }
/** /**
* Set the {@link HttpMessageConverter HttpMessageConverters} that should be applied * Set the {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied
* to the {@link RestTemplate}. Customizers are applied in the order that they were * to the {@link RestTemplate}. Customizers are applied in the order that they were
* added after builder configuration has been applied. Setting this value will replace * added after builder configuration has been applied. Setting this value will replace
* any previously configured customizers. * any previously configured customizers.
...@@ -321,7 +321,7 @@ public class RestTemplateBuilder { ...@@ -321,7 +321,7 @@ public class RestTemplateBuilder {
} }
/** /**
* Add {@link HttpMessageConverter HttpMessageConverters} that should be applied to * Add {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied to
* the {@link RestTemplate}. Customizers are applied in the order that they were added * the {@link RestTemplate}. Customizers are applied in the order that they were added
* after builder configuration has been applied. * after builder configuration has been applied.
* @param restTemplateCustomizers the customizers to add * @param restTemplateCustomizers the customizers to add
...@@ -336,7 +336,7 @@ public class RestTemplateBuilder { ...@@ -336,7 +336,7 @@ public class RestTemplateBuilder {
} }
/** /**
* Add {@link HttpMessageConverter HttpMessageConverters} that should be applied to * Add {@link RestTemplateCustomizer RestTemplateCustomizers} that should be applied to
* the {@link RestTemplate}. Customizers are applied in the order that they were added * the {@link RestTemplate}. Customizers are applied in the order that they were added
* after builder configuration has been applied. * after builder configuration has been applied.
* @param customizers the customizers to add * @param customizers the customizers to add
......
...@@ -26,7 +26,7 @@ import org.springframework.web.util.DefaultUriTemplateHandler; ...@@ -26,7 +26,7 @@ import org.springframework.web.util.DefaultUriTemplateHandler;
import org.springframework.web.util.UriTemplateHandler; import org.springframework.web.util.UriTemplateHandler;
/** /**
* {@link UriTemplateHandler} to set the root for URI that start with {@code '/'}. * {@link UriTemplateHandler} to set the root for URI that starts with {@code '/'}.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
...@@ -44,7 +44,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler { ...@@ -44,7 +44,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
/** /**
* Create a new {@link RootUriTemplateHandler} instance. * Create a new {@link RootUriTemplateHandler} instance.
* @param rootUri the root URI to used to prefix relative URLs * @param rootUri the root URI to be used to prefix relative URLs
*/ */
public RootUriTemplateHandler(String rootUri) { public RootUriTemplateHandler(String rootUri) {
this(rootUri, new DefaultUriTemplateHandler()); this(rootUri, new DefaultUriTemplateHandler());
...@@ -52,7 +52,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler { ...@@ -52,7 +52,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler {
/** /**
* Create a new {@link RootUriTemplateHandler} instance. * Create a new {@link RootUriTemplateHandler} instance.
* @param rootUri the root URI to used to prefix relative URLs * @param rootUri the root URI to be used to prefix relative URLs
* @param handler the delegate handler * @param handler the delegate handler
*/ */
public RootUriTemplateHandler(String rootUri, UriTemplateHandler handler) { public RootUriTemplateHandler(String rootUri, UriTemplateHandler handler) {
......
...@@ -54,7 +54,7 @@ public class BasicAuthorizationInterceptorTests { ...@@ -54,7 +54,7 @@ public class BasicAuthorizationInterceptorTests {
@Test @Test
public void createWhenPasswordIsNullShouldUseEmptyPassword() throws Exception { public void createWhenPasswordIsNullShouldUseEmptyPassword() throws Exception {
BasicAuthorizationInterceptor interceptor = new BasicAuthorizationInterceptor( BasicAuthorizationInterceptor interceptor = new BasicAuthorizationInterceptor(
"username", ""); "username", null);
assertThat(interceptor).extracting("password").containsExactly(""); assertThat(interceptor).extracting("password").containsExactly("");
} }
......
...@@ -264,22 +264,14 @@ public class RestTemplateBuilderTests { ...@@ -264,22 +264,14 @@ public class RestTemplateBuilderTests {
} }
@Test @Test
public void customizersWhenNullArrayShouldThrowException() throws Exception { public void customizersWhenCustomizersAreNullShouldThrowException() throws Exception {
this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Customizers must not be null");
RestTemplateCustomizer[] customizers = null;
this.builder.customizers(customizers);
}
@Test
public void customizersWhenConvertersAreNullShouldThrowException() throws Exception {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("RestTemplateCustomizers must not be null"); this.thrown.expectMessage("RestTemplateCustomizers must not be null");
this.builder.customizers((RestTemplateCustomizer[]) null); this.builder.customizers((RestTemplateCustomizer[]) null);
} }
@Test @Test
public void customizersCollectionWhenConvertersAreNullShouldThrowException() public void customizersCollectionWhenCustomizersAreNullShouldThrowException()
throws Exception { throws Exception {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("RestTemplateCustomizers must not be null"); this.thrown.expectMessage("RestTemplateCustomizers must not be null");
...@@ -318,7 +310,7 @@ public class RestTemplateBuilderTests { ...@@ -318,7 +310,7 @@ public class RestTemplateBuilderTests {
} }
@Test @Test
public void additionalCustomizersWhenConvertersAreNullShouldThrowException() public void additionalCustomizersWhenCustomizersAreNullShouldThrowException()
throws Exception { throws Exception {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("RestTemplateCustomizers must not be null"); this.thrown.expectMessage("RestTemplateCustomizers must not be null");
...@@ -326,7 +318,7 @@ public class RestTemplateBuilderTests { ...@@ -326,7 +318,7 @@ public class RestTemplateBuilderTests {
} }
@Test @Test
public void additionalCustomizersCollectionWhenConvertersAreNullShouldThrowException() public void additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException()
throws Exception { throws Exception {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("RestTemplateCustomizers must not be null"); this.thrown.expectMessage("RestTemplateCustomizers must not be null");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment