Package org.jclouds.rest.internal

Examples of org.jclouds.rest.internal.GeneratedHttpRequest


   }

   public void testSearchClientsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "searchClients", SearchOptions.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(SearchOptions.Builder.query("text").rows(5))));

      assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/client?q=text&rows=5 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION
            + "-test\n");
View Full Code Here


   }

   public void testSearchNodes() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "searchNodes");
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.of()));

      assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/node HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION
            + "-test\n");
      assertPayloadEquals(httpRequest, null, null, false);
View Full Code Here

   }

   public void testSearchNodesWithOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "searchNodes", SearchOptions.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(SearchOptions.Builder.query("foo:foo").start(3))));

      assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/node?q=foo%3Afoo&start=3 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION
            + "-test\n");
View Full Code Here

   }

   public void testSearchDatabagItems() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "searchDatabagItems", String.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of("foo")));

      assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/foo HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION
            + "-test\n");
      assertPayloadEquals(httpRequest, null, null, false);
View Full Code Here

   }

   public void testSearchDatabagItemsWithOptions() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "searchDatabagItems", String.class, SearchOptions.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of("foo", SearchOptions.Builder.query("bar").sort("name DESC"))));

      assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/foo?q=bar&sort=name%20DESC HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION
            + "-test\n");
View Full Code Here

   }

   public void testGetResourceContents() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(ChefApi.class, "getResourceContents", Resource.class);
      GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(Resource.builder().name("test").url(URI.create("http://foo/bar")).build())));

      assertRequestLineEquals(httpRequest, "GET http://foo/bar HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION
            + "-test\n");
View Full Code Here

   @Override
   public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
      checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
            "this binder is only valid for GeneratedHttpRequests");
      GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
      checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point");

      String name = checkNotNull(postParams.remove("name"), "name").toString();
      CreateClientOptions options = (CreateClientOptions) Iterables.find(gRequest.getInvocation().getArgs(),
            Predicates.instanceOf(CreateClientOptions.class));

      return bindToRequest(request, new CreateClientParams(name, options));
   }
View Full Code Here

                                       .addQueryParam("lastname", "LastName").build();

   public void testCreateAccount() throws Exception {
      Invokable<?, ?> method = method(GlobalUserAsyncClient.class, "createUser", String.class, String.class,
         String.class, String.class, String.class, String.class, CreateUserOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("user", "account", "email@example.com",
         "hashed-password", "FirstName", "LastName"));

      assertRequestLineEquals(httpRequest, createUser.getRequestLine());
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);
View Full Code Here

      checkFilters(httpRequest);
   }

   public void testUpdateUser() throws Exception {
      Invokable<?, ?> method = method(GlobalUserAsyncClient.class, "updateUser", String.class, UpdateUserOptions[].class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=updateUser&id=42 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);
View Full Code Here

      checkFilters(httpRequest);
   }

   public void testDeleteUser() throws Exception {
      Invokable<?, ?> method = method(GlobalUserAsyncClient.class, "deleteUser", String.class);
      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(42L));

      assertRequestLineEquals(httpRequest,
         "GET http://localhost:8080/client/api?response=json&command=deleteUser&id=42 HTTP/1.1");
      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
      assertPayloadEquals(httpRequest, null, null, false);
View Full Code Here

TOP

Related Classes of org.jclouds.rest.internal.GeneratedHttpRequest

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.