Package org.springframework.hateoas.client

Examples of org.springframework.hateoas.client.FormRequest


    when(httpClient.execute(Mockito.<HttpGet> any(), Mockito.<ResponseHandler<?>> any())).thenReturn(indexPage,
        searchForm, result);
    when(indexPage.getRel("search")).thenReturn(expectedRel);
    when(searchForm.getFormRequest(Mockito.eq("people"), Mockito.<Args> any())).thenReturn(
        new FormRequest(HttpMethod.GET, new LinkedMultiValueMap<String, String>(), new URI("/"), "", "UTF-8"));

    browser.followRel("search").submitForm("people", Args.of("customerId", 1));

    Browsable currentResource = browser.getCurrentResource();
View Full Code Here


    try {
      // ResponseHandler returns xhtml or xforms or whatever
      // browsable, capable of handling its content
      ResponseHandler<Browsable> responseHandler = new BrowsableResponseHandler();

      FormRequest formRequest = getCurrentResource().getFormRequest(name, values);
      System.out.println("submitting form " + name + " with " + formRequest);
      URI uri = formRequest.getURI();
      if (!uri.isAbsolute()) {
        uri = new URI(context.toASCIIString() + uri.toASCIIString());
      }
      HttpMethod method = formRequest.getMethod();
      switch (method) {
      case GET: {
        uri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), formRequest.getRequestBody(), null);
        HttpGet httpGet = createGet(uri);
        currentResource = httpClient.execute(httpGet, responseHandler);
        break;
      }
      case POST: {
        HttpPost httpPost = new HttpPost(uri);
        StringEntity entity = new StringEntity(formRequest.getRequestBody(), ContentType.create(
            formRequest.getContentType(), formRequest.getEncoding()));
        httpPost.setEntity(entity);
        currentResource = httpClient.execute(httpPost, responseHandler);
        break;
      }
      default:
View Full Code Here

TOP

Related Classes of org.springframework.hateoas.client.FormRequest

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.