@Test(expectedExceptions = IllegalArgumentException.class) public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException { Invokable<?, Object> noPayload = method(TestPayload.class, "noPayload", String.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(noPayload, ImmutableList.<Object> of("robot"))) .method("POST").endpoint("http: binder().bindToRequest(request, ImmutableMap.<String, Object>of("fooble", "robot")); }
@SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { checkNotNull(postParams, "postParams"); GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request")); Invokable<?, ?> invoked = r.getInvocation().getInvokable(); checkArgument(invoked.isAnnotationPresent(Payload.class), "method %s must have @Payload annotation to use this binder", invoked); String payload = invoked.getAnnotation(Payload.class).value(); if (!postParams.isEmpty()) { payload = urlDecode(expand(payload, postParams)); } return (R) request.toBuilder().payload(payload).build(); }
BindMapToStringPayload implements MapBinder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { checkNotNull(postParams, "postParams"); GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request")); Invokable<?, ?> invoked = r.getInvocation().getInvokable(); checkArgument(invoked.isAnnotationPresent(Payload.class), "method %s must have @Payload annotation to use this binder", invoked); String payload = invoked.getAnnotation(Payload.class).value(); if (!postParams.isEmpty()) { payload = urlDecode(expand(payload, postParams)); } return (R) request.toBuilder().payload(payload).build(); } }
BindMapToStringPayload implements MapBinder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { checkNotNull(postParams, "postParams"); GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request")); Invokable<?, ?> invoked = r.getInvocation().getInvokable(); checkArgument(invoked.isAnnotationPresent(Payload.class), "method %s must have @Payload annotation to use this binder", invoked); String payload = invoked.getAnnotation(Payload.class).value(); if (!postParams.isEmpty()) { payload = urlDecode(expand(payload, postParams)); } return (R) request.toBuilder().payload(payload).build(); }  }
BindMapToStringPayload implements MapBinder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { checkNotNull(postParams, "postParams"); GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request")); Invokable<?, ?> invoked = r.getInvocation().getInvokable(); checkArgument(invoked.isAnnotationPresent(Payload.class), "method %s must have @Payload annotation to use this binder", invoked); String payload = invoked.getAnnotation(Payload.class).value(); if (!postParams.isEmpty()) { payload = urlDecode(expand(payload, postParams)); } return (R) request.toBuilder().payload(payload).build(); }  @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Map<String, Object> postParams); @Override R bindToRequest(R request, Object payload); }
BindMapToStringPayload implements MapBinder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { checkNotNull(postParams, "postParams"); GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request")); Invokable<?, ?> invoked = r.getInvocation().getInvokable(); checkArgument(invoked.isAnnotationPresent(Payload.class), "method %s must have @Payload annotation to use this binder", invoked); String payload = invoked.getAnnotation(Payload.class).value(); if (!postParams.isEmpty()) { payload = urlDecode(expand(payload, postParams)); } return (R) request.toBuilder().payload(payload).build(); }  @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Map<String, Object> postParams); @Override R bindToRequest(R request, Object payload);  }