@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument( checkNotNull(input, "input") instanceof Map<?, ?>, "this binder is only valid for Maps!"); checkNotNull(request, "request"); @SuppressWarnings("unchecked") Map<String, String> userMetadata = Maps2.transformKeys((Map<String, String>) input, FN); return ModifyRequest.putHeaders(request, Multimaps.forMap(userMetadata)); }
/** * base jclouds tests expect properties to arrive in a different naming convention, based on * provider name. * * <p>ex. * * <pre> * test.jenkins.compute.provider=aws-ec2 * test.jenkins.compute.identity=access * test.jenkins.compute.credential=secret * </pre> * * should turn into * * <pre> * test.aws-ec2.identity=access * test.aws-ec2.credential=secret * </pre> */ static { PROVIDER = checkNotNull( System.getProperty("test.jenkins.compute.provider"), "test.compute.provider variable must be set!"); Map<String, String> filtered = Maps.filterKeys( Map.class.cast(System.getProperties()), Predicates.containsPattern("^test\\.jenkins\\.compute")); Map<String, String> transformed = Maps2.transformKeys( filtered, new Function<String, String>() { public String apply(String arg0) { return arg0.replaceAll("test.jenkins.compute", "test." + PROVIDER); } }); System.getProperties().putAll(transformed); }