mirror of https://github.com/apache/jclouds.git
consider @FormParam on @Delegate calls
This commit is contained in:
parent
1674d46548
commit
6dd96610e0
|
@ -422,7 +422,13 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
tokenValues.putAll(addPathAndGetTokens(declaring, method, args, uriBuilder));
|
tokenValues.putAll(addPathAndGetTokens(declaring, method, args, uriBuilder));
|
||||||
|
|
||||||
Multimap<String, Object> formParams = addFormParams(tokenValues, method, args);
|
Multimap<String, Object> formParams;
|
||||||
|
if (caller != null) {
|
||||||
|
formParams = addFormParams(tokenValues, caller.getMethod(), caller.getArgs());
|
||||||
|
formParams.putAll(addFormParams(tokenValues, method, args));
|
||||||
|
} else {
|
||||||
|
formParams = addFormParams(tokenValues, method, args);
|
||||||
|
}
|
||||||
Multimap<String, Object> queryParams = addQueryParams(tokenValues, method, args);
|
Multimap<String, Object> queryParams = addQueryParams(tokenValues, method, args);
|
||||||
Multimap<String, String> headers = buildHeaders(tokenValues, method, args);
|
Multimap<String, String> headers = buildHeaders(tokenValues, method, args);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
import javax.ws.rs.HEAD;
|
import javax.ws.rs.HEAD;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
@ -56,6 +57,8 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
||||||
|
|
||||||
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
static interface DelegatingApi {
|
static interface DelegatingApi {
|
||||||
|
@Delegate
|
||||||
|
DiskApi getDiskApiForProjectForm(@FormParam("project") String projectName);
|
||||||
|
|
||||||
@Delegate
|
@Delegate
|
||||||
@Path("/projects/{project}")
|
@Path("/projects/{project}")
|
||||||
|
@ -63,6 +66,8 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
||||||
}
|
}
|
||||||
|
|
||||||
static interface DelegatingAsyncApi {
|
static interface DelegatingAsyncApi {
|
||||||
|
@Delegate
|
||||||
|
DiskAsyncApi getDiskApiForProjectForm(@FormParam("project") String projectName);
|
||||||
|
|
||||||
@Delegate
|
@Delegate
|
||||||
@Path("/projects/{project}")
|
@Path("/projects/{project}")
|
||||||
|
@ -71,12 +76,17 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
||||||
|
|
||||||
@Timeout(duration = 1, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 1, timeUnit = TimeUnit.SECONDS)
|
||||||
static interface DiskApi {
|
static interface DiskApi {
|
||||||
|
void form();
|
||||||
|
|
||||||
void syncAll();
|
void syncAll();
|
||||||
|
|
||||||
boolean exists(@PathParam("disk") String diskName);
|
boolean exists(@PathParam("disk") String diskName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static interface DiskAsyncApi {
|
static interface DiskAsyncApi {
|
||||||
|
@POST
|
||||||
|
ListenableFuture<Void> form();
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Payload("<Sync>{project}</Sync>")
|
@Payload("<Sync>{project}</Sync>")
|
||||||
ListenableFuture<Void> syncAll();
|
ListenableFuture<Void> syncAll();
|
||||||
|
@ -87,6 +97,14 @@ public class DelegateAnnotationExpectTest extends BaseRestClientExpectTest<Deleg
|
||||||
public ListenableFuture<Boolean> exists(@PathParam("disk") String diskName);
|
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() {
|
public void testDelegatingCallTakesIntoConsiderationAndCalleePayloadParam() {
|
||||||
|
|
||||||
DelegatingApi client = requestSendsResponse(
|
DelegatingApi client = requestSendsResponse(
|
||||||
|
|
Loading…
Reference in New Issue