Package org.springframework.web.util

Examples of org.springframework.web.util.UriTemplate$Parser


    @Override
    public void doWith(ResourceTester content) {

      String href = content.assertHasLink("self", null).getHref();

      UriTemplate uriTemplate = new UriTemplate(template.toString());
      assertThat(String.format("Expected %s to match %s!", href, uriTemplate.toString()), uriTemplate.matches(href),
          is(true));
    }
View Full Code Here


    patchAndGet(frodosSiblingsLink, links.get(1).getHref(), TEXT_URI_LIST);
    patchAndGet(frodosSiblingsLink, links.get(2).getHref(), TEXT_URI_LIST);
    patchAndGet(frodosSiblingsLink, links.get(3).getHref(), TEXT_URI_LIST);

    String pippinId = new UriTemplate("/people/{id}").match(links.get(3).getHref()).get("id");
    deleteAndVerify(new Link(frodosSiblingsLink.getHref() + "/" + pippinId));

    assertSiblingNames(frodosSiblingsLink, "Bilbo", "Merry");
  }
View Full Code Here

    mapper.writeValue(writer, resource);

    String s = writer.toString();

    Link fatherLink = linkDiscoverer.findLinkWithRel("father", s);
    assertThat(fatherLink.getHref(), endsWith(new UriTemplate("/{id}/father").expand(person.getId()).toString()));

    Link siblingLink = linkDiscoverer.findLinkWithRel("siblings", s);
    assertThat(siblingLink.getHref(), endsWith(new UriTemplate("/{id}/siblings").expand(person.getId()).toString()));
  }
View Full Code Here

        String url = resolveUrl(path, uriVariables);
        return restClient.post(gitHub.restOperations(), url, String.class, body);
    }

    private String resolveUrl(String path, Object[] uriVariables) {
        String expandedPath = new UriTemplate(path).expand(uriVariables).toString();
        return API_URL_BASE + expandedPath;
    }
View Full Code Here

    public String sendPostRequestForHtml(String path, String body, Object... uriVariables) {
        return "<h1>HTML</h1>";
    }

    private String handleRequest(String path, Object[] uriVariables) {
        String url = new UriTemplate(path).expand(uriVariables).getPath();
        if (!responseMap.containsKey(url)) {
            throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "no response for: " + url);
        }
        return responseMap.get(url);
    }
View Full Code Here

  public static ControllerLinkBuilder linkTo(Class<?> controller, Method method, Object... parameters) {

    Assert.notNull(controller, "Controller type must not be null!");
    Assert.notNull(method, "Method must not be null!");

    UriTemplate template = new UriTemplate(DISCOVERER.getMapping(controller, method));
    URI uri = template.expand(parameters);

    return new ControllerLinkBuilder(getBuilder()).slash(uri);
  }
View Full Code Here

    Method method = invocation.getMethod();

    String mapping = DISCOVERER.getMapping(invocation.getTargetType(), method);
    UriComponentsBuilder builder = ControllerLinkBuilder.getBuilder().path(mapping);

    UriTemplate template = new UriTemplate(mapping);
    Map<String, Object> values = new HashMap<String, Object>();

    Iterator<String> names = template.getVariableNames().iterator();
    while (classMappingParameters.hasNext()) {
      values.put(names.next(), classMappingParameters.next());
    }

    for (BoundMethodParameter parameter : PATH_VARIABLE_ACCESSOR.getBoundParameters(invocation)) {
View Full Code Here

  @Override
  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException {

    URI expanded = new UriTemplate(url).expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  @Override
  public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
      ResponseExtractor<T> responseExtractor, Map<String, ?> urlVariables) throws RestClientException {

    URI expanded = new UriTemplate(url).expand(urlVariables);
    return doExecute(expanded, method, requestCallback, responseExtractor);
  }
View Full Code Here

  /**
   * @see org.springframework.web.servlet.support.RequestContext#getContextUrl(String, Map)
   */
  public String getContextUrl(String relativeUrl, Map<String,String> params) {
    UriTemplate template = new UriTemplate(relativeUrl);
    return getContextPath() + template.expand(params).toASCIIString();
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.util.UriTemplate$Parser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.