mirror of https://github.com/apache/jclouds.git
consider @FormParam on @Delegate calls
This commit is contained in:
parent
55925e4bf6
commit
d9c4cf2d39
|
@ -220,8 +220,13 @@ public class RestAnnotationProcessor implements Function<Invocation, HttpRequest
|
|||
if (caller != null)
|
||||
tokenValues.putAll(addPathAndGetTokens(caller, uriBuilder));
|
||||
tokenValues.putAll(addPathAndGetTokens(invocation, uriBuilder));
|
||||
|
||||
Multimap<String, Object> formParams = addFormParams(tokenValues, invocation);
|
||||
Multimap<String, Object> formParams;
|
||||
if (caller != null) {
|
||||
formParams = addFormParams(tokenValues, caller);
|
||||
formParams.putAll(addFormParams(tokenValues, invocation));
|
||||
} else {
|
||||
formParams = addFormParams(tokenValues, invocation);
|
||||
}
|
||||
Multimap<String, Object> queryParams = addQueryParams(tokenValues, invocation);
|
||||
Multimap<String, String> headers = buildHeaders(tokenValues, invocation);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.rest.annotationparsing;
|
|||
import static org.jclouds.providers.AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.HEAD;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -52,6 +53,8 @@ import com.google.inject.Module;
|
|||
public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<DelegateAnnotationExpectTest.DelegatingApi> {
|
||||
|
||||
static interface DelegatingApi {
|
||||
@Delegate
|
||||
DiskApi getDiskApiForProjectForm(@FormParam("project") String projectName);
|
||||
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
|
@ -59,6 +62,8 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
|||
}
|
||||
|
||||
static interface DelegatingAsyncApi {
|
||||
@Delegate
|
||||
DiskAsyncApi getDiskApiForProjectForm(@FormParam("project") String projectName);
|
||||
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
|
@ -66,12 +71,17 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
|||
}
|
||||
|
||||
static interface DiskApi {
|
||||
void form();
|
||||
|
||||
void syncAll();
|
||||
|
||||
boolean exists(@PathParam("disk") String diskName);
|
||||
}
|
||||
|
||||
static interface DiskAsyncApi {
|
||||
@POST
|
||||
ListenableFuture<Void> form();
|
||||
|
||||
@POST
|
||||
@Payload("<Sync>{project}</Sync>")
|
||||
ListenableFuture<Void> syncAll();
|
||||
|
@ -82,6 +92,14 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
|||
public ListenableFuture<Boolean> exists(@PathParam("disk") String diskName);
|
||||
}
|
||||
|
||||
public void testDelegatingCallTakesIntoConsiderationAndCalleeFormParam() {
|
||||
|
||||
DelegatingApi client = requestSendsResponse(HttpRequest.builder().method("POST").endpoint("http://mock")
|
||||
.addFormParam("project", "prod").build(), HttpResponse.builder().statusCode(200).build());
|
||||
|
||||
client.getDiskApiForProjectForm("prod").form();
|
||||
}
|
||||
|
||||
public void testDelegatingCallTakesIntoConsiderationAndCalleePayloadParam() {
|
||||
|
||||
DelegatingApi client = requestSendsResponse(
|
||||
|
|
Loading…
Reference in New Issue