BindUserIdGroupPairToSourceSecurityGroupFormParams implements Binder { @SuppressWarnings("unchecked") @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof UserIdGroupPair, "this binder is only valid for UserIdGroupPair!"); UserIdGroupPair pair = (UserIdGroupPair) input; Builder<String, String> builder = ImmutableMultimap.builder(); builder.put("SourceSecurityGroupOwnerId", pair.getUserId()); builder.put("SourceSecurityGroupName", pair.getGroupName()); return (R) request.toBuilder().replaceFormParams(builder.build()).build(); }  @SuppressWarnings("unchecked") @Override R bindToRequest(R request, Object input);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeUserIdGroupPair() { HttpRequest request = HttpRequest.builder().method("POST").endpoint("http: binder.bindToRequest(request, new File("foo")); }
@Test(expectedExceptions = NullPointerException.class) public void testNullIsBad() { HttpRequest request = HttpRequest.builder().method("GET").endpoint("http: binder.bindToRequest(request, null); }