Search in sources :

Example 1 with DefaultUriBuilderFactory

use of cn.taketoday.web.util.DefaultUriBuilderFactory in project today-infrastructure by TAKETODAY.

the class RestTemplateTests method getForObjectWithCustomUriTemplateHandler.

@Test
void getForObjectWithCustomUriTemplateHandler() throws Exception {
    DefaultUriBuilderFactory uriTemplateHandler = new DefaultUriBuilderFactory();
    template.setUriTemplateHandler(uriTemplateHandler);
    mockSentRequest(GET, "https://example.com/hotels/1/pic/pics%2Flogo.png/size/150x150");
    mockResponseStatus(HttpStatus.OK);
    given(response.getHeaders()).willReturn(HttpHeaders.create());
    given(response.getBody()).willReturn(StreamUtils.emptyInput());
    Map<String, String> uriVariables = new HashMap<>(2);
    uriVariables.put("hotel", "1");
    uriVariables.put("publicpath", "pics/logo.png");
    uriVariables.put("scale", "150x150");
    String url = "https://example.com/hotels/{hotel}/pic/{publicpath}/size/{scale}";
    template.getForObject(url, String.class, uriVariables);
    verify(response).close();
}
Also used : HashMap(java.util.HashMap) DefaultUriBuilderFactory(cn.taketoday.web.util.DefaultUriBuilderFactory) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultUriBuilderFactory

use of cn.taketoday.web.util.DefaultUriBuilderFactory in project today-framework by TAKETODAY.

the class DefaultWebClientBuilder method initUriBuilderFactory.

private UriBuilderFactory initUriBuilderFactory() {
    if (this.uriBuilderFactory != null) {
        return this.uriBuilderFactory;
    }
    DefaultUriBuilderFactory factory = (this.baseUrl != null ? new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory());
    factory.setDefaultUriVariables(this.defaultUriVariables);
    return factory;
}
Also used : DefaultUriBuilderFactory(cn.taketoday.web.util.DefaultUriBuilderFactory)

Example 3 with DefaultUriBuilderFactory

use of cn.taketoday.web.util.DefaultUriBuilderFactory in project today-framework by TAKETODAY.

the class RestTemplateTests method getForObjectWithCustomUriTemplateHandler.

@Test
void getForObjectWithCustomUriTemplateHandler() throws Exception {
    DefaultUriBuilderFactory uriTemplateHandler = new DefaultUriBuilderFactory();
    template.setUriTemplateHandler(uriTemplateHandler);
    mockSentRequest(GET, "https://example.com/hotels/1/pic/pics%2Flogo.png/size/150x150");
    mockResponseStatus(HttpStatus.OK);
    given(response.getHeaders()).willReturn(HttpHeaders.create());
    given(response.getBody()).willReturn(StreamUtils.emptyInput());
    Map<String, String> uriVariables = new HashMap<>(2);
    uriVariables.put("hotel", "1");
    uriVariables.put("publicpath", "pics/logo.png");
    uriVariables.put("scale", "150x150");
    String url = "https://example.com/hotels/{hotel}/pic/{publicpath}/size/{scale}";
    template.getForObject(url, String.class, uriVariables);
    verify(response).close();
}
Also used : HashMap(java.util.HashMap) DefaultUriBuilderFactory(cn.taketoday.web.util.DefaultUriBuilderFactory) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultUriBuilderFactory

use of cn.taketoday.web.util.DefaultUriBuilderFactory in project today-infrastructure by TAKETODAY.

the class DefaultWebClientBuilder method initUriBuilderFactory.

private UriBuilderFactory initUriBuilderFactory() {
    if (this.uriBuilderFactory != null) {
        return this.uriBuilderFactory;
    }
    DefaultUriBuilderFactory factory = (this.baseUrl != null ? new DefaultUriBuilderFactory(this.baseUrl) : new DefaultUriBuilderFactory());
    factory.setDefaultUriVariables(this.defaultUriVariables);
    return factory;
}
Also used : DefaultUriBuilderFactory(cn.taketoday.web.util.DefaultUriBuilderFactory)

Aggregations

DefaultUriBuilderFactory (cn.taketoday.web.util.DefaultUriBuilderFactory)4 HashMap (java.util.HashMap)2 Test (org.junit.jupiter.api.Test)2