use of cn.taketoday.web.util.UriTemplateHandler in project today-infrastructure by TAKETODAY.
the class RootUriRequestExpectationManager method forRestTemplate.
/**
* Return {@link RequestExpectationManager} to be used for binding with the specified
* {@link RestTemplate}. If the {@link RestTemplate} is using a
* {@link RootUriTemplateHandler} then a {@link RootUriRequestExpectationManager} is
* returned, otherwise the source manager is returned unchanged.
*
* @param restTemplate the source REST template
* @param expectationManager the source {@link RequestExpectationManager}
* @return a {@link RequestExpectationManager} to be bound to the template
*/
public static RequestExpectationManager forRestTemplate(RestTemplate restTemplate, RequestExpectationManager expectationManager) {
Assert.notNull(restTemplate, "RestTemplate must not be null");
UriTemplateHandler templateHandler = restTemplate.getUriTemplateHandler();
if (templateHandler instanceof RootUriTemplateHandler) {
return new RootUriRequestExpectationManager(((RootUriTemplateHandler) templateHandler).getRootUri(), expectationManager);
}
return expectationManager;
}
Aggregations