From 58f0f577d0863f5eb0cc9e0a0b3f099b6b2666f9 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 19 Jan 2013 17:17:06 -0800 Subject: [PATCH 1/2] centralize construction of invokables --- .../main/java/org/jclouds/ContextBuilder.java | 6 +- core/src/main/java/org/jclouds/apis/Apis.java | 4 +- .../apis/internal/BaseApiMetadata.java | 6 +- ...WithWildcardExtendsExplicitAndRawType.java | 7 +- .../java/org/jclouds/providers/Providers.java | 9 +- .../jclouds/reflect/FunctionalReflection.java | 8 +- .../java/org/jclouds/reflect/Reflection2.java | 195 ++++++++-- .../rest/config/CallGetOnFuturesProvider.java | 3 +- .../jclouds/rest/config/HttpApiProvider.java | 3 +- .../org/jclouds/rest/config/RestModule.java | 38 +- .../rest/internal/BaseRestApiMetadata.java | 4 +- .../DelegatesToInvocationFunction.java | 27 +- .../org/jclouds/apis/BaseViewLiveTest.java | 4 +- .../http/functions/BaseHandlerTest.java | 6 +- .../BackoffLimitedRetryHandlerTest.java | 4 +- .../org/jclouds/internal/BaseViewTest.java | 12 +- .../java/org/jclouds/json/BaseParserTest.java | 5 +- .../internal/BaseProviderMetadataTest.java | 4 +- .../org/jclouds/reflect/Reflection2Test.java | 79 ++++ .../jclouds/rest/InputParamValidatorTest.java | 13 +- .../ProvidesAnnotationExpectTest.java | 148 ++++++++ .../binders/BindMapToStringPayloadTest.java | 10 +- ...aphicallyAtOrAfterSinceApiVersionTest.java | 8 +- .../internal/BaseRestApiMetadataTest.java | 5 +- .../rest/internal/BlockOnFutureTest.java | 10 +- .../internal/RestAnnotationProcessorTest.java | 343 +++++++----------- .../java/org/jclouds/util/Optionals2Test.java | 10 +- .../org/jclouds/util/Throwables2Test.java | 6 +- 28 files changed, 631 insertions(+), 346 deletions(-) create mode 100644 core/src/test/java/org/jclouds/reflect/Reflection2Test.java create mode 100644 core/src/test/java/org/jclouds/rest/annotationparsing/ProvidesAnnotationExpectTest.java diff --git a/core/src/main/java/org/jclouds/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java index 254de0a220..106c28f0e7 100644 --- a/core/src/main/java/org/jclouds/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/ContextBuilder.java @@ -42,7 +42,7 @@ import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; import static org.jclouds.Constants.PROPERTY_PROVIDER; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; import java.util.List; @@ -491,7 +491,7 @@ public class ContextBuilder { // TODO: move this up if (apiMetadata instanceof RestApiMetadata) { RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); - modules.add(new RestClientModule(typeTokenOf(rest.getApi()), typeTokenOf(rest.getAsyncApi()))); + modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi()))); } else { modules.add(new RestModule()); } @@ -568,7 +568,7 @@ public class ContextBuilder { * @see #buildView(TypeToken) */ public V buildView(Class viewType) { - return buildView(typeTokenOf(viewType)); + return buildView(typeToken(viewType)); } /** diff --git a/core/src/main/java/org/jclouds/apis/Apis.java b/core/src/main/java/org/jclouds/apis/Apis.java index 58b722095c..29ae0a2926 100644 --- a/core/src/main/java/org/jclouds/apis/Apis.java +++ b/core/src/main/java/org/jclouds/apis/Apis.java @@ -21,7 +21,7 @@ package org.jclouds.apis; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.NoSuchElementException; import java.util.ServiceLoader; @@ -116,7 +116,7 @@ public class Apis { } public static Iterable viewableAs(Class type) { - return filter(all(), ApiPredicates.viewableAs(typeTokenOf(type))); + return filter(all(), ApiPredicates.viewableAs(typeToken(type))); } /** diff --git a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java index 761023998e..a86b0189ce 100644 --- a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java @@ -32,7 +32,7 @@ import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; import static org.jclouds.Constants.PROPERTY_USER_THREADS; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -93,7 +93,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { private Optional defaultCredential = Optional.absent(); private Properties defaultProperties = BaseApiMetadata.defaultProperties(); private URI documentation; - private TypeToken context = typeTokenOf(Context.class); + private TypeToken context = typeToken(Context.class); private Set> defaultModules = ImmutableSet.of(); /** @@ -119,7 +119,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { */ @Override public T view(Class view) { - return view(typeTokenOf(checkNotNull(view, "view"))); + return view(typeToken(checkNotNull(view, "view"))); } /** diff --git a/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java b/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java index 780b22ed23..d14c554b74 100644 --- a/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java +++ b/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java @@ -17,10 +17,9 @@ * under the License. */ package org.jclouds.config; - import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; @@ -50,8 +49,8 @@ public class BindRestContextWithWildcardExtendsExplicitAndRawType extends Abstra @SuppressWarnings("unchecked") @Override protected void configure() { - TypeToken concreteType = BaseRestApiMetadata.contextToken(typeTokenOf(restApiMetadata.getApi()), TypeToken - .of(restApiMetadata.getAsyncApi())); + TypeToken concreteType = BaseRestApiMetadata.contextToken(typeToken(restApiMetadata.getApi()), + typeToken(restApiMetadata.getAsyncApi())); // bind explicit type bind(TypeLiteral.get(concreteType.getType())).to( TypeLiteral.class.cast(TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index 8500ba6977..36b55e2efa 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -17,10 +17,9 @@ * under the License. */ package org.jclouds.providers; - import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.NoSuchElementException; import java.util.ServiceLoader; @@ -117,7 +116,7 @@ public class Providers { } public static Iterable viewableAs(Class viewableAs) { - return filter(all(), ProviderPredicates.viewableAs(typeTokenOf(viewableAs))); + return filter(all(), ProviderPredicates.viewableAs(typeToken(viewableAs))); } /** @@ -179,7 +178,7 @@ public class Providers { public static Iterable boundedByIso3166Code(String iso3166Code, Class viewableAs) { - return boundedByIso3166Code(iso3166Code, typeTokenOf(viewableAs)); + return boundedByIso3166Code(iso3166Code, typeToken(viewableAs)); } /** @@ -215,6 +214,6 @@ public class Providers { public static Iterable collocatedWith(ProviderMetadata providerMetadata, Class viewableAs) { - return collocatedWith(providerMetadata, typeTokenOf(viewableAs)); + return collocatedWith(providerMetadata, typeToken(viewableAs)); } } diff --git a/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java b/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java index fe659fad4b..4e96983ba2 100644 --- a/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java +++ b/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java @@ -24,7 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.notNull; import static com.google.common.base.Throwables.propagate; import static com.google.common.collect.Iterables.all; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Throwables2.propagateIfPossible; import java.lang.reflect.Method; @@ -84,8 +85,7 @@ public final class FunctionalReflection { public static T newProxy(Class enclosingType, Function invocationFunction) { checkNotNull(invocationFunction, "invocationFunction"); - return newProxy(enclosingType, - new FunctionalInvocationHandler(typeTokenOf(enclosingType), invocationFunction)); + return newProxy(enclosingType, new FunctionalInvocationHandler(typeToken(enclosingType), invocationFunction)); } @SuppressWarnings("unchecked") @@ -113,7 +113,7 @@ public final class FunctionalReflection { args = ImmutableList.copyOf(args); else args = Collections.unmodifiableList(args); - Invokable invokable = enclosingType.method(invoked); + Invokable invokable = method(enclosingType, invoked); Invocation invocation = Invocation.create(invokable, args); try { return invocationFunction.apply(invocation); diff --git a/core/src/main/java/org/jclouds/reflect/Reflection2.java b/core/src/main/java/org/jclouds/reflect/Reflection2.java index b3c9eeb1b7..7c603abe60 100644 --- a/core/src/main/java/org/jclouds/reflect/Reflection2.java +++ b/core/src/main/java/org/jclouds/reflect/Reflection2.java @@ -19,65 +19,196 @@ package org.jclouds.reflect; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.toArray; -import java.lang.reflect.Type; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; import com.google.common.annotations.Beta; -import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.reflect.Invokable; import com.google.common.reflect.TypeToken; /** - * Invokable utilities + * Utilities that allow access to {@link Invokable}s with {@link Invokable#getOwnerType() owner types}. * * @since 1.6 */ @Beta public final class Reflection2 { - private static final LoadingCache, TypeToken> typeTokenForClass = CacheBuilder.newBuilder().build( - new CacheLoader, TypeToken>() { - public TypeToken load(final Class key) throws Exception { - return TypeToken.of(key); - } - }); /** - * Cache of type tokens for the supplied class. - */ - public static Function, TypeToken> typeTokenForClass() { - return typeTokenForClass; - } - - /** - * Cache of type tokens for the supplied class. + * gets a {@link TypeToken} for the given class. */ @SuppressWarnings("unchecked") - public static TypeToken typeTokenOf(Class in) { + public static TypeToken typeToken(Class in) { return (TypeToken) typeTokenForClass.apply(checkNotNull(in, "class")); } - private static final LoadingCache> typeTokenForType = CacheBuilder.newBuilder().build( - new CacheLoader>() { - public TypeToken load(final Type key) throws Exception { + /** + * returns an {@link Invokable} object that links the {@code method} to its owner. + * + * @param ownerType + * corresponds to {@link Invokable#getOwnerType()} + * @param method + * present in {@code ownerType} + */ + @SuppressWarnings("unchecked") + public static Invokable method(TypeToken ownerType, Method method) { + return (Invokable) methods.apply(new TypeTokenAndMethod(ownerType, method)); + } + + /** + * returns an {@link Invokable} object that reflects a method present in the {@link TypeToken} type. + * + * @param ownerType + * corresponds to {@link Invokable#getOwnerType()} + * @param parameterTypes + * corresponds to {@link Method#getParameterTypes()} + * + * @throws IllegalArgumentException + * if the method doesn't exist or a security exception occurred + */ + @SuppressWarnings("unchecked") + public static Invokable method(Class ownerType, String name, Class... parameterTypes) { + return (Invokable) methodForArgs.apply(new TypeTokenNameAndParameterTypes(typeToken(ownerType), name, + parameterTypes)); + } + + /** + * return all methods present in the class as {@link Invokable}s. + * + * @param ownerType + * corresponds to {@link Invokable#getOwnerType()} + */ + @SuppressWarnings("unchecked") + public static Collection> methods(Class ownerType) { + return Collection.class.cast(methodsForTypeToken.apply(typeToken(ownerType)).values()); + } + + private static final LoadingCache> methods = CacheBuilder.newBuilder().build( + new CacheLoader>() { + public Invokable load(TypeTokenAndMethod key) { + return key.type.method(key.method); + } + }); + + private static class TypeTokenAndMethod { + + protected final TypeToken type; + protected final Method method; + + public TypeTokenAndMethod(TypeToken type, Method method) { + this.type = checkNotNull(type, "type"); + this.method = checkNotNull(method, "method"); + } + + public int hashCode() { + return Objects.hashCode(type, method); + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + TypeTokenAndMethod that = TypeTokenAndMethod.class.cast(obj); + return Objects.equal(this.type, that.type) && Objects.equal(this.method, that.method); + } + } + + private static final LoadingCache, TypeToken> typeTokenForClass = CacheBuilder.newBuilder().build( + new CacheLoader, TypeToken>() { + public TypeToken load(final Class key) { return TypeToken.of(key); } }); - /** - * Cache of type tokens for the supplied class. - */ - public static Function> typeTokenForType() { - return typeTokenForType; + private static class TypeTokenAndParameterTypes { + + protected final TypeToken type; + protected final List> parameterTypes; + + public TypeTokenAndParameterTypes(TypeToken type, Class... parameterTypes) { + this.type = checkNotNull(type, "type"); + this.parameterTypes = Arrays.asList(checkNotNull(parameterTypes, "parameterTypes")); + } + + public int hashCode() { + return Objects.hashCode(type, parameterTypes); + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + TypeTokenAndParameterTypes that = TypeTokenAndParameterTypes.class.cast(obj); + return Objects.equal(this.type, that.type) && Objects.equal(this.parameterTypes, that.parameterTypes); + } + + public String toString() { + return Objects.toStringHelper("").add("type", type).add("parameterTypes", parameterTypes).toString(); + } } - /** - * Cache of type tokens for the supplied type. - */ - @SuppressWarnings("unchecked") - public static TypeToken typeTokenOf(Type in) { - return (TypeToken) typeTokenForType.apply(checkNotNull(in, "class")); + private static final LoadingCache> methodForArgs = CacheBuilder + .newBuilder().build(new CacheLoader>() { + public Invokable load(final TypeTokenNameAndParameterTypes key) { + try { + Method method = key.type.getRawType().getMethod(key.name, toArray(key.parameterTypes, Class.class)); + return methods.apply(new TypeTokenAndMethod(key.type, method)); + } catch (SecurityException e) { + throw new IllegalArgumentException(e.getMessage() + " getting method " + key.toString(), e); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException("no such method " + key.toString(), e); + } + } + }); + + private static class TypeTokenNameAndParameterTypes extends TypeTokenAndParameterTypes { + + private final String name; + + public TypeTokenNameAndParameterTypes(TypeToken type, String name, Class... parameterTypes) { + super(type, parameterTypes); + this.name = checkNotNull(name, "name"); + } + + public int hashCode() { + return Objects.hashCode(super.hashCode(), name); + } + + public boolean equals(Object obj) { + if (super.equals(obj)) { + TypeTokenNameAndParameterTypes that = TypeTokenNameAndParameterTypes.class.cast(obj); + return name.equals(that.name); + } + return false; + } + + public String toString() { + return Objects.toStringHelper("").add("type", type).add("name", name).add("parameterTypes", parameterTypes) + .toString(); + } } + private static final LoadingCache, Map>> methodsForTypeToken = CacheBuilder + .newBuilder().build(new CacheLoader, Map>>() { + public Map> load(final TypeToken key) { + Builder> builder = ImmutableMap.> builder(); + for (Method method : key.getRawType().getMethods()) + builder.put(method, method(key, method)); + return builder.build(); + } + }); + } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java b/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java index 58018d61c9..27fb53c93d 100644 --- a/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/CallGetOnFuturesProvider.java @@ -18,7 +18,6 @@ */ package org.jclouds.rest.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; import java.lang.reflect.Proxy; @@ -47,7 +46,7 @@ public class CallGetOnFuturesProvider implements Provider { Class asyncApiType) { this.syncInvoker = syncInvoker; this.apiType = apiType; - RestModule.putInvokables(typeTokenOf(apiType), typeTokenOf(asyncApiType), invokables); + RestModule.putInvokables(apiType, asyncApiType, invokables); } @SuppressWarnings("unchecked") diff --git a/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java b/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java index 6c55f065dd..820ebe1f39 100644 --- a/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java @@ -18,7 +18,6 @@ */ package org.jclouds.rest.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; import java.lang.reflect.Proxy; @@ -46,7 +45,7 @@ public class HttpApiProvider implements Provider { DelegatesToInvocationFunction httpInvoker, Class apiType, Class asyncApiType) { this.httpInvoker = httpInvoker; this.apiType = apiType; - RestModule.putInvokables(typeTokenOf(apiType), typeTokenOf(asyncApiType), invokables); + RestModule.putInvokables(apiType, asyncApiType, invokables); } @SuppressWarnings("unchecked") diff --git a/core/src/main/java/org/jclouds/rest/config/RestModule.java b/core/src/main/java/org/jclouds/rest/config/RestModule.java index f7c30a7fbc..315f152bde 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestModule.java @@ -19,18 +19,21 @@ package org.jclouds.rest.config; import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.propagate; +import static com.google.common.collect.Iterables.toArray; +import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Maps.transformValues; import static com.google.common.util.concurrent.Atomics.newReference; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; +import static org.jclouds.reflect.Reflection2.methods; import static org.jclouds.rest.config.BinderUtils.bindHttpApi; import static org.jclouds.util.Maps2.transformKeys; import static org.jclouds.util.Predicates2.startsWith; import java.lang.reflect.Method; import java.net.URI; -import java.util.Arrays; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; @@ -57,7 +60,7 @@ import com.google.common.cache.CacheBuilder; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.reflect.Invokable; -import com.google.common.reflect.TypeToken; +import com.google.common.reflect.Parameter; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -80,7 +83,7 @@ public class RestModule extends AbstractModule { public RestModule(Map, Class> sync2Async) { this.sync2Async = sync2Async; } - + /** * seeds well-known invokables. */ @@ -88,33 +91,42 @@ public class RestModule extends AbstractModule { @Singleton protected Cache, Invokable> seedKnownSync2AsyncInvokables() { Cache, Invokable> sync2AsyncBuilder = CacheBuilder.newBuilder().build(); - putInvokables(typeTokenOf(HttpClient.class), typeTokenOf(HttpAsyncClient.class), sync2AsyncBuilder); + putInvokables(HttpClient.class, HttpAsyncClient.class, sync2AsyncBuilder); for (Class s : sync2Async.keySet()) { - putInvokables(typeTokenOf(s), typeTokenOf(sync2Async.get(s)), sync2AsyncBuilder); + putInvokables(s, sync2Async.get(s), sync2AsyncBuilder); } return sync2AsyncBuilder; } // accessible for ClientProvider - public static void putInvokables(TypeToken sync, TypeToken async, Cache, Invokable> cache) { - for (Method invoked : sync.getRawType().getMethods()) { + public static void putInvokables(Class sync, Class async, Cache, Invokable> cache) { + for (Invokable invoked : methods(sync)) { if (!objectMethods.contains(invoked)) { try { - Method delegatedMethod = async.getRawType().getMethod(invoked.getName(), invoked.getParameterTypes()); - checkArgument(Arrays.equals(delegatedMethod.getExceptionTypes(), invoked.getExceptionTypes()), + Invokable delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked)); + checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes()), "invoked %s has different typed exceptions than delegated invoked %s", invoked, delegatedMethod); invoked.setAccessible(true); delegatedMethod.setAccessible(true); - cache.put(sync.method(invoked), async.method(delegatedMethod)); + cache.put(invoked, delegatedMethod); } catch (SecurityException e) { throw propagate(e); - } catch (NoSuchMethodException e) { - throw propagate(e); } } } } + /** + * for portability with {@link Class#getMethod(String, Class...)} + */ + private static Class[] getParameterTypes(Invokable in) { + return toArray(transform(checkNotNull(in, "invokable").getParameters(), new Function>() { + public Class apply(Parameter input) { + return input.getType().getRawType(); + } + }), Class.class); + } + protected void installLocations() { install(new LocationModule()); } diff --git a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java index f48d88f8ad..4c4c8990b0 100644 --- a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java +++ b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java @@ -19,7 +19,7 @@ package org.jclouds.rest.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Properties; @@ -72,7 +72,7 @@ public abstract class BaseRestApiMetadata extends BaseApiMetadata implements Res checkNotNull(asyncApi, "asyncApi"); javaApi(api, asyncApi) .name(String.format("%s->%s", api.getSimpleName(), asyncApi.getSimpleName())) - .context(contextToken(typeTokenOf(api), typeTokenOf(asyncApi))) + .context(contextToken(typeToken(api), typeToken(asyncApi))) .defaultProperties(BaseRestApiMetadata.defaultProperties()); } diff --git a/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java b/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java index 9ae84c1f5d..d1ff456cbf 100644 --- a/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java +++ b/core/src/main/java/org/jclouds/rest/internal/DelegatesToInvocationFunction.java @@ -23,7 +23,8 @@ import static com.google.common.base.Throwables.propagate; import static com.google.common.collect.Iterables.all; import static com.google.common.collect.Iterables.find; import static com.google.inject.util.Types.newParameterizedType; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Optionals2.isReturnTypeOptional; import static org.jclouds.util.Optionals2.unwrapIfOptional; import static org.jclouds.util.Throwables2.getFirstThrowableOfType; @@ -66,7 +67,6 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.ProvisionException; -import com.google.inject.TypeLiteral; import com.google.inject.util.Types; /** @@ -96,10 +96,11 @@ public final class DelegatesToInvocationFunction *
  • other method calls are dispatched to {@link #handleInvocation}. * - * @throws Throwable + * + * @throws Throwable */ @Override - public final Object invoke(Object proxy, Method invoked, @Nullable Object[] argv) throws Throwable { + public final Object invoke(Object proxy, Method invoked, @Nullable Object[] argv) throws Throwable { if (argv == null) { argv = NO_ARGS; } @@ -118,7 +119,7 @@ public final class DelegatesToInvocationFunction invokable = enclosingType.method(invoked); + Invokable invokable = method(ownerType, invoked); Invocation invocation = Invocation.create(invokable, args); try { return handle(invocation); @@ -135,20 +136,19 @@ public final class DelegatesToInvocationFunction enclosingType; + private final TypeToken ownerType; private final SetCaller setCaller; private final Map, Class> syncToAsync; private final Function> optionalConverter; private final F methodInvoker; - @SuppressWarnings("unchecked") @Inject DelegatesToInvocationFunction(Injector injector, SetCaller setCaller, Map, Class> syncToAsync, - TypeLiteral enclosingType, Function> optionalConverter, F methodInvoker) { + Class ownerType, Function> optionalConverter, F methodInvoker) { this.injector = checkNotNull(injector, "injector"); - this.enclosingType = (TypeToken) typeTokenOf(checkNotNull(enclosingType, "enclosingType").getType()); + this.ownerType = typeToken(checkNotNull(ownerType, "ownerType")); this.setCaller = checkNotNull(setCaller, "setCaller"); this.syncToAsync = checkNotNull(syncToAsync, "syncToAsync"); this.optionalConverter = checkNotNull(optionalConverter, "optionalConverter"); @@ -174,7 +174,7 @@ public final class DelegatesToInvocationFunction methodInvokerFor(Class returnType) { switch (methodInvoker.getClass().getTypeParameters().length) { @@ -256,8 +256,7 @@ public final class DelegatesToInvocationFunction extends BaseContextLiveTe @Override protected TypeToken contextType() { - return typeTokenOf(Context.class); + return typeToken(Context.class); } protected V createView(Properties props, Iterable modules) { diff --git a/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java b/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java index 612e68b4f5..fc83e258ef 100644 --- a/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java @@ -19,6 +19,7 @@ package org.jclouds.http.functions; import static com.google.common.base.Throwables.propagate; +import static org.jclouds.reflect.Reflection2.method; import java.util.List; @@ -29,7 +30,6 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; @@ -54,11 +54,9 @@ public class BaseHandlerTest { @BeforeTest protected void setUpRequest() { try { - toString = Invocation.create(Invokable.from(String.class.getDeclaredMethod("toString")), ImmutableList.of()); + toString = Invocation.create(method(String.class, "toString"), ImmutableList.of()); } catch (SecurityException e) { throw propagate(e); - } catch (NoSuchMethodException e) { - throw propagate(e); } request = GeneratedHttpRequest.builder().method("POST").endpoint("http://localhost/key").invocation(toString) .build(); diff --git a/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java b/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java index 8896a0f7be..909baa41de 100644 --- a/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java @@ -17,7 +17,7 @@ * under the License. */ package org.jclouds.http.handlers; - +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -125,7 +125,7 @@ public class BackoffLimitedRetryHandlerTest { .getInstance(RestAnnotationProcessor.class); private HttpCommand createCommand() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(IntegrationTestAsyncClient.class.getMethod("download", String.class)); + Invokable method = method(IntegrationTestAsyncClient.class, "download", String.class); return new HttpCommand(processor.createRequest(method, ImmutableList. of("1"))); } diff --git a/core/src/test/java/org/jclouds/internal/BaseViewTest.java b/core/src/test/java/org/jclouds/internal/BaseViewTest.java index c3de223bb6..9b947080a3 100644 --- a/core/src/test/java/org/jclouds/internal/BaseViewTest.java +++ b/core/src/test/java/org/jclouds/internal/BaseViewTest.java @@ -19,7 +19,7 @@ package org.jclouds.internal; import static org.easymock.EasyMock.createMock; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.fail; @@ -64,22 +64,22 @@ public class BaseViewTest { private static class Wine extends BaseView { protected Wine() { - super(new Water(), typeTokenOf(Water.class)); + super(new Water(), typeToken(Water.class)); } } public void testWaterTurnedIntoWine() { Wine wine = new Wine(); - assertEquals(wine.getBackendType(), typeTokenOf(Water.class)); - assertEquals(wine.unwrap(typeTokenOf(Water.class)).getClass(), Water.class); + assertEquals(wine.getBackendType(), typeToken(Water.class)); + assertEquals(wine.unwrap(typeToken(Water.class)).getClass(), Water.class); assertEquals(wine.unwrap().getClass(), Water.class); } public void testPeanutButterDidntTurnIntoWine() { Wine wine = new Wine(); - assertNotEquals(wine.getBackendType(), typeTokenOf(PeanutButter.class)); + assertNotEquals(wine.getBackendType(), typeToken(PeanutButter.class)); try { - wine.unwrap(typeTokenOf(PeanutButter.class)); + wine.unwrap(typeToken(PeanutButter.class)); fail(); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), "backend type: org.jclouds.internal.BaseViewTest$Water not assignable from org.jclouds.internal.BaseViewTest$PeanutButter"); diff --git a/core/src/test/java/org/jclouds/json/BaseParserTest.java b/core/src/test/java/org/jclouds/json/BaseParserTest.java index d3143826fd..ae6910ff87 100644 --- a/core/src/test/java/org/jclouds/json/BaseParserTest.java +++ b/core/src/test/java/org/jclouds/json/BaseParserTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.json; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.lang.annotation.ElementType; @@ -39,7 +40,6 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; @@ -62,8 +62,7 @@ public abstract class BaseParserTest { return (Function) i .createChildInjector(new SaxParserModule()) .getInstance(TransformerForRequest.class) - .getTransformerForMethod( - Invocation.create(Invokable.from(getClass().getMethod("expected")), ImmutableList.of()), i); + .getTransformerForMethod(Invocation.create(method(getClass(), "expected"), ImmutableList.of()), i); } catch (Exception e) { throw Throwables.propagate(e); } diff --git a/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java index a915b12e1e..bc66237438 100644 --- a/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java +++ b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java @@ -19,7 +19,7 @@ package org.jclouds.providers.internal; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.testng.Assert.assertEquals; import java.util.Set; @@ -63,7 +63,7 @@ public abstract class BaseProviderMetadataTest { public void testOfApiContains() { if (expectedApi == null) Logger.getAnonymousLogger().warning("please update your test class"); - ImmutableSet ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(typeTokenOf(expectedApi.getClass()))); + ImmutableSet ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(typeToken(expectedApi.getClass()))); assert ofApi.contains(toTest) : String.format("%s not found in %s", toTest, ofApi); } diff --git a/core/src/test/java/org/jclouds/reflect/Reflection2Test.java b/core/src/test/java/org/jclouds/reflect/Reflection2Test.java new file mode 100644 index 0000000000..4255b5225a --- /dev/null +++ b/core/src/test/java/org/jclouds/reflect/Reflection2Test.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.reflect; + +import static com.google.common.base.Functions.toStringFunction; +import static org.jclouds.reflect.Reflection2.method; +import static org.jclouds.reflect.Reflection2.methods; +import static org.jclouds.reflect.Reflection2.typeToken; +import static org.testng.Assert.assertEquals; + +import java.util.Set; + +import org.testng.annotations.Test; + +import com.google.common.base.Function; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.Invokable; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + */ +@Test +public class Reflection2Test { + + public void testTypeToken() { + assertEquals(typeToken(String.class), TypeToken.of(String.class)); + } + + public void testMethodFromJavaMethod() throws SecurityException, NoSuchMethodException { + assertEquals(method(typeToken(String.class), String.class.getMethod("toString")), TypeToken.of(String.class) + .method(String.class.getMethod("toString")).returning(String.class)); + } + + public void testMethodFromClassAndNoParams() { + @SuppressWarnings("rawtypes") + Invokable methodInSuper = method(Set.class, "iterator"); + + assertEquals(methodInSuper.getOwnerType(), typeToken(Set.class)); + } + + public void testMethodFromClassAndParams() { + @SuppressWarnings("rawtypes") + Invokable methodInSuper = method(Set.class, "equals", Object.class); + + assertEquals(methodInSuper.getOwnerType(), typeToken(Set.class)); + assertEquals(methodInSuper.getParameters().get(0).getType().getRawType(), Object.class); + } + + public void testMethods() { + Set methodNames = FluentIterable.from(methods(Set.class)) + .transform(new Function, String>() { + public String apply(Invokable input) { + return input.getName(); + } + }).transform(toStringFunction()).toSet(); + + assertEquals(methodNames, ImmutableSet.of("add", "equals", "hashCode", "clear", "isEmpty", "contains", "addAll", + "size", "toArray", "iterator", "remove", "removeAll", "containsAll", "retainAll")); + } +} diff --git a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java index f7a1c5c492..0073bb9250 100644 --- a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java +++ b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.rest; +import static org.jclouds.reflect.Reflection2.method; + import javax.ws.rs.POST; import javax.ws.rs.PathParam; @@ -36,7 +38,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; import com.google.inject.Injector; - @Test(groups = "unit") public class InputParamValidatorTest { @@ -59,10 +60,10 @@ public class InputParamValidatorTest { */ @Test public void testInputParamsValidation() throws Exception { - Invokable allParamsValidatedMethod = Invokable.from(InputParamValidatorForm.class.getMethod( - "allParamsValidated", String.class, String.class)); - Invokable oneParamValidatedMethod = Invokable.from(InputParamValidatorForm.class.getMethod( - "oneParamValidated", String.class, String.class)); + Invokable allParamsValidatedMethod = method(InputParamValidatorForm.class, "allParamsValidated", + String.class, String.class); + Invokable oneParamValidatedMethod = method(InputParamValidatorForm.class, "oneParamValidated", + String.class, String.class); restAnnotationProcessor.createRequest(allParamsValidatedMethod, ImmutableList. of("blah", "blah")); restAnnotationProcessor.createRequest(oneParamValidatedMethod, ImmutableList. of("blah", "blah")); @@ -98,7 +99,7 @@ public class InputParamValidatorTest { @Test(expectedExceptions = ClassCastException.class) public void testWrongPredicateTypeLiteral() throws Exception { - Invocation invocation = Invocation.create(Invokable.from(WrongValidator.class.getMethod("method", Integer.class)), + Invocation invocation = Invocation.create(method(WrongValidator.class, "method", Integer.class), ImmutableList. of(55)); new InputParamValidator(injector).validateMethodParametersOrThrow(invocation); } diff --git a/core/src/test/java/org/jclouds/rest/annotationparsing/ProvidesAnnotationExpectTest.java b/core/src/test/java/org/jclouds/rest/annotationparsing/ProvidesAnnotationExpectTest.java new file mode 100644 index 0000000000..88aab9d98b --- /dev/null +++ b/core/src/test/java/org/jclouds/rest/annotationparsing/ProvidesAnnotationExpectTest.java @@ -0,0 +1,148 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.rest.annotationparsing; + +import static org.jclouds.providers.AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint; +import static org.testng.Assert.assertEquals; + +import java.util.NoSuchElementException; +import java.util.Set; + +import javax.inject.Named; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.config.RestClientModule; +import org.jclouds.rest.internal.BaseRestClientExpectTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; + +/** + * Tests that we can add {@link Provides} methods on interfaces + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ProvidesAnnotationExpectTest") +public class ProvidesAnnotationExpectTest extends BaseRestClientExpectTest { + + static interface ProvidingApi { + @Provides + Set set(); + + @Named("bar") + @Provides + Set foo(); + + @Named("exception") + @Provides + Set exception(); + + @Named("NoSuchElementException") + @Provides + Set noSuchElementException(); + } + + static interface ProvidingAsyncApi { + @Provides + Set set(); + + @Named("bar") + @Provides + Set foo(); + + @Named("exception") + @Provides + Set exception(); + + @Named("NoSuchElementException") + @Provides + Set noSuchElementException(); + } + + @Test + public void testProvidesWithGeneric(){ + ProvidingApi client = requestsSendResponses(ImmutableMap. of()); + assertEquals(client.set(), ImmutableSet.of("foo")); + } + + @Test + public void testProvidesWithGenericQualified(){ + ProvidingApi client = requestsSendResponses(ImmutableMap. of()); + assertEquals(client.foo(), ImmutableSet.of("bar")); + } + + @Test(expectedExceptions = AuthorizationException.class) + public void testProvidesWithGenericQualifiedAuthorizationException(){ + ProvidingApi client = requestsSendResponses(ImmutableMap. of()); + client.exception(); + } + + @Test(expectedExceptions = NoSuchElementException.class) + public void testProvidesWithGenericQualifiedNoSuchElementException(){ + ProvidingApi client = requestsSendResponses(ImmutableMap. of()); + client.noSuchElementException(); + } + + // crufty junk until we inspect delegating api classes for all their client + // mappings and make a test helper for random classes. + + @Override + public ProviderMetadata createProviderMetadata() { + return forClientMappedToAsyncClientOnEndpoint(ProvidingApi.class, ProvidingAsyncApi.class, "http://mock"); + } + + @Override + protected Module createModule() { + return new ProvidingRestClientModule(); + } + + @ConfiguresRestClient + static class ProvidingRestClientModule extends RestClientModule { + + @Override + protected void configure() { + super.configure(); + bind(new TypeLiteral>() { + }).toInstance(ImmutableSet.of("foo")); + bind(new TypeLiteral>() { + }).annotatedWith(Names.named("bar")).toInstance(ImmutableSet.of("bar")); + } + + @Provides + @Named("exception") + Set exception() { + throw new AuthorizationException(); + } + + @Provides + @Named("NoSuchElementException") + Set noSuchElementException() { + throw new NoSuchElementException(); + } + } +} diff --git a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java index a99a8a3af3..583082d6a6 100644 --- a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java +++ b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.rest.binders; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.File; @@ -33,10 +34,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; - import com.google.common.reflect.Invokable; - /** * Tests behavior of {@code BindMapToStringPayload} * @@ -56,7 +54,7 @@ public class BindMapToStringPayloadTest { @Test public void testCorrect() throws SecurityException, NoSuchMethodException { - Invokable testPayload = Invokable.from(TestPayload.class.getMethod("testPayload", String.class)); + Invokable testPayload = method(TestPayload.class, "testPayload", String.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(testPayload, ImmutableList. of("robot"))) .method("POST").endpoint("http://localhost").build(); @@ -70,7 +68,7 @@ public class BindMapToStringPayloadTest { @Test public void testDecodes() throws SecurityException, NoSuchMethodException { - Invokable testPayload = Invokable.from(TestPayload.class.getMethod("changeAdminPass", String.class)); + Invokable testPayload = method(TestPayload.class, "changeAdminPass", String.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(testPayload, ImmutableList. of("foo"))) .method("POST").endpoint("http://localhost").build(); @@ -84,7 +82,7 @@ public class BindMapToStringPayloadTest { @Test(expectedExceptions = IllegalArgumentException.class) public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException { - Invokable noPayload = Invokable.from(TestPayload.class.getMethod("noPayload", String.class)); + Invokable noPayload = method(TestPayload.class, "noPayload", String.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(noPayload, ImmutableList. of("robot"))) .method("POST").endpoint("http://localhost").build(); diff --git a/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java b/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java index 6acd1bc26e..8d7102aaf6 100644 --- a/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java +++ b/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java @@ -19,6 +19,7 @@ package org.jclouds.rest.functions; import static com.google.common.base.Throwables.propagate; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -35,7 +36,6 @@ import org.testng.annotations.Test; import com.google.common.base.Optional; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Allows you to use simple api version comparison to determine if a feature is @@ -165,9 +165,9 @@ public class PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest InvocationSuccess getApi(String name, Class target) { try { - return InvocationSuccess.create(Invocation.create( - Invokable.from(EC2AsyncApi.class.getDeclaredMethod("get" + name + "ApiForRegion", String.class)), - ImmutableList. of("region")), "present"); + return InvocationSuccess.create( + Invocation.create(method(EC2AsyncApi.class, "get" + name + "ApiForRegion", String.class), + ImmutableList. of("region")), "present"); } catch (Exception e) { throw propagate(e); } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java index 68448dd562..ec42464cdb 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java @@ -17,8 +17,7 @@ * under the License. */ package org.jclouds.rest.internal; - -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Set; @@ -46,7 +45,7 @@ public abstract class BaseRestApiMetadataTest extends BaseApiMetadataTest { @Test public void testContextAssignableFromRestContext() { - Set all = ImmutableSet.copyOf(Apis.contextAssignableFrom(typeTokenOf(RestContext.class))); + Set all = ImmutableSet.copyOf(Apis.contextAssignableFrom(typeToken(RestContext.class))); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } diff --git a/core/src/test/java/org/jclouds/rest/internal/BlockOnFutureTest.java b/core/src/test/java/org/jclouds/rest/internal/BlockOnFutureTest.java index ed4e669578..d9673c9a57 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BlockOnFutureTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BlockOnFutureTest.java @@ -22,7 +22,7 @@ import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.util.concurrent.ExecutionException; @@ -39,7 +39,6 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; import com.google.common.util.concurrent.ListenableFuture; /** @@ -62,16 +61,13 @@ public class BlockOnFutureTest { } } - private TypeToken enclosingType; private Invocation get; private Invocation namedGet; @BeforeClass void setupInvocations() throws SecurityException, NoSuchMethodException { - enclosingType = typeTokenOf(ThingAsyncApi.class); - get = Invocation.create(enclosingType.method(ThingAsyncApi.class.getDeclaredMethod("get")), ImmutableList.of()); - namedGet = Invocation.create(enclosingType.method(ThingAsyncApi.class.getDeclaredMethod("namedGet")), - ImmutableList.of()); + get = Invocation.create(method(ThingAsyncApi.class, "get"), ImmutableList.of()); + namedGet = Invocation.create(method(ThingAsyncApi.class, "namedGet"), ImmutableList.of()); } @SuppressWarnings("unchecked") diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 58510157fd..0040ea719e 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.io.Payloads.calculateMD5; import static org.jclouds.io.Payloads.newInputStreamPayload; import static org.jclouds.io.Payloads.newStringPayload; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.fail; @@ -42,7 +43,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Map; -import java.util.NoSuchElementException; import java.util.Set; import java.util.concurrent.ExecutionException; @@ -93,7 +93,6 @@ import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.reflect.Invocation; import org.jclouds.reflect.InvocationSuccess; -import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.InvocationContext; import org.jclouds.rest.annotations.BinderParam; @@ -120,7 +119,6 @@ import org.jclouds.rest.annotations.WrapWith; import org.jclouds.rest.binders.BindAsHostPrefix; import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.rest.binders.BindToStringPayload; -import org.jclouds.rest.config.AsyncHttpApiProvider; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.functions.ImplicitOptionalConverter; import org.jclouds.util.Strings2; @@ -148,12 +146,9 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.AbstractModule; import com.google.inject.ConfigurationException; import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; - /** * Tests behavior of {@code RestAnnotationProcessor} * @@ -497,7 +492,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQuery() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("foo")); + Invokable method = method(TestQuery.class, "foo"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); @@ -506,7 +501,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQuery2() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("foo2")); + Invokable method = method(TestQuery.class, "foo2"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); @@ -515,7 +510,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQuery3() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("foo3", String.class)); + Invokable method = method(TestQuery.class, "foo3", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("wonder")); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -526,12 +521,12 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "param\\{robbie\\} for invocation TestQuery.foo3") public void testNiceNPEQueryParam() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestQuery.class.getMethod("foo3", String.class)); + Invokable method = method(TestQuery.class, "foo3", String.class); processor.createRequest(method, Lists. newArrayList((String) null)); } public void testNoNPEOnQueryParamWithNullable() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("foo3Nullable", String.class)); + Invokable method = method(TestQuery.class, "foo3Nullable", String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -541,7 +536,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQueryParamIterableOneString() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); + Invokable method = method(TestQuery.class, "queryParamIterable", Iterable.class); Set bars = ImmutableSortedSet. of("1"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -551,7 +546,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQueryParamIterableString() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); + Invokable method = method(TestQuery.class, "queryParamIterable", Iterable.class); Set bars = ImmutableSortedSet. of("1", "2", "3"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -561,7 +556,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQueryParamIterableInteger() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); + Invokable method = method(TestQuery.class, "queryParamIterable", Iterable.class); Set bars = ImmutableSortedSet. of(1, 2, 3); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -571,7 +566,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQueryParamIterableEmpty() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); + Invokable method = method(TestQuery.class, "queryParamIterable", Iterable.class); Set bars = Collections.emptySet(); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -581,7 +576,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testQueryParamIterableNull() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); + Invokable method = method(TestQuery.class, "queryParamIterable", Iterable.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -610,7 +605,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testHttpRequestOptionsNoPayloadParam() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("post")); + Invokable method = method(TestPayloadParamVarargs.class, "post"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -635,7 +630,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testHttpRequestOptionsPayloadParam() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("post", Payload.class)); + Invokable method = method(TestPayloadParamVarargs.class, "post", Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(Payloads.newStringPayload("foo"))); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); @@ -644,8 +639,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testHttpRequestWithOnlyContentType() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable - .from(TestPayloadParamVarargs.class.getMethod("post", HttpRequestOptions.class)); + Invokable method = method(TestPayloadParamVarargs.class, "post", HttpRequestOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(new TestHttpRequestOptions().payload("fooya"))); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); @@ -654,8 +648,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testHeaderAndQueryVarargs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("varargs", - HttpRequestOptions[].class)); + Invokable method = method(TestPayloadParamVarargs.class, "varargs", + HttpRequestOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of(new TestHttpRequestOptions().payload("fooya"), @@ -667,8 +661,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testHeaderAndQueryVarargsPlusReq() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("varargsWithReq", String.class, - HttpRequestOptions[].class)); + Invokable method = method(TestPayloadParamVarargs.class, "varargsWithReq", String.class, + HttpRequestOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of("required param", new TestHttpRequestOptions().payload("fooya"), @@ -680,8 +674,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testDuplicateHeaderAndQueryVarargs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("varargs", - HttpRequestOptions[].class)); + Invokable method = method(TestPayloadParamVarargs.class, "varargs", + HttpRequestOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of(new TestHttpRequestOptions().queryParams(ImmutableMultimap.of("key", "value")), @@ -702,7 +696,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCustomMethod() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestCustomMethod.class.getMethod("foo")); + Invokable method = method(TestCustomMethod.class, "foo"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), ""); @@ -720,7 +714,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testOverriddenMethod() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestOverridden.class.getMethod("foo")); + Invokable method = method(TestOverridden.class, "foo"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), ""); @@ -740,7 +734,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testOverriddenEndpointMethod() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestOverriddenEndpoint.class.getMethod("foo")); + Invokable method = method(TestOverriddenEndpoint.class, "foo"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPort(), 1111); @@ -749,7 +743,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testOverriddenEndpointParameter() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestOverriddenEndpoint.class.getMethod("foo", URI.class)); + Invokable method = method(TestOverriddenEndpoint.class, "foo", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("http://wowsa:8001"))); assertEquals(request.getEndpoint().getHost(), "wowsa"); @@ -792,7 +786,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostRequest() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("post", String.class)); + Invokable method = method(TestPost.class, "post", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); @@ -801,7 +795,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostRequestNullOk1() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("post", String.class)); + Invokable method = method(TestPost.class, "post", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); @@ -810,7 +804,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostRequestNullOk2() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("post", String.class)); + Invokable method = method(TestPost.class, "post", String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -820,7 +814,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostRequestNullNotOk1() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("postNonnull", String.class)); + Invokable method = method(TestPost.class, "postNonnull", String.class); try { GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); Assert.fail("call should have failed with illegal null parameter, not permitted " + request + " to be created"); @@ -832,12 +826,12 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "postNonnull parameter 1") public void testCreatePostRequestNullNotOk2() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("postNonnull", String.class)); + Invokable method = method(TestPost.class, "postNonnull", String.class); processor.createRequest(method, Lists. newArrayList((String) null)); } public void testCreatePostJsonRequest() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("postAsJson", String.class)); + Invokable method = method(TestPost.class, "postAsJson", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); @@ -846,7 +840,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostWithPathRequest() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("postWithPath", String.class, MapBinder.class)); + Invokable method = method(TestPost.class, "postWithPath", String.class, MapBinder.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data", new org.jclouds.rest.MapBinder() { @Override @@ -865,7 +859,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostWithMethodBinder() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("postWithMethodBinder", String.class)); + Invokable method = method(TestPost.class, "postWithMethodBinder", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1"); @@ -874,8 +868,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostWithMethodBinderAndDefaults() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable - .from(TestPost.class.getMethod("postWithMethodBinderAndDefaults", String.class)); + Invokable method = method(TestPost.class, "postWithMethodBinderAndDefaults", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1"); @@ -884,7 +877,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePostWithPayload() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPost.class.getMethod("testPayload", String.class)); + Invokable method = method(TestPost.class, "testPayload", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1"); @@ -913,7 +906,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testMultipartWithStringPart() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withStringPart", String.class)); + Invokable method = method(TestMultipartForm.class, "withStringPart", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foobledata")); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); @@ -928,13 +921,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "fooble") public void testMultipartWithStringPartNullNotOkay() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withStringPart", String.class)); + Invokable method = method(TestMultipartForm.class, "withStringPart", String.class); processor.createRequest(method, Lists. newArrayList((String) null)); } public void testMultipartWithParamStringPart() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withParamStringPart", String.class, - String.class)); + Invokable method = method(TestMultipartForm.class, "withParamStringPart", String.class, + String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "foobledata")); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); @@ -953,14 +946,14 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "param\\{name\\} for invocation TestMultipartForm.withParamStringPart") public void testMultipartWithParamStringPartNullNotOk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withParamStringPart", String.class, - String.class)); + Invokable method = method(TestMultipartForm.class, "withParamStringPart", String.class, + String.class); processor.createRequest(method, Lists. newArrayList(null, "foobledata")); } public void testMultipartWithParamFilePart() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withParamFilePart", String.class, - File.class)); + Invokable method = method(TestMultipartForm.class, "withParamFilePart", String.class, + File.class); File file = File.createTempFile("foo", "bar"); Files.append("foobledata", file, UTF_8); file.deleteOnExit(); @@ -982,8 +975,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testMultipartWithParamByteArrayPart() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withParamByteArrayBinaryPart", - String.class, byte[].class)); + Invokable method = method(TestMultipartForm.class, "withParamByteArrayBinaryPart", + String.class, byte[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "goo".getBytes())); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); @@ -1002,8 +995,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { }; public void testMultipartWithParamFileBinaryPart() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestMultipartForm.class.getMethod("withParamFileBinaryPart", - String.class, File.class)); + Invokable method = method(TestMultipartForm.class, "withParamFileBinaryPart", + String.class, File.class); File file = File.createTempFile("foo", "bar"); Files.write(new byte[] { 17, 26, 39, 40, 50 }, file); file.deleteOnExit(); @@ -1137,7 +1130,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testAlternateHttpMethod() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("rowdy", String.class)); + Invokable method = method(TestPut.class, "rowdy", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "ROWDY http://localhost:9999/strings/data HTTP/1.1"); @@ -1146,7 +1139,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testAlternateHttpMethodSameArity() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("rowdy", int.class)); + Invokable method = method(TestPut.class, "rowdy", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "ROWDY http://localhost:9999/ints/data HTTP/1.1"); @@ -1155,7 +1148,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePutWithMethodBinder() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("putWithMethodBinder", String.class)); + Invokable method = method(TestPut.class, "putWithMethodBinder", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "PUT http://localhost:9999/data HTTP/1.1"); @@ -1164,7 +1157,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePutWithMethodProduces() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("putWithMethodBinderProduces", String.class)); + Invokable method = method(TestPut.class, "putWithMethodBinderProduces", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "PUT http://localhost:9999/data HTTP/1.1"); @@ -1174,7 +1167,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testCreatePutWithMethodConsumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("putWithMethodBinderConsumes", String.class)); + Invokable method = method(TestPut.class, "putWithMethodBinderConsumes", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "PUT http://localhost:9999/data HTTP/1.1"); @@ -1192,7 +1185,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testGeneric1() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testGeneric")); + Invokable method = method(TestPut.class, "testGeneric"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseJson.class); @@ -1206,7 +1199,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testGeneric2() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testGeneric2")); + Invokable method = method(TestPut.class, "testGeneric2"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseJson.class); @@ -1220,7 +1213,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testGeneric3() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testGeneric3")); + Invokable method = method(TestPut.class, "testGeneric3"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseJson.class); @@ -1234,7 +1227,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrap1() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap")); + Invokable method = method(TestPut.class, "testUnwrap"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); @@ -1247,7 +1240,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrapValueNamed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrapValueNamed")); + Invokable method = method(TestPut.class, "testUnwrapValueNamed"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseFirstJsonValueNamed.class); @@ -1259,14 +1252,14 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testWrapWith() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testWrapWith", String.class)); + Invokable method = method(TestPut.class, "testWrapWith", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bar")); assertPayloadEquals(request, "{\"foo\":\"bar\"}", "application/json", false); } @SuppressWarnings("unchecked") public void testUnwrap2() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap2")); + Invokable method = method(TestPut.class, "testUnwrap2"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); @@ -1279,7 +1272,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrap3() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap3")); + Invokable method = method(TestPut.class, "testUnwrap3"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); @@ -1292,7 +1285,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrap4() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap4")); + Invokable method = method(TestPut.class, "testUnwrap4"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); @@ -1305,7 +1298,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void selectLong() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("selectLong")); + Invokable method = method(TestPut.class, "selectLong"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseFirstJsonValueNamed.class); @@ -1318,7 +1311,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void selectLongAddOne() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPut.class.getMethod("selectLongAddOne")); + Invokable method = method(TestPut.class, "selectLongAddOne"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); Function parser = transformer.apply(request); @@ -1357,7 +1350,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testRequestFilter() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestRequestFilter.class.getMethod("get")); + Invokable method = method(TestRequestFilter.class, "get"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getFilters().size(), 2); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter1.class); @@ -1365,14 +1358,14 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testRequestFilterOverride() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestRequestFilter.class.getMethod("getOverride")); + Invokable method = method(TestRequestFilter.class, "getOverride"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getFilters().size(), 1); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter2.class); } public void testRequestFilterOverrideOnRequest() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestRequestFilter.class.getMethod("getOverride", HttpRequest.class)); + Invokable method = method(TestRequestFilter.class, "getOverride", HttpRequest.class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of(HttpRequest.builder().method("GET").endpoint("http://localhost") @@ -1391,7 +1384,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testSkipEncoding() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestEncoding.class.getMethod("twoPaths", String.class, String.class)); + Invokable method = method(TestEncoding.class, "twoPaths", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertEquals(request.getEndpoint().getPath(), "/1/localhost"); @@ -1401,7 +1394,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testEncodingPath() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestEncoding.class.getMethod("twoPaths", String.class, String.class)); + Invokable method = method(TestEncoding.class, "twoPaths", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("/", "localhost")); assertEquals(request.getEndpoint().getPath(), "///localhost"); @@ -1422,8 +1415,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(enabled = false) public void testConstantPathParam() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestConstantPathParam.class.getMethod("twoPaths", String.class, - String.class)); + Invokable method = method(TestConstantPathParam.class, "twoPaths", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertRequestLineEquals(request, "GET http://localhost:9999/v1/ralphie/1/localhost HTTP/1.1"); @@ -1470,13 +1463,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "param\\{path\\} for invocation TestPath.onePath") public void testNiceNPEPathParam() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPath.class.getMethod("onePath", String.class)); + Invokable method = method(TestPath.class, "onePath", String.class); processor.createRequest(method, Lists. newArrayList((String) null)); } @Test public void testPathParamExtractor() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPath.class.getMethod("onePathParamExtractor", String.class)); + Invokable method = method(TestPath.class, "onePathParamExtractor", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); assertRequestLineEquals(request, "GET http://localhost:9999/l HTTP/1.1"); @@ -1486,7 +1479,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testQueryParamExtractor() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPath.class.getMethod("oneQueryParamExtractor", String.class)); + Invokable method = method(TestPath.class, "oneQueryParamExtractor", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); assertRequestLineEquals(request, "GET http://localhost:9999/?one=l HTTP/1.1"); @@ -1496,7 +1489,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testFormParamExtractor() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPath.class.getMethod("oneFormParamExtractor", String.class)); + Invokable method = method(TestPath.class, "oneFormParamExtractor", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); assertRequestLineEquals(request, "POST http://localhost:9999/ HTTP/1.1"); @@ -1506,7 +1499,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "param\\{one\\} for invocation TestPath.oneFormParamExtractor") public void testNiceNPEFormParam() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPath.class.getMethod("oneFormParamExtractor", String.class)); + Invokable method = method(TestPath.class, "oneFormParamExtractor", String.class); processor.createRequest(method, Lists. newArrayList((String) null)); } @@ -1550,7 +1543,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoHeader() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestHeader.class.getMethod("twoHeader", String.class)); + Invokable method = method(TestHeader.class, "twoHeader", String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot")).getHeaders(); assertEquals(headers.size(), 2); @@ -1568,7 +1561,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildOneClassHeader() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestClassHeader.class.getMethod("oneHeader", String.class)); + Invokable method = method(TestClassHeader.class, "oneHeader", String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot")).getHeaders(); assertEquals(headers.size(), 1); @@ -1577,7 +1570,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildOneHeader() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestHeader.class.getMethod("oneHeader", String.class)); + Invokable method = method(TestHeader.class, "oneHeader", String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot")).getHeaders(); assertEquals(headers.size(), 1); @@ -1586,7 +1579,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoHeaders() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestHeader.class.getMethod("twoHeaders", String.class, String.class)); + Invokable method = method(TestHeader.class, "twoHeaders", String.class, String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot", "eggs")).getHeaders(); assertEquals(headers.size(), 1); @@ -1595,8 +1588,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoHeadersOutOfOrder() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestHeader.class.getMethod("twoHeadersOutOfOrder", String.class, - String.class)); + Invokable method = method(TestHeader.class, "twoHeadersOutOfOrder", String.class, + String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot", "eggs")).getHeaders(); assertEquals(headers.size(), 1); @@ -1611,8 +1604,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testQueryInOptions() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQueryReplace.class.getMethod("queryInOptions", String.class, - TestReplaceQueryOptions.class)); + Invokable method = method(TestQueryReplace.class, "queryInOptions", String.class, + TestReplaceQueryOptions.class); String query = processor .createRequest(method, ImmutableList. of("robot", new TestReplaceQueryOptions())).getEndpoint() .getQuery(); @@ -1653,7 +1646,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoQuery() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQueryReplace.class.getMethod("twoQuery", String.class)); + Invokable method = method(TestQueryReplace.class, "twoQuery", String.class); String query = processor.createRequest(method, ImmutableList. of("robot")) .getEndpoint().getQuery(); assertEquals(query, "slash=/robot&hyphen=-robot"); @@ -1669,7 +1662,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildOneClassQuery() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestClassQuery.class.getMethod("oneQuery", String.class)); + Invokable method = method(TestClassQuery.class, "oneQuery", String.class); String query = processor.createRequest(method, ImmutableList. of("robot")) .getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); @@ -1677,7 +1670,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildOneQuery() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQueryReplace.class.getMethod("oneQuery", String.class)); + Invokable method = method(TestQueryReplace.class, "oneQuery", String.class); String query = processor.createRequest(method, ImmutableList. of("robot")) .getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); @@ -1685,8 +1678,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoQuerys() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable - .from(TestQueryReplace.class.getMethod("twoQuerys", String.class, String.class)); + Invokable method = method(TestQueryReplace.class, "twoQuerys", String.class, String.class); String query = processor .createRequest(method, ImmutableList. of("robot", "eggs")).getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot/eggs"); @@ -1694,8 +1686,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoQuerysOutOfOrder() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestQueryReplace.class.getMethod("twoQuerysOutOfOrder", String.class, - String.class)); + Invokable method = method(TestQueryReplace.class, "twoQuerysOutOfOrder", String.class, + String.class); String query = processor .createRequest(method, ImmutableList. of("robot", "eggs")).getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/eggs/robot"); @@ -1731,7 +1723,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayloadEnclosing() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", PayloadEnclosing.class)); + Invokable method = method(TestTransformers.class, "put", PayloadEnclosing.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(new PayloadEnclosingImpl(newStringPayload("whoops")))); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); @@ -1740,7 +1732,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayloadEnclosingGenerateMD5() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", PayloadEnclosing.class)); + Invokable method = method(TestTransformers.class, "put", PayloadEnclosing.class); PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl(newStringPayload("whoops")); calculateMD5(payloadEnclosing); GeneratedHttpRequest request = processor.createRequest(method, @@ -1753,7 +1745,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testPutInputStreamPayloadEnclosingGenerateMD5() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", PayloadEnclosing.class)); + Invokable method = method(TestTransformers.class, "put", PayloadEnclosing.class); PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl( newInputStreamPayload(Strings2.toInputStream("whoops"))); @@ -1767,7 +1759,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayloadChunkedNoContentLength() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("putXfer", Payload.class)); + Invokable method = method(TestTransformers.class, "putXfer", Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(newStringPayload("whoops"))); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); @@ -1776,7 +1768,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayload() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(newStringPayload("whoops"))); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); @@ -1785,7 +1777,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayloadContentDisposition() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); Payload payload = newStringPayload("whoops"); payload.getContentMetadata().setContentDisposition("attachment; filename=photo.jpg"); GeneratedHttpRequest request = processor.createRequest(method, @@ -1796,7 +1788,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayloadContentEncoding() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); Payload payload = newStringPayload("whoops"); payload.getContentMetadata().setContentEncoding("gzip"); GeneratedHttpRequest request = processor.createRequest(method, @@ -1807,7 +1799,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testPutPayloadContentLanguage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); Payload payload = newStringPayload("whoops"); payload.getContentMetadata().setContentLanguage("en"); GeneratedHttpRequest request = processor.createRequest(method, @@ -1821,7 +1813,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { IOException { Payload payload = newStringPayload("whoops"); calculateMD5(payload); - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); @@ -1832,7 +1824,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testPutInputStreamPayload() throws SecurityException, NoSuchMethodException, IOException { Payload payload = newInputStreamPayload(Strings2.toInputStream("whoops")); payload.getContentMetadata().setContentLength((long) "whoops".length()); - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); @@ -1844,7 +1836,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { NoSuchMethodException { Payload payload = newStringPayload("whoops"); calculateMD5(payload); - Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); + Invokable method = method(TestTransformers.class, "put", Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); @@ -1853,7 +1845,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testInputStreamListenableFuture() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("futureInputStream")); + Invokable method = method(TestTransformers.class, "futureInputStream"); Class> transformer = unwrap(TestTransformers.class, method); assertEquals(transformer, ReturnInputStream.class); } @@ -1865,7 +1857,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testURIListenableFuture() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("futureUri")); + Invokable method = method(TestTransformers.class, "futureUri"); Class> transformer = unwrap(TestTransformers.class, method); assertEquals(transformer, ParseURIFromListOrLocationHeaderIf20x.class); } @@ -1884,7 +1876,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = RuntimeException.class) public void testNoTransformer() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("noTransformer")); + Invokable method = method(TestTransformers.class, "noTransformer"); unwrap(TestTransformers.class, method); } @@ -1893,7 +1885,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { .method("GET") .endpoint("http://localhost") .invocation( - Invocation.create(Invokable.from(TestTransformers.class.getMethod("oneTransformerWithContext")), + Invocation.create(method(TestTransformers.class, "oneTransformerWithContext"), ImmutableList.of())).build(); Function transformer = this.transformer.apply(request); assertEquals(transformer.getClass(), ReturnStringIf200Context.class); @@ -1901,7 +1893,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testOneTransformer() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestTransformers.class.getMethod("oneTransformer")); + Invokable method = method(TestTransformers.class, "oneTransformer"); Class> transformer = unwrap(TestTransformers.class, method); assertEquals(transformer, ReturnStringIf2xx.class); } @@ -1958,8 +1950,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetVarArgOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); - Invokable method = Invokable.from(TestRequest.class.getMethod("get", String.class, - HttpRequestOptions[].class)); + Invokable method = method(TestRequest.class, "get", String.class, + HttpRequestOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -1974,8 +1966,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); - Invokable method = Invokable.from(TestRequest.class - .getMethod("get", String.class, HttpRequestOptions.class)); + Invokable method = method(TestRequest.class, "get", String.class, HttpRequestOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -1996,8 +1987,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetOptionsThatProducesQuery() throws SecurityException, NoSuchMethodException, IOException { PrefixOptions options = new PrefixOptions().withPrefix("1"); - Invokable method = Invokable.from(TestRequest.class - .getMethod("get", String.class, HttpRequestOptions.class)); + Invokable method = method(TestRequest.class, "get", String.class, HttpRequestOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertRequestLineEquals(request, "GET http://localhost:9999/1?prefix=1 HTTP/1.1"); @@ -2006,7 +1996,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreateGetQuery() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestRequest.class.getMethod("getQuery", String.class)); + Invokable method = method(TestRequest.class, "getQuery", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); @@ -2016,7 +2006,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreateGetQueryNull() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestRequest.class.getMethod("getQueryNull", String.class)); + Invokable method = method(TestRequest.class, "getQueryNull", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); @@ -2026,7 +2016,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreateGetQueryEmpty() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestRequest.class.getMethod("getQueryEmpty", String.class)); + Invokable method = method(TestRequest.class, "getQueryEmpty", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); @@ -2044,8 +2034,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetOptionsThatProducesPayload() throws SecurityException, NoSuchMethodException, IOException { PayloadOptions options = new PayloadOptions(); - Invokable method = Invokable.from(TestRequest.class.getMethod("putOptions", String.class, - HttpRequestOptions.class)); + Invokable method = method(TestRequest.class, "putOptions", String.class, + HttpRequestOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); @@ -2062,7 +2052,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(dataProvider = "strings") public void testCreateGetRequest(String key) throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { - Invokable method = Invokable.from(TestRequest.class.getMethod("get", String.class, String.class)); + Invokable method = method(TestRequest.class, "get", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(key, "localhost")); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -2075,7 +2065,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePutRequest() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestRequest.class.getMethod("put", String.class, String.class)); + Invokable method = method(TestRequest.class, "put", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("111", "data")); @@ -2085,7 +2075,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { } public void testCreatePutHeader() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestRequest.class.getMethod("putHeader", String.class, String.class)); + Invokable method = method(TestRequest.class, "putHeader", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "data")); @@ -2105,7 +2095,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testVirtualHostMethod() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestVirtualHostMethod.class.getMethod("get", String.class, String.class)); + Invokable method = method(TestVirtualHostMethod.class, "get", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -2129,7 +2119,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testVirtualHost() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestVirtualHost.class.getMethod("get", String.class, String.class)); + Invokable method = method(TestVirtualHost.class, "get", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -2141,7 +2131,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testHostPrefix() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestVirtualHost.class.getMethod("getPrefix", String.class, String.class)); + Invokable method = method(TestVirtualHost.class, "getPrefix", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "holy")); assertEquals(request.getEndpoint().getHost(), "holy.localhost"); @@ -2152,7 +2142,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = IllegalArgumentException.class) public void testHostPrefixEmpty() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestVirtualHost.class.getMethod("getPrefix", String.class, String.class)); + Invokable method = method(TestVirtualHost.class, "getPrefix", String.class, String.class); processor.createRequest(method, ImmutableList. of("1", "")); } @@ -2172,7 +2162,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testOneHeader() throws SecurityException, NoSuchMethodException, ExecutionException { - Invokable method = Invokable.from(TestHeaders.class.getMethod("oneHeader", String.class)); + Invokable method = method(TestHeaders.class, "oneHeader", String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot")).getHeaders(); assertEquals(headers.size(), 1); @@ -2181,7 +2171,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testOneIntHeader() throws SecurityException, NoSuchMethodException, ExecutionException { - Invokable method = Invokable.from(TestHeaders.class.getMethod("oneIntHeader", int.class)); + Invokable method = method(TestHeaders.class, "oneIntHeader", int.class); Multimap headers = processor.createRequest(method, ImmutableList. of(1)).getHeaders(); assertEquals(headers.size(), 1); @@ -2190,8 +2180,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testTwoDifferentHeaders() throws SecurityException, NoSuchMethodException, ExecutionException { - Invokable method = Invokable.from(TestHeaders.class.getMethod("twoDifferentHeaders", String.class, - String.class)); + Invokable method = method(TestHeaders.class, "twoDifferentHeaders", String.class, + String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot", "egg")).getHeaders(); assertEquals(headers.size(), 2); @@ -2201,8 +2191,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testTwoSameHeaders() throws SecurityException, NoSuchMethodException, ExecutionException { - Invokable method = Invokable - .from(TestHeaders.class.getMethod("twoSameHeaders", String.class, String.class)); + Invokable method = method(TestHeaders.class, "twoSameHeaders", String.class, String.class); Multimap headers = processor.createRequest(method, ImmutableList. of("robot", "egg")).getHeaders(); assertEquals(headers.size(), 2); @@ -2244,7 +2233,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testOneEndpointParam() throws SecurityException, NoSuchMethodException, ExecutionException { - Invokable method = Invokable.from(TestEndpointParams.class.getMethod("oneEndpointParam", String.class)); + Invokable method = method(TestEndpointParams.class, "oneEndpointParam", String.class); URI uri = RestAnnotationProcessor.getEndpointInParametersOrNull( Invocation.create(method, ImmutableList. of("robot")), injector); assertEquals(uri, URI.create("robot")); @@ -2253,8 +2242,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = IllegalStateException.class) public void testTwoDifferentEndpointParams() throws SecurityException, NoSuchMethodException, ExecutionException { - Invokable method = Invokable.from(TestEndpointParams.class.getMethod("twoEndpointParams", String.class, - String.class)); + Invokable method = method(TestEndpointParams.class, "twoEndpointParams", String.class, + String.class); RestAnnotationProcessor.getEndpointInParametersOrNull( Invocation.create(method, ImmutableList. of("robot", "egg")), injector); } @@ -2275,7 +2264,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testPut() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayload.class.getMethod("put", String.class)); + Invokable method = method(TestPayload.class, "put", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("test")); @@ -2286,7 +2275,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void putWithPath() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TestPayload.class.getMethod("putWithPath", String.class, String.class)); + Invokable method = method(TestPayload.class, "putWithPath", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("rabble", "test")); @@ -2335,7 +2324,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoForm() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestFormReplace.class.getMethod("twoForm", String.class)); + Invokable method = method(TestFormReplace.class, "twoForm", String.class); Object form = processor.createRequest(method, ImmutableList. of("robot")) .getPayload().getRawContent(); assertEquals(form, "slash=/robot&hyphen=-robot"); @@ -2343,55 +2332,14 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @FormParams(keys = "x-amz-copy-source", values = "/{bucket}") public interface TestClassForm { - @Provides - Set set(); - - @Named("bar") - @Provides - Set foo(); - - @Named("exception") - @Provides - Set exception(); - - @Named("NoSuchElementException") - @Provides - Set noSuchElementException(); - @POST @Path("/") void oneForm(@PathParam("bucket") String path); } - static final Key> formKey = Key - .get(new TypeLiteral>() { - }); - - @Test - public void testProvidesWithGeneric() throws SecurityException, NoSuchMethodException { - Set set = injector.getInstance(formKey).get().set(); - assertEquals(set, ImmutableSet.of("foo")); - } - - @Test - public void testProvidesWithGenericQualified() throws SecurityException, NoSuchMethodException { - Set set = injector.getInstance(formKey).get().foo(); - assertEquals(set, ImmutableSet.of("bar")); - } - - @Test(expectedExceptions = AuthorizationException.class) - public void testProvidesWithGenericQualifiedAuthorizationException() throws SecurityException, NoSuchMethodException { - injector.getInstance(formKey).get().exception(); - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testProvidesWithGenericQualifiedNoSuchElementException() throws SecurityException, NoSuchMethodException { - injector.getInstance(formKey).get().noSuchElementException(); - } - @Test public void testBuildOneClassForm() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestClassForm.class.getMethod("oneForm", String.class)); + Invokable method = method(TestClassForm.class, "oneForm", String.class); Object form = processor.createRequest(method, ImmutableList. of("robot")) .getPayload().getRawContent(); assertEquals(form, "x-amz-copy-source=/robot"); @@ -2399,7 +2347,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildOneForm() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestFormReplace.class.getMethod("oneForm", String.class)); + Invokable method = method(TestFormReplace.class, "oneForm", String.class); Object form = processor.createRequest(method, ImmutableList. of("robot")) .getPayload().getRawContent(); assertEquals(form, "x-amz-copy-source=/robot"); @@ -2407,7 +2355,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoForms() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestFormReplace.class.getMethod("twoForms", String.class, String.class)); + Invokable method = method(TestFormReplace.class, "twoForms", String.class, String.class); Object form = processor.createRequest(method, ImmutableList. of("robot", "eggs")) .getPayload().getRawContent(); assertEquals(form, "x-amz-copy-source=/robot/eggs"); @@ -2415,8 +2363,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testBuildTwoFormsOutOfOrder() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(TestFormReplace.class.getMethod("twoFormsOutOfOrder", String.class, - String.class)); + Invokable method = method(TestFormReplace.class, "twoFormsOutOfOrder", String.class, + String.class); Object form = processor.createRequest(method, ImmutableList. of("robot", "eggs")) .getPayload().getRawContent(); assertEquals(form, "x-amz-copy-source=/eggs/robot"); @@ -2462,30 +2410,11 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(Callee.class, AsyncCallee.class, "http://localhost:9999")) .modules(ImmutableSet. of(new MockModule(), new NullLoggingModule(), new AbstractModule() { - - @Override protected void configure() { - bind(new TypeLiteral>() { - }).toInstance(ImmutableSet.of("foo")); - bind(new TypeLiteral>() { - }).annotatedWith(Names.named("bar")).toInstance(ImmutableSet.of("bar")); bind(new TypeLiteral>() { }).annotatedWith(Localhost2.class).toInstance( Suppliers.ofInstance(URI.create("http://localhost:1111"))); } - - @Provides - @Named("exception") - Set exception() { - throw new AuthorizationException(); - } - - @Provides - @Named("NoSuchElementException") - Set noSuchElementException() { - throw new NoSuchElementException(); - } - })).buildInjector(); parserFactory = injector.getInstance(ParseSax.Factory.class); processor = injector.getInstance(RestAnnotationProcessor.class); diff --git a/core/src/test/java/org/jclouds/util/Optionals2Test.java b/core/src/test/java/org/jclouds/util/Optionals2Test.java index 5f156176f4..8b8791a462 100644 --- a/core/src/test/java/org/jclouds/util/Optionals2Test.java +++ b/core/src/test/java/org/jclouds/util/Optionals2Test.java @@ -17,7 +17,7 @@ * under the License. */ package org.jclouds.util; - +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; @@ -40,25 +40,25 @@ public class Optionals2Test { } public void testReturnTypeOrTypeOfOptionalWhenOptional() throws SecurityException, NoSuchMethodException { - Invokable invoked = Invokable.from(Test.class.getMethod("getOptional")); + Invokable invoked = method(Test.class, "getOptional"); assertEquals(Optionals2.unwrapIfOptional(invoked.getReturnType()), String.class); } public void testReturnTypeOrTypeOfOptionalWhenNotOptional() throws SecurityException, NoSuchMethodException { - Invokable invoked = Invokable.from(Test.class.getMethod("getNotOptional")); + Invokable invoked = method(Test.class, "getNotOptional"); assertEquals(Optionals2.unwrapIfOptional(invoked.getReturnType()), String.class); } public void testIsReturnTypeOptionalWhenOptional() throws SecurityException, NoSuchMethodException { - Invokable invoked = Invokable.from(Test.class.getMethod("getOptional")); + Invokable invoked = method(Test.class, "getOptional"); assertTrue(Optionals2.isReturnTypeOptional(invoked)); } public void testIsReturnTypeOptionalWhenNotOptional() throws SecurityException, NoSuchMethodException { - Invokable invoked = Invokable.from(Test.class.getMethod("getNotOptional")); + Invokable invoked = method(Test.class, "getNotOptional"); assertFalse(Optionals2.isReturnTypeOptional(invoked)); } diff --git a/core/src/test/java/org/jclouds/util/Throwables2Test.java b/core/src/test/java/org/jclouds/util/Throwables2Test.java index 907d739865..15497a7982 100644 --- a/core/src/test/java/org/jclouds/util/Throwables2Test.java +++ b/core/src/test/java/org/jclouds/util/Throwables2Test.java @@ -20,7 +20,7 @@ package org.jclouds.util; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.createNiceMock; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Throwables2.getFirstThrowableOfType; import static org.jclouds.util.Throwables2.propagateIfPossible; import static org.testng.Assert.assertEquals; @@ -148,14 +148,14 @@ public class Throwables2Test { @Test(expectedExceptions = TestException.class) public void testPropagateExceptionThatsInList() throws Throwable { Exception e = new TestException(); - propagateIfPossible(e, ImmutableSet.> of(typeTokenOf(TestException.class))); + propagateIfPossible(e, ImmutableSet.> of(typeToken(TestException.class))); } @Test(expectedExceptions = TestException.class) public void testPropagateWrappedExceptionThatsInList() throws Throwable { Exception e = new TestException(); propagateIfPossible(new RuntimeException(e), - ImmutableSet.> of(typeTokenOf(TestException.class))); + ImmutableSet.> of(typeToken(TestException.class))); } public void testPropagateIfPossibleDoesnThrowExceptionNotInList() throws Throwable { From 37e587ee51413c1ed1446b949c436db0d51cccd5 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 19 Jan 2013 17:17:30 -0800 Subject: [PATCH 2/2] changes related to centralizing construction of invokables --- .../org/jclouds/atmos/AtmosApiMetadata.java | 5 +- .../blobstore/AtmosBlobRequestSigner.java | 8 +- .../jclouds/atmos/AtmosAsyncClientTest.java | 42 +-- .../config/CloudFilesRestClientModule.java | 4 +- .../cloudservers/CloudServersApiMetadata.java | 4 +- .../CloudServersAsyncClientTest.java | 122 ++++----- .../cloudsigma/CloudSigmaApiMetadata.java | 5 +- .../cloudsigma/CloudSigmaAsyncClientTest.java | 74 +++--- ...loneDriveOptionsToPlainTextStringTest.java | 7 +- .../cloudstack/CloudStackApiMetadata.java | 6 +- .../features/AccountAsyncClientTest.java | 9 +- .../features/AddressAsyncClientTest.java | 17 +- .../features/AsyncJobAsyncClientTest.java | 10 +- .../ConfigurationAsyncClientTest.java | 7 +- .../DomainAccountAsyncClientTest.java | 9 +- .../features/DomainLimitAsyncClientTest.java | 7 +- .../features/EventAsyncClientTest.java | 11 +- .../features/FirewallAsyncClientTest.java | 19 +- .../GlobalAccountAsyncClientTest.java | 15 +- .../features/GlobalAlertAsyncClientTest.java | 9 +- .../GlobalCapacityAsyncClientTest.java | 9 +- .../features/GlobalHostAsyncClientTest.java | 7 +- .../GlobalOfferingAsyncClientTest.java | 27 +- .../GlobalStoragePoolAsyncClientTest.java | 9 +- .../features/GlobalUsageAsyncClientTest.java | 21 +- .../features/GlobalUserAsyncClientTest.java | 13 +- .../features/GuestOSAsyncClientTest.java | 15 +- .../features/HypervisorAsyncClientTest.java | 9 +- .../features/ISOAsyncClientTest.java | 27 +- .../features/LimitAsyncClientTest.java | 7 +- .../features/LoadBalancerAsyncClientTest.java | 25 +- .../features/NATAsyncClientTest.java | 25 +- .../features/NetworkAsyncClientTest.java | 21 +- .../features/OfferingAsyncClientTest.java | 22 +- .../features/SSHKeyPairAsyncClientTest.java | 14 +- .../SecurityGroupAsyncClientTest.java | 35 +-- .../features/SnapshotAsyncClientTest.java | 27 +- .../features/TemplateAsyncClientTest.java | 41 +-- .../features/VMGroupAsyncClientTest.java | 19 +- .../VirtualMachineAsyncClientTest.java | 37 +-- .../features/VolumeAsyncClientTest.java | 23 +- .../features/ZoneAsyncClientTest.java | 11 +- .../BaseCloudStackClientLiveTest.java | 4 +- .../config/CloudWatchRestClientModule.java | 4 +- .../ec2/config/EC2RestClientModule.java | 4 +- .../ec2/services/AMIAsyncClientTest.java | 56 ++-- ...ilabilityZoneAndRegionAsyncClientTest.java | 20 +- .../ElasticBlockStoreAsyncClientTest.java | 58 ++-- .../ElasticIPAddressAsyncClientTest.java | 21 +- .../ec2/services/InstanceAsyncClientTest.java | 85 +++--- .../ec2/services/KeyPairAsyncClientTest.java | 11 +- .../SecurityGroupAsyncClientTest.java | 37 +-- .../ec2/services/WindowsAsyncClientTest.java | 17 +- .../elasticstack/ElasticStackApiMetadata.java | 4 +- .../ElasticStackAsyncClientTest.java | 50 ++-- .../v1/config/CinderRestClientModule.java | 4 +- .../v2_0/config/KeystoneRestClientModule.java | 4 +- ...EqualsAnyNamespaceInExtensionsSetTest.java | 12 +- .../ec2/config/NovaEC2RestClientModule.java | 4 +- .../openstack/nova/v2_0/NovaApiMetadata.java | 4 +- .../v2_0/config/NovaRestClientModule.java | 5 +- .../CloudLoadBalancersApiMetadata.java | 5 +- .../java/org/jclouds/s3/S3ApiMetadata.java | 4 +- .../s3/blobstore/S3BlobRequestSigner.java | 12 +- .../jclouds/s3/config/S3RestClientModule.java | 5 +- .../org/jclouds/s3/S3AsyncClientTest.java | 64 +++-- ...indAsHostPrefixIfConfiguredNoPathTest.java | 4 +- .../BindAsHostPrefixIfConfiguredTest.java | 4 +- ...rOperationAbortedWhenBucketExistsTest.java | 7 +- .../RequestAuthorizeSignatureTest.java | 15 +- .../sqs/config/SQSRestClientModule.java | 5 +- .../openstack/swift/SwiftApiMetadata.java | 4 +- .../swift/blobstore/SwiftBlobSigner.java | 17 +- .../config/SwiftKeystoneRestClientModule.java | 4 +- .../swift/config/SwiftRestClientModule.java | 6 +- .../swift/internal/BasePayloadTest.java | 7 +- .../org/jclouds/vcloud/VCloudApiMetadata.java | 5 +- .../vcloud/VCloudVersionsAsyncClientTest.java | 6 +- .../features/CatalogAsyncClientTest.java | 19 +- .../features/NetworkAsyncClientTest.java | 11 +- .../vcloud/features/OrgAsyncClientTest.java | 11 +- .../vcloud/features/TaskAsyncClientTest.java | 13 +- .../vcloud/features/VAppAsyncClientTest.java | 41 +-- .../features/VAppTemplateAsyncClientTest.java | 40 +-- .../vcloud/features/VDCAsyncClientTest.java | 15 +- .../vcloud/features/VmAsyncClientTest.java | 37 +-- .../vcloud/internal/BasePayloadTest.java | 7 +- .../internal/VCloudLoginAsyncClientTest.java | 6 +- .../blobstore/util/BlobStoreUtils.java | 1 - .../BaseBlobStoreIntegrationTest.java | 4 +- .../BaseBlobStoreApiMetadataTest.java | 4 +- .../blobstore/util/BlobStoreUtilsTest.java | 7 +- .../SharedKeyLiteAuthenticationTest.java | 9 +- .../OpenStackAuthAsyncClientTest.java | 9 +- .../vcloud_0_8/internal/BasePayloadTest.java | 7 +- .../TerremarkVCloudLoginAsyncClientTest.java | 5 +- ...erremarkVCloudVersionsAsyncClientTest.java | 6 +- .../BaseComputeServiceApiMetadataTest.java | 4 +- .../BaseComputeServiceContextLiveTest.java | 4 +- .../org/jclouds/abiquo/AbiquoApiMetadata.java | 4 +- .../abiquo/binders/BindToPathTest.java | 14 +- .../cloud/BindMoveVolumeToPathTest.java | 6 +- ...dNetworkConfigurationRefToPayloadTest.java | 18 +- .../BindSupportedDevicesLinkToPathTest.java | 10 +- .../abiquo/features/AdminAsyncApiTest.java | 18 +- .../abiquo/features/CloudAsyncApiTest.java | 178 ++++++------- .../abiquo/features/ConfigAsyncApiTest.java | 30 +-- .../features/EnterpriseAsyncApiTest.java | 84 +++--- .../abiquo/features/EventAsyncApiTest.java | 5 +- .../features/InfrastructureAsyncApiTest.java | 249 +++++++++--------- .../abiquo/features/PricingAsyncApiTest.java | 54 ++-- .../abiquo/features/TaskAsyncApiTest.java | 11 +- .../VirtualMachineTemplateAsyncApiTest.java | 41 ++- .../abiquo/internal/AsyncMonitorTest.java | 1 - .../internal/BaseAbiquoLiveApiTest.java | 4 +- .../internal/AbiquoHttpAsyncClientTest.java | 5 +- .../AzureManagementApiMetadata.java | 5 +- .../elb/config/ELBRestClientModule.java | 4 +- .../jclouds/fujitsu/fgcp/FGCPApiMetadata.java | 4 +- .../iam/config/IAMRestClientModule.java | 4 +- .../cloudapi/v6_5/JoyentCloudApiMetadata.java | 5 +- .../cloudapi/v6_5/reference/Metadata.java | 5 +- .../v2/config/OAuthRestClientModule.java | 6 +- .../v1_0/config/GlanceRestClientModule.java | 5 +- .../v1_0/config/QuantumRestClientModule.java | 4 +- .../v1/config/SwiftRestClientModule.java | 5 +- .../rds/config/RDSRestClientModule.java | 5 +- .../jclouds/savvis/vpdc/VPDCApiMetadata.java | 4 +- .../vpdc/features/BrowsingAsyncApiTest.java | 33 +-- .../vpdc/features/FirewallAsyncApiTest.java | 13 +- .../ServiceManagementAsyncApiTest.java | 17 +- .../savvis/vpdc/features/VMAsyncApiTest.java | 26 +- .../v1_5/VCloudDirectorApiMetadata.java | 6 +- .../BaseLoadBalancerServiceLiveTest.java | 4 +- ...aseLoadBalancerServiceApiMetadataTest.java | 5 +- .../ec2/config/AWSEC2RestClientModule.java | 5 +- .../ec2/services/AWSAMIAsyncClientTest.java | 66 ++--- .../services/AWSInstanceAsyncClientTest.java | 90 +++---- .../services/AWSKeyPairAsyncClientTest.java | 21 +- .../AWSSecurityGroupAsyncClientTest.java | 37 +-- .../services/MonitoringAsyncClientTest.java | 13 +- .../PlacementGroupAsyncClientTest.java | 25 +- .../services/SpotInstanceAsyncClientTest.java | 33 +-- .../org/jclouds/aws/s3/AWSS3ApiMetadata.java | 4 +- .../aws/s3/config/AWSS3RestClientModule.java | 4 +- .../jclouds/aws/s3/AWSS3AsyncClientTest.java | 40 +-- .../azureblob/AzureBlobApiMetadata.java | 4 +- .../blobstore/AzureBlobRequestSigner.java | 10 +- .../azureblob/AzureBlobAsyncClientTest.java | 38 +-- .../org/jclouds/glesys/GleSYSApiMetadata.java | 4 +- .../org/jclouds/gogrid/GoGridApiMetadata.java | 4 +- .../services/GridImageAsyncClientTest.java | 23 +- .../services/GridIpAsyncClientTest.java | 9 +- .../services/GridJobAsyncClientTest.java | 12 +- .../GridLoadBalancerAsyncClientTest.java | 19 +- .../services/GridServerAsyncClientTest.java | 27 +- ...HPCloudObjectStorageBlobRequestSigner.java | 12 +- .../HPCloudObjectStorageRestClientModule.java | 5 +- .../softlayer/SoftLayerApiMetadata.java | 4 +- .../features/AccountAsyncClientTest.java | 7 +- .../features/DatacenterAsyncClientTest.java | 9 +- .../ProductPackageAsyncClientTest.java | 7 +- .../features/VirtualGuestAsyncClientTest.java | 19 +- .../TerremarkECloudAsyncClientTest.java | 76 +++--- .../DataCenterOperationsAsyncClientTest.java | 9 +- .../TagOperationsAsyncClientTest.java | 9 +- ...TerremarkVCloudExpressAsyncClientTest.java | 82 +++--- 167 files changed, 1653 insertions(+), 1638 deletions(-) diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java index a76b5ceae1..f592574445 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java @@ -17,12 +17,11 @@ * under the License. */ package org.jclouds.atmos; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -88,7 +87,7 @@ public class AtmosApiMetadata extends BaseRestApiMetadata { .version("1.4.0") .defaultEndpoint("https://accesspoint.atmosonline.com") .defaultProperties(AtmosApiMetadata.defaultProperties()) - .view(typeTokenOf(BlobStoreContext.class)) + .view(typeToken(BlobStoreContext.class)) .defaultModules(ImmutableSet.>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class)); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java index 057957d8e6..5f55f6b015 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java @@ -20,6 +20,7 @@ package org.jclouds.atmos.blobstore; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; +import static org.jclouds.reflect.Reflection2.method; import javax.inject.Inject; import javax.inject.Singleton; @@ -59,10 +60,9 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner { this.processor = checkNotNull(processor, "processor"); this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); - this.getMethod = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class)); - this.deleteMethod = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class)); - this.createMethod = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, - AtmosObject.class, PutOptions[].class)); + this.getMethod = method(AtmosAsyncClient.class, "readFile", String.class, GetOptions[].class); + this.deleteMethod = method(AtmosAsyncClient.class, "deletePath", String.class); + this.createMethod = method(AtmosAsyncClient.class, "createFile", String.class, AtmosObject.class, PutOptions[].class); } @Override diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index 3da991ce15..e82844aeec 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.atmos; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -47,7 +48,6 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.options.GetOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; @@ -56,8 +56,8 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; import com.google.inject.Module; - /** * Tests behavior of {@code AtmosAsyncClient} * @@ -70,7 +70,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest private BlobToObject blobToObject; public void testListDirectories() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "listDirectories", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1"); @@ -85,7 +85,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testListDirectory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "listDirectory", String.class, ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("directory")); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1"); @@ -100,7 +100,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testListDirectoriesOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "listDirectories", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(new ListOptions().limit(1).token("asda"))); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1"); @@ -115,7 +115,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testListDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "listDirectory", String.class, ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("directory", new ListOptions().limit(1).token("asda"))); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1"); @@ -130,7 +130,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testCreateDirectory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "createDirectory", String.class, PutOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir")); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1"); @@ -145,7 +145,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testCreateDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "createDirectory", String.class, PutOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", PutOptions.Builder.publicRead())); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1"); @@ -161,8 +161,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testCreateFile() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, - PutOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "createFile", String.class, AtmosObject.class, + PutOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB))); @@ -178,8 +178,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testCreateFileOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, - PutOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "createFile", String.class, AtmosObject.class, + PutOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead())); @@ -196,8 +196,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testUpdateFile() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class, - PutOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "updateFile", String.class, AtmosObject.class, + PutOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB))); @@ -213,8 +213,8 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testUpdateFileOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class, - PutOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "updateFile", String.class, AtmosObject.class, + PutOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead())); @@ -231,7 +231,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testReadFile() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class)); + Invokable method = method(AtmosAsyncClient.class, "readFile", String.class, GetOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); @@ -246,7 +246,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testGetSystemMetadata() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("getSystemMetadata", String.class)); + Invokable method = method(AtmosAsyncClient.class, "getSystemMetadata", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); @@ -261,7 +261,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testDeletePath() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class)); + Invokable method = method(AtmosAsyncClient.class, "deletePath", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "DELETE https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); @@ -276,7 +276,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testIsPublic() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("isPublic", String.class)); + Invokable method = method(AtmosAsyncClient.class, "isPublic", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); @@ -291,7 +291,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest } public void testNewObject() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("newObject")); + Invokable method = method(AtmosAsyncClient.class, "newObject"); assertEquals(method.getReturnType().getRawType(), AtmosObject.class); } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java index f7be4a1ae6..4c46d45ce2 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.cloudfiles.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Map; @@ -50,7 +50,7 @@ import com.google.inject.Scopes; @ConfiguresRestClient public class CloudFilesRestClientModule extends SwiftRestClientModule { public CloudFilesRestClientModule() { - super(typeTokenOf(CloudFilesClient.class), typeTokenOf(CloudFilesAsyncClient.class), ImmutableMap + super(typeToken(CloudFilesClient.class), typeToken(CloudFilesAsyncClient.class), ImmutableMap ., Class> of()); } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java index 05629065e0..46ed0e498f 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -21,7 +21,7 @@ package org.jclouds.cloudservers; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -80,7 +80,7 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata { .version("1.0") .defaultEndpoint("https://auth.api.rackspacecloud.com") .defaultProperties(CloudServersApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class)); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index 427b49929a..2798741f29 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -27,6 +27,7 @@ import static org.jclouds.cloudservers.options.ListOptions.Builder.changesSince; import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails; import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage; import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -62,7 +63,6 @@ import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth; import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest; -import com.google.common.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; @@ -70,9 +70,9 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.Invokable; import com.google.inject.Module; import com.google.inject.Provides; - /** * Tests behavior of {@code CloudServersAsyncClient} * @@ -84,8 +84,8 @@ import com.google.inject.Provides; public class CloudServersAsyncClientTest extends BaseAsyncClientTest { public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - CreateServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -102,8 +102,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - CreateServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -120,8 +120,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - CreateServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + CreateServerOptions[].class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of("ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes()))); @@ -141,8 +141,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - CreateServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withMetadata(ImmutableMap.of("foo", "bar")))); @@ -162,8 +162,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, - CreateServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2).withSharedIp("127.0.0.1"))); @@ -182,7 +182,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteImage", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "deleteImage", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2 HTTP/1.1"); @@ -197,7 +197,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getLimits")); + Invokable method = method(CloudServersAsyncClient.class, "getLimits"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/limits?format=json HTTP/1.1"); @@ -212,7 +212,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -229,7 +229,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -245,7 +245,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/detail?format=json HTTP/1.1"); @@ -260,7 +260,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getServer", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "getServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2?format=json HTTP/1.1"); @@ -275,7 +275,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json HTTP/1.1"); @@ -290,7 +290,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -306,7 +306,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json HTTP/1.1"); @@ -321,7 +321,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -337,7 +337,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getFlavor", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "getFlavor", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/2?format=json HTTP/1.1"); @@ -352,7 +352,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1"); @@ -367,7 +367,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json HTTP/1.1"); @@ -382,7 +382,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -398,7 +398,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -414,7 +414,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getImage", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "getImage", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json HTTP/1.1"); @@ -429,7 +429,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteServer", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "deleteServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); @@ -444,8 +444,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, - boolean.class)); + Invokable method = method(CloudServersAsyncClient.class, "shareIp", String.class, int.class, int.class, + boolean.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); @@ -462,8 +462,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, - boolean.class)); + Invokable method = method(CloudServersAsyncClient.class, "shareIp", String.class, int.class, int.class, + boolean.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, true)); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); @@ -481,7 +481,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("unshareIp", String.class, int.class)); + Invokable method = method(CloudServersAsyncClient.class, "unshareIp", String.class, int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); @@ -497,7 +497,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class)); + Invokable method = method(CloudServersAsyncClient.class, "replaceBackupSchedule", int.class, BackupSchedule.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY) .daily(DailyBackup.H_0800_1000).enabled(true).build())); @@ -516,7 +516,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteBackupSchedule", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "deleteBackupSchedule", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1"); @@ -532,7 +532,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class, String.class)); + Invokable method = method(CloudServersAsyncClient.class, "changeAdminPass", int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); @@ -548,7 +548,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("renameServer", int.class, String.class)); + Invokable method = method(CloudServersAsyncClient.class, "renameServer", int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); @@ -564,7 +564,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); @@ -579,7 +579,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -595,7 +595,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json HTTP/1.1"); @@ -610,7 +610,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -626,7 +626,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getSharedIpGroup", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "getSharedIpGroup", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2?format=json HTTP/1.1"); @@ -641,8 +641,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class, - CreateSharedIpGroupOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createSharedIpGroup", String.class, + CreateSharedIpGroupOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie")); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); @@ -658,8 +658,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class, - CreateSharedIpGroupOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "createSharedIpGroup", String.class, + CreateSharedIpGroupOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", withServer(2))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); @@ -675,7 +675,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteSharedIpGroup", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "deleteSharedIpGroup", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2 HTTP/1.1"); @@ -690,7 +690,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getAddresses", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "getAddresses", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips?format=json HTTP/1.1"); @@ -705,7 +705,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPublicAddresses", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "listPublicAddresses", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public?format=json HTTP/1.1"); @@ -720,7 +720,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPrivateAddresses", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "listPrivateAddresses", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/private?format=json HTTP/1.1"); @@ -735,7 +735,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getBackupSchedule", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "getBackupSchedule", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule?format=json HTTP/1.1"); @@ -750,7 +750,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, int.class)); + Invokable method = method(CloudServersAsyncClient.class, "createImageFromServer", String.class, int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1"); @@ -767,8 +767,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class, - RebuildServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "rebuildServer", int.class, + RebuildServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1"); @@ -783,8 +783,8 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class, - RebuildServerOptions[].class)); + Invokable method = method(CloudServersAsyncClient.class, "rebuildServer", int.class, + RebuildServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(3, withImage(2))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1"); @@ -799,7 +799,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class)); + Invokable method = method(CloudServersAsyncClient.class, "rebootServer", int.class, RebootType.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, RebootType.HARD)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -814,7 +814,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("resizeServer", int.class, int.class)); + Invokable method = method(CloudServersAsyncClient.class, "resizeServer", int.class, int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, 3)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -830,7 +830,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("confirmResizeServer", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "confirmResizeServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -845,7 +845,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("revertResizeServer", int.class)); + Invokable method = method(CloudServersAsyncClient.class, "revertResizeServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java index 2f5783241d..ad485113ba 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java @@ -17,12 +17,11 @@ * under the License. */ package org.jclouds.cloudsigma; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD; import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -87,7 +86,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata { .version("1.0") .defaultEndpoint("https://api.cloudsigma.com") .defaultProperties(CloudSigmaApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class)); } diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index 42b53c944e..2836ada74c 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudsigma; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -46,14 +47,13 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code CloudSigmaAsyncClient} * @@ -64,7 +64,7 @@ import com.google.common.collect.Iterables; public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest { public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getProfileInfo")); + Invokable method = method(CloudSigmaAsyncClient.class, "getProfileInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1"); @@ -80,7 +80,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardDrives")); + Invokable method = method(CloudSigmaAsyncClient.class, "listStandardDrives"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1"); @@ -95,7 +95,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardCds")); + Invokable method = method(CloudSigmaAsyncClient.class, "listStandardCds"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1"); @@ -110,7 +110,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardImages")); + Invokable method = method(CloudSigmaAsyncClient.class, "listStandardImages"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1"); @@ -125,7 +125,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDriveInfo")); + Invokable method = method(CloudSigmaAsyncClient.class, "listDriveInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1"); @@ -140,7 +140,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getDriveInfo", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "getDriveInfo", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1"); @@ -156,7 +156,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createDrive", Drive.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "createDrive", Drive.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l) .build())); @@ -174,8 +174,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class, - CloneDriveOptions[].class)); + Invokable method = method(CloudSigmaAsyncClient.class, "cloneDrive", String.class, String.class, + CloneDriveOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1"); @@ -191,8 +191,8 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class, - CloneDriveOptions[].class)); + Invokable method = method(CloudSigmaAsyncClient.class, "cloneDrive", String.class, String.class, + CloneDriveOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname", new CloneDriveOptions().size(1024l))); @@ -209,7 +209,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "setDriveData", String.class, DriveData.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", new DriveData.Builder().name("foo").size(10000l) .use(ImmutableList.of("production", "candy")).build())); @@ -226,7 +226,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServers")); + Invokable method = method(CloudSigmaAsyncClient.class, "listServers"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1"); @@ -253,7 +253,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServerInfo")); + Invokable method = method(CloudSigmaAsyncClient.class, "listServerInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1"); @@ -268,7 +268,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getServerInfo", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "getServerInfo", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1"); @@ -284,7 +284,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createServer", Server.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "createServer", Server.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1"); @@ -300,7 +300,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "setServerConfiguration", String.class, Server.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1"); @@ -316,7 +316,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "destroyServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1"); @@ -332,7 +332,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("startServer", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "startServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1"); @@ -348,7 +348,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("stopServer", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "stopServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1"); @@ -364,7 +364,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("shutdownServer", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "shutdownServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1"); @@ -380,7 +380,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("resetServer", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "resetServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1"); @@ -396,7 +396,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDrives")); + Invokable method = method(CloudSigmaAsyncClient.class, "listDrives"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1"); @@ -423,7 +423,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "destroyDrive", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1"); @@ -439,7 +439,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANs")); + Invokable method = method(CloudSigmaAsyncClient.class, "listVLANs"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1"); @@ -466,7 +466,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANInfo")); + Invokable method = method(CloudSigmaAsyncClient.class, "listVLANInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1"); @@ -481,7 +481,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getVLANInfo", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "getVLANInfo", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1"); @@ -497,7 +497,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createVLAN", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "createVLAN", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("poohbear")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1"); @@ -513,7 +513,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("renameVLAN", String.class, String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "renameVLAN", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "poohbear")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1"); @@ -529,7 +529,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "destroyVLAN", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1"); @@ -545,7 +545,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPs")); + Invokable method = method(CloudSigmaAsyncClient.class, "listStaticIPs"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1"); @@ -572,7 +572,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPInfo")); + Invokable method = method(CloudSigmaAsyncClient.class, "listStaticIPInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1"); @@ -587,7 +587,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getStaticIPInfo", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "getStaticIPInfo", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1"); @@ -603,7 +603,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createStaticIP")); + Invokable method = method(CloudSigmaAsyncClient.class, "createStaticIP"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1"); @@ -619,7 +619,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class)); + Invokable method = method(CloudSigmaAsyncClient.class, "destroyStaticIP", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1"); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java index e0e3c9aec3..29cd5d4310 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudsigma.binders; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -27,7 +28,6 @@ import java.util.Map; import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.reflect.Invocation; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; @@ -35,7 +35,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.inject.Guice; - /** * * @author Adrian Cole @@ -64,13 +63,11 @@ public class BindCloneDriveOptionsToPlainTextStringTest { protected GeneratedHttpRequest requestForArgs(List args) { try { - Invocation invocation = Invocation.create(Invokable.from(String.class.getDeclaredMethod("toString")), args); + Invocation invocation = Invocation.create(method(String.class, "toString"), args); return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) .invocation(invocation).build(); } catch (SecurityException e) { throw Throwables.propagate(e); - } catch (NoSuchMethodException e) { - throw Throwables.propagate(e); } } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java index 39c0d8aab9..a604bcf1bc 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java @@ -17,10 +17,9 @@ * under the License. */ package org.jclouds.cloudstack; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -35,7 +34,6 @@ import org.jclouds.rest.internal.BaseRestApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; import com.google.inject.Module; - /** * Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api. * @@ -81,7 +79,7 @@ public class CloudStackApiMetadata extends BaseRestApiMetadata { .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")) .defaultEndpoint("http://localhost:8080/client/api") .version("2.2") - .view(typeTokenOf(CloudStackContext.class)) + .view(typeToken(CloudStackContext.class)) .defaultProperties(CloudStackApiMetadata.defaultProperties()) .defaultModules(ImmutableSet.> builder() .add(CloudStackParserModule.class) diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java index acad979a9f..a9cedf6b3f 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java @@ -17,6 +17,7 @@ * under the License. */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -26,12 +27,12 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListAccountsOptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AccountAsyncClient} @@ -44,7 +45,7 @@ import com.google.common.collect.ImmutableList; public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListAccounts() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class)); + Invokable method = method(AccountAsyncClient.class, "listAccounts", ListAccountsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -61,7 +62,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class)); + Invokable method = method(AccountAsyncClient.class, "listAccounts", ListAccountsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListAccountsOptions.Builder.accountInDomain("jclouds", "123"))); @@ -79,7 +80,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AccountAsyncClient.class.getMethod("getAccount", String.class)); + Invokable method = method(AccountAsyncClient.class, "getAccount", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("3")); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java index 1c3f8c7c53..7b9f27abb9 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -31,13 +33,12 @@ import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AddressAsyncClient} * @@ -48,7 +49,7 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "AddressAsyncClientTest") public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListPublicIPAddresses() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class)); + Invokable method = method(AddressAsyncClient.class, "listPublicIPAddresses", ListPublicIPAddressesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -65,7 +66,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class)); + Invokable method = method(AddressAsyncClient.class, "listPublicIPAddresses", ListPublicIPAddressesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListPublicIPAddressesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true))); @@ -84,7 +85,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("getPublicIPAddress", String.class)); + Invokable method = method(AddressAsyncClient.class, "getPublicIPAddress", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -102,8 +103,8 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("associateIPAddressInZone", String.class, - AssociateIPAddressOptions[].class)); + Invokable method = method(AddressAsyncClient.class, "associateIPAddressInZone", String.class, + AssociateIPAddressOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6)); assertRequestLineEquals(httpRequest, @@ -120,7 +121,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("disassociateIPAddress", String.class)); + Invokable method = method(AddressAsyncClient.class, "disassociateIPAddress", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java index fa946c5862..600e8f3943 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,11 +28,11 @@ import org.jclouds.cloudstack.functions.ParseAsyncJobFromHttpResponse; import org.jclouds.cloudstack.functions.ParseAsyncJobsFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListAsyncJobsOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AsyncJobAsyncClient} @@ -43,7 +45,7 @@ import com.google.common.collect.ImmutableList; public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testGetAsyncJob() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AsyncJobAsyncClient.class.getMethod("getAsyncJob", String.class)); + Invokable method = method(AsyncJobAsyncClient.class, "getAsyncJob", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, @@ -60,7 +62,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class)); + Invokable method = method(AsyncJobAsyncClient.class, "listAsyncJobs", ListAsyncJobsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -77,7 +79,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class)); + Invokable method = method(AsyncJobAsyncClient.class, "listAsyncJobs", ListAsyncJobsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListAsyncJobsOptions.Builder.accountInDomain("adrian", "5"))); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java index e02faa3b94..d703c7244e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java @@ -18,17 +18,18 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ConfigurationAsyncClient} * @@ -40,7 +41,7 @@ import com.google.common.collect.ImmutableList; public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListCapabilities() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigurationAsyncClient.class.getMethod("listCapabilities")); + Invokable method = method(ConfigurationAsyncClient.class, "listCapabilities"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java index 605c0fa843..baee097f42 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code DomainAccountAsyncClient} * @@ -37,7 +38,7 @@ import com.google.common.collect.ImmutableList; public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testEnableAccount() throws Exception { - Invokable method = Invokable.from(DomainAccountAsyncClient.class.getMethod("enableAccount", String.class, String.class)); + Invokable method = method(DomainAccountAsyncClient.class, "enableAccount", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo", "2")); assertRequestLineEquals(httpRequest, @@ -53,7 +54,7 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testDisableAccount() throws Exception { - Invokable method = Invokable.from(DomainAccountAsyncClient.class.getMethod("disableAccount", String.class, String.class, boolean.class)); + Invokable method = method(DomainAccountAsyncClient.class, "disableAccount", String.class, String.class, boolean.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("1", "2", true)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java index 4223b6b5c6..1d71d1949e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.cloudstack.domain.ResourceLimit; @@ -25,12 +27,11 @@ import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code DomainLimitAsyncClient} * @@ -40,7 +41,7 @@ import com.google.common.collect.ImmutableList; public class DomainLimitAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testUpdateResourceLimit() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(DomainLimitAsyncClient.class.getMethod("updateResourceLimit", ResourceLimit.class)); + Invokable method = method(DomainLimitAsyncClient.class, "updateResourceLimit", ResourceLimit.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build())); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java index f72b68c573..2677c0d7a9 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -25,12 +27,11 @@ import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListEventsOptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code EventAsyncClient} * @@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableList; public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListEventTypes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(EventAsyncClient.class.getMethod("listEventTypes")); + Invokable method = method(EventAsyncClient.class, "listEventTypes"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -58,7 +59,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class)); + Invokable method = method(EventAsyncClient.class, "listEvents", ListEventsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -75,7 +76,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class)); + Invokable method = method(EventAsyncClient.class, "listEvents", ListEventsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListEventsOptions.Builder.account("jclouds"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java index a3b9f34952..251b5b0025 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -29,12 +31,11 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code FirewallAsyncClient} * @@ -45,8 +46,8 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "FirewallAsyncClientTest") public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListPortForwardingRules() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules", - ListPortForwardingRulesOptions[].class)); + Invokable method = method(FirewallAsyncClient.class, "listPortForwardingRules", + ListPortForwardingRulesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -63,8 +64,8 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules", - ListPortForwardingRulesOptions[].class)); + Invokable method = method(FirewallAsyncClient.class, "listPortForwardingRules", + ListPortForwardingRulesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListPortForwardingRulesOptions.Builder.ipAddressId("3"))); assertRequestLineEquals(httpRequest, @@ -82,8 +83,8 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("createPortForwardingRuleForVirtualMachine", String.class, - PortForwardingRule.Protocol.class, int.class, String.class, int.class)); + Invokable method = method(FirewallAsyncClient.class, "createPortForwardingRuleForVirtualMachine", String.class, + PortForwardingRule.Protocol.class, int.class, String.class, int.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22)); assertRequestLineEquals( @@ -101,7 +102,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("deletePortForwardingRule", String.class)); + Invokable method = method(FirewallAsyncClient.class, "deletePortForwardingRule", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java index 4bddcaa02d..2b4ae4b1c3 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; @@ -26,12 +28,11 @@ import org.jclouds.cloudstack.options.UpdateAccountOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalAccountAsyncClient} * @@ -53,8 +54,8 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< .build(); public void testCreateAccount() throws Exception { - Invokable method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("createAccount", String.class, Account.Type.class, - String.class, String.class, String.class, String.class, CreateAccountOptions[].class)); + Invokable method = method(GlobalAccountAsyncClient.class, "createAccount", String.class, Account.Type.class, + String.class, String.class, String.class, String.class, CreateAccountOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("user", Account.Type.USER, "email@example.com", "FirstName", "LastName", "hashed-password")); @@ -79,8 +80,8 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< .build(); public void testUpdateAccount() throws Exception { - Invokable method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("updateAccount", String.class, String.class, - String.class, UpdateAccountOptions[].class)); + Invokable method = method(GlobalAccountAsyncClient.class, "updateAccount", String.class, String.class, + String.class, UpdateAccountOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("account", 42L, "new-account-name")); assertRequestLineEquals(httpRequest, update.getRequestLine()); @@ -95,7 +96,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testDeleteAccount() throws Exception { - Invokable method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("deleteAccount", String.class)); + Invokable method = method(GlobalAccountAsyncClient.class, "deleteAccount", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java index dc3888516d..29084da71b 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java @@ -18,18 +18,19 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListAlertsOptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalAlertsAsyncClient} * @@ -41,7 +42,7 @@ import com.google.common.collect.ImmutableList; public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListAlerts() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class)); + Invokable method = method(GlobalAlertAsyncClient.class, "listAlerts", ListAlertsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -58,7 +59,7 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class)); + Invokable method = method(GlobalAlertAsyncClient.class, "listAlerts", ListAlertsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListAlertsOptions.Builder.id("42").keyword("jclouds").type("TEMPLATE"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java index 3c036f1abe..6a18ef05ae 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -25,12 +27,11 @@ import org.jclouds.cloudstack.domain.Capacity; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListCapacityOptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalCapacityAsyncClient} * @@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableList; public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListCapacity() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class)); + Invokable method = method(GlobalCapacityAsyncClient.class, "listCapacity", ListCapacityOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -58,7 +59,7 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testListCapacityOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class)); + Invokable method = method(GlobalCapacityAsyncClient.class, "listCapacity", ListCapacityOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListCapacityOptions.Builder.hostId("3").keyword("fred").podId("4").type(Capacity.Type.CPU_ALLOCATED_MHZ).zoneId("6"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java index 32ec924ea6..541b32f569 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListHostsOptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalHostAsyncClient} * @@ -37,7 +38,7 @@ import com.google.common.collect.ImmutableList; public class GlobalHostAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListHosts() throws Exception { - Invokable method = Invokable.from(GlobalHostAsyncClient.class.getMethod("listHosts", ListHostsOptions[].class)); + Invokable method = method(GlobalHostAsyncClient.class, "listHosts", ListHostsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java index 3659ca9f89..09ccc93317 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java @@ -17,6 +17,7 @@ * under the License. */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; @@ -28,11 +29,11 @@ import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalOfferingAsyncClient} @@ -53,8 +54,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest .addQueryParam("memory", "3").build(); public void testCreateServiceOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createServiceOffering", - String.class, String.class, int.class, int.class, int.class, CreateServiceOfferingOptions[].class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "createServiceOffering", + String.class, String.class, int.class, int.class, int.class, CreateServiceOfferingOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "displayText", 1, 2, 3)); assertRequestLineEquals(httpRequest, createServiceOffering.getRequestLine()); @@ -69,8 +70,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testUpdateServiceOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateServiceOffering", - String.class, UpdateServiceOfferingOptions[].class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "updateServiceOffering", + String.class, UpdateServiceOfferingOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, @@ -86,7 +87,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testDeleteServiceOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteServiceOffering", String.class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "deleteServiceOffering", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, @@ -102,8 +103,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testCreateDiskOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createDiskOffering", - String.class, String.class, CreateDiskOfferingOptions[].class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "createDiskOffering", + String.class, String.class, CreateDiskOfferingOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "displayText")); assertRequestLineEquals(httpRequest, @@ -119,8 +120,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testUpdateDiskOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateDiskOffering", - String.class, UpdateDiskOfferingOptions[].class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "updateDiskOffering", + String.class, UpdateDiskOfferingOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, @@ -136,7 +137,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testDeleteDiskOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteDiskOffering", String.class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "deleteDiskOffering", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, @@ -152,8 +153,8 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testUpdateNetworkOffering() throws Exception { - Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateNetworkOffering", - String.class, UpdateNetworkOfferingOptions[].class)); + Invokable method = method(GlobalOfferingAsyncClient.class, "updateNetworkOffering", + String.class, UpdateNetworkOfferingOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java index d23d8c82df..62435cfafa 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListStoragePoolsOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalStoragePoolAsyncClient} * @@ -37,7 +38,7 @@ import com.google.common.collect.ImmutableList; public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListStoragePools() throws NoSuchMethodException { - Invokable method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class)); + Invokable method = method(GlobalStoragePoolAsyncClient.class, "listStoragePools", ListStoragePoolsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -53,7 +54,7 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT } public void testListStoragePoolsOptions() throws NoSuchMethodException { - Invokable method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class)); + Invokable method = method(GlobalStoragePoolAsyncClient.class, "listStoragePools", ListStoragePoolsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java index aa7fd8c83f..095edb27ce 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.util.Calendar; import java.util.Date; @@ -26,12 +28,11 @@ import org.jclouds.cloudstack.options.GenerateUsageRecordsOptions; import org.jclouds.cloudstack.options.ListUsageRecordsOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalUsageAsyncClient} * @@ -49,8 +50,8 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords", - Date.class, Date.class, GenerateUsageRecordsOptions[].class)); + Invokable method = method(GlobalUsageAsyncClient.class, "generateUsageRecords", + Date.class, Date.class, GenerateUsageRecordsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end)); assertRequestLineEquals(httpRequest, @@ -74,8 +75,8 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords", - Date.class, Date.class, GenerateUsageRecordsOptions[].class)); + Invokable method = method(GlobalUsageAsyncClient.class, "generateUsageRecords", + Date.class, Date.class, GenerateUsageRecordsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end, GenerateUsageRecordsOptions.Builder.domainId("42"))); assertRequestLineEquals(httpRequest, @@ -99,8 +100,8 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords", - Date.class, Date.class, ListUsageRecordsOptions[].class)); + Invokable method = method(GlobalUsageAsyncClient.class, "listUsageRecords", + Date.class, Date.class, ListUsageRecordsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end)); assertRequestLineEquals(httpRequest, @@ -124,8 +125,8 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords", - Date.class, Date.class, ListUsageRecordsOptions[].class)); + Invokable method = method(GlobalUsageAsyncClient.class, "listUsageRecords", + Date.class, Date.class, ListUsageRecordsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java index 27b009606f..cdd7d05137 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.CreateUserOptions; @@ -25,12 +27,11 @@ import org.jclouds.cloudstack.options.UpdateUserOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalUserAsyncClient} */ @@ -49,8 +50,8 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUserAsyncClient.class.getMethod("createUser", String.class, String.class, - String.class, String.class, String.class, String.class, CreateUserOptions[].class)); + Invokable method = method(GlobalUserAsyncClient.class, "createUser", String.class, String.class, + String.class, String.class, String.class, String.class, CreateUserOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("user", "account", "email@example.com", "hashed-password", "FirstName", "LastName")); @@ -66,7 +67,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUserAsyncClient.class.getMethod("updateUser", String.class, UpdateUserOptions[].class)); + Invokable method = method(GlobalUserAsyncClient.class, "updateUser", String.class, UpdateUserOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); assertRequestLineEquals(httpRequest, @@ -82,7 +83,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUserAsyncClient.class.getMethod("deleteUser", String.class)); + Invokable method = method(GlobalUserAsyncClient.class, "deleteUser", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java index 0d5e639420..d72895ec7a 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -28,13 +30,12 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListOSTypesOptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GuestOSAsyncClient} * @@ -46,7 +47,7 @@ import com.google.common.collect.ImmutableList; public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testGetOSCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSCategory", String.class)); + Invokable method = method(GuestOSAsyncClient.class, "getOSCategory", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, @@ -63,7 +64,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSCategories")); + Invokable method = method(GuestOSAsyncClient.class, "listOSCategories"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -80,7 +81,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSType", String.class)); + Invokable method = method(GuestOSAsyncClient.class, "getOSType", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, @@ -98,7 +99,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class)); + Invokable method = method(GuestOSAsyncClient.class, "listOSTypes", ListOSTypesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -115,7 +116,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class)); + Invokable method = method(GuestOSAsyncClient.class, "listOSTypes", ListOSTypesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListOSTypesOptions.Builder.OSCategoryId("11"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java index dea795b9e5..f7cca81aa3 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java @@ -18,17 +18,18 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code HypervisorAsyncClient} * @@ -40,7 +41,7 @@ import com.google.common.collect.ImmutableList; public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListHypervisors() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisors")); + Invokable method = method(HypervisorAsyncClient.class, "listHypervisors"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -57,7 +58,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisorsInZone", String.class)); + Invokable method = method(HypervisorAsyncClient.class, "listHypervisorsInZone", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java index ae143e7538..00a7396206 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java @@ -17,6 +17,7 @@ * under the License. */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; import org.jclouds.cloudstack.domain.ExtractMode; import org.jclouds.cloudstack.domain.PermissionOperation; @@ -48,7 +49,7 @@ import com.google.common.reflect.Invokable; public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testAttachISO() throws NoSuchMethodException { - Invokable method = Invokable.from(ISOAsyncClient.class.getMethod("attachISO", String.class, String.class)); + Invokable method = method(ISOAsyncClient.class, "attachISO", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("3", "5")); assertRequestLineEquals(httpRequest, @@ -64,7 +65,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("detachISO", String.class)); + Invokable method = method(ISOAsyncClient.class, "detachISO", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, @@ -80,7 +81,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "updateISO", String.class, UpdateISOOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, @@ -96,7 +97,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "updateISO", String.class, UpdateISOOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId("9").passwordEnabled(true))); assertRequestLineEquals(httpRequest, @@ -112,7 +113,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "deleteISO", String.class, DeleteISOOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, @@ -128,7 +129,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "deleteISO", String.class, DeleteISOOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, DeleteISOOptions.Builder.zoneId("5"))); assertRequestLineEquals(httpRequest, @@ -153,7 +154,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("copyISO", String.class, String.class, String.class)); + Invokable method = method(ISOAsyncClient.class, "copyISO", String.class, String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, 5, 7)); assertRequestLineEquals(httpRequest, copyIso.getRequestLine()); @@ -167,7 +168,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, @@ -183,7 +184,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add))); assertRequestLineEquals(httpRequest, @@ -199,7 +200,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "listISOPermissions", String.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, @@ -215,7 +216,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "listISOPermissions", String.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, AccountInDomainOptions.Builder.accountInDomain("fred", "5"))); assertRequestLineEquals(httpRequest, @@ -240,7 +241,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5)); assertRequestLineEquals(httpRequest, extractIso.getRequestLine()); @@ -265,7 +266,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class)); + Invokable method = method(ISOAsyncClient.class, "extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/"))); assertRequestLineEquals(httpRequest, extractIsoOptions.getRequestLine()); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java index 39de8d24ca..d0aab6e3bd 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java @@ -17,6 +17,7 @@ * under the License. */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -24,11 +25,11 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListResourceLimitsOptions; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code LimitAsyncClient} @@ -39,7 +40,7 @@ import com.google.common.collect.ImmutableList; public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListResourceLimits() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class)); + Invokable method = method(LimitAsyncClient.class, "listResourceLimits", ListResourceLimitsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -56,7 +57,7 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class)); + Invokable method = method(LimitAsyncClient.class, "listResourceLimits", ListResourceLimitsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListResourceLimitsOptions.Builder.account("jclouds" , "23"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java index 08bf1ef647..9c058c6d1b 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -30,12 +32,11 @@ import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code LoadBalancerAsyncClient} * @@ -46,8 +47,8 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "LoadBalancerAsyncClientTest") public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListLoadBalancerRules() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules", - ListLoadBalancerRulesOptions[].class)); + Invokable method = method(LoadBalancerAsyncClient.class, "listLoadBalancerRules", + ListLoadBalancerRulesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -64,8 +65,8 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules", - ListLoadBalancerRulesOptions[].class)); + Invokable method = method(LoadBalancerAsyncClient.class, "listLoadBalancerRules", + ListLoadBalancerRulesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListLoadBalancerRulesOptions.Builder.publicIPId("3"))); assertRequestLineEquals(httpRequest, @@ -92,8 +93,8 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("createLoadBalancerRuleForPublicIP", String.class, - Algorithm.class, String.class, int.class, int.class, CreateLoadBalancerRuleOptions[].class)); + Invokable method = method(LoadBalancerAsyncClient.class, "createLoadBalancerRuleForPublicIP", String.class, + Algorithm.class, String.class, int.class, int.class, CreateLoadBalancerRuleOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, Algorithm.LEASTCONN, "tcp", 22, 22)); assertRequestLineEquals(httpRequest, createLoadBalancerRule.getRequestLine()); @@ -109,7 +110,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("updateLoadBalancerRule", String.class, UpdateLoadBalancerRuleOptions[].class)); + Invokable method = method(LoadBalancerAsyncClient.class, "updateLoadBalancerRule", String.class, UpdateLoadBalancerRuleOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -125,7 +126,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("deleteLoadBalancerRule", String.class)); + Invokable method = method(LoadBalancerAsyncClient.class, "deleteLoadBalancerRule", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -143,8 +144,8 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule", - String.class)); + Invokable method = method(LoadBalancerAsyncClient.class, "listVirtualMachinesAssignedToLoadBalancerRule", + String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java index 3dca97205f..efa9feb48d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -30,12 +32,11 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NATAsyncClient} * @@ -46,7 +47,7 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "NATAsyncClientTest") public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListIPForwardingRules() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class)); + Invokable method = method(NATAsyncClient.class, "listIPForwardingRules", ListIPForwardingRulesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -63,7 +64,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class)); + Invokable method = method(NATAsyncClient.class, "listIPForwardingRules", ListIPForwardingRulesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListIPForwardingRulesOptions.Builder.virtualMachineId("3"))); @@ -81,7 +82,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("getIPForwardingRule", String.class)); + Invokable method = method(NATAsyncClient.class, "getIPForwardingRule", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -106,8 +107,8 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class, - CreateIPForwardingRuleOptions[].class)); + Invokable method = method(NATAsyncClient.class, "createIPForwardingRule", String.class, String.class, int.class, + CreateIPForwardingRuleOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7, "tcp", 22)); assertRequestLineEquals(httpRequest, createIpForwardingRule.getRequestLine()); @@ -133,8 +134,8 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class, - CreateIPForwardingRuleOptions[].class)); + Invokable method = method(NATAsyncClient.class, "createIPForwardingRule", String.class, String.class, int.class, + CreateIPForwardingRuleOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7, "tcp", 22, CreateIPForwardingRuleOptions.Builder.endPort(22))); @@ -151,7 +152,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("enableStaticNATForVirtualMachine", String.class, String.class)); + Invokable method = method(NATAsyncClient.class, "enableStaticNATForVirtualMachine", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, 6)); assertRequestLineEquals(httpRequest, @@ -168,7 +169,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("disableStaticNATOnPublicIP", String.class)); + Invokable method = method(NATAsyncClient.class, "disableStaticNATOnPublicIP", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -185,7 +186,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("deleteIPForwardingRule", String.class)); + Invokable method = method(NATAsyncClient.class, "deleteIPForwardingRule", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java index 9cb636cdee..d982fbc9f0 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -30,13 +32,12 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NetworkAsyncClient} * @@ -47,7 +48,7 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "NetworkAsyncClientTest") public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class)); + Invokable method = method(NetworkAsyncClient.class, "listNetworks", ListNetworksOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -64,7 +65,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class)); + Invokable method = method(NetworkAsyncClient.class, "listNetworks", ListNetworksOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListNetworksOptions.Builder.type(NetworkType.ADVANCED) .domainId("6").id("5"))); @@ -82,7 +83,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", String.class)); + Invokable method = method(NetworkAsyncClient.class, "getNetwork", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("id")); assertRequestLineEquals(httpRequest, @@ -109,8 +110,8 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class, - String.class, CreateNetworkOptions[].class)); + Invokable method = method(NetworkAsyncClient.class, "createNetworkInZone", String.class, String.class, String.class, + String.class, CreateNetworkOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1, 2, "named", "lovely")); assertRequestLineEquals(httpRequest, createNetwork.getRequestLine()); @@ -137,8 +138,8 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class, - String.class, CreateNetworkOptions[].class)); + Invokable method = method(NetworkAsyncClient.class, "createNetworkInZone", String.class, String.class, String.class, + String.class, CreateNetworkOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1, 2, "named", "lovely", CreateNetworkOptions.Builder .netmask("255.255.255.0").domainId("6"))); @@ -156,7 +157,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("deleteNetwork", String.class)); + Invokable method = method(NetworkAsyncClient.class, "deleteNetwork", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java index cf23dcb00b..380caa778a 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java @@ -19,6 +19,7 @@ package org.jclouds.cloudstack.features; import static org.jclouds.cloudstack.domain.NetworkOfferingAvailabilityType.DEFAULT; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -30,13 +31,12 @@ import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OfferingAsyncClient} * @@ -47,7 +47,7 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "OfferingAsyncClientTest") public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListDiskOfferings() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class)); + Invokable method = method(OfferingAsyncClient.class, "listDiskOfferings", ListDiskOfferingsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -64,7 +64,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class)); + Invokable method = method(OfferingAsyncClient.class, "listDiskOfferings", ListDiskOfferingsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListDiskOfferingsOptions.Builder.domainId("6").id("5"))); assertRequestLineEquals(httpRequest, @@ -81,7 +81,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("getDiskOffering", String.class)); + Invokable method = method(OfferingAsyncClient.class, "getDiskOffering", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); assertRequestLineEquals(httpRequest, @@ -99,7 +99,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class)); + Invokable method = method(OfferingAsyncClient.class, "listNetworkOfferings", ListNetworkOfferingsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -116,7 +116,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class)); + Invokable method = method(OfferingAsyncClient.class, "listNetworkOfferings", ListNetworkOfferingsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListNetworkOfferingsOptions.Builder.availability(DEFAULT).isShared(true).id("6"))); @@ -135,7 +135,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("getNetworkOffering", String.class)); + Invokable method = method(OfferingAsyncClient.class, "getNetworkOffering", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); assertRequestLineEquals(httpRequest, @@ -153,7 +153,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class)); + Invokable method = method(OfferingAsyncClient.class, "listServiceOfferings", ListServiceOfferingsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -170,7 +170,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class)); + Invokable method = method(OfferingAsyncClient.class, "listServiceOfferings", ListServiceOfferingsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListServiceOfferingsOptions.Builder.virtualMachineId("4") .domainId("5").id("6"))); @@ -189,7 +189,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("getServiceOffering", String.class)); + Invokable method = method(OfferingAsyncClient.class, "getServiceOffering", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java index cc9dc478f7..f0e3be3669 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -33,14 +34,13 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.ssh.SshKeys; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SSHKeyPairAsyncClient} * @@ -50,7 +50,7 @@ import com.google.common.collect.ImmutableList; public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListSSHKeyPairs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class)); + Invokable method = method(SSHKeyPairAsyncClient.class, "listSSHKeyPairs", ListSSHKeyPairsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -67,7 +67,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class)); + Invokable method = method(SSHKeyPairAsyncClient.class, "listSSHKeyPairs", ListSSHKeyPairsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSSHKeyPairsOptions.Builder.name("jclouds"))); assertRequestLineEquals(httpRequest, @@ -84,7 +84,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", String.class)); + Invokable method = method(SSHKeyPairAsyncClient.class, "getSSHKeyPair", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair")); assertRequestLineEquals(httpRequest, @@ -102,7 +102,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("registerSSHKeyPair", String.class, String.class)); + Invokable method = method(SSHKeyPairAsyncClient.class, "registerSSHKeyPair", String.class, String.class); String publicKey = URLEncoder.encode(SshKeys.generate().get("public"), "UTF-8"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair", publicKey)); assertRequestLineEquals(httpRequest, @@ -122,7 +122,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("deleteSSHKeyPair", String.class)); + Invokable method = method(SSHKeyPairAsyncClient.class, "deleteSSHKeyPair", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair")); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java index 28551d8169..848777e4ac 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -31,7 +33,6 @@ import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; @@ -40,7 +41,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SecurityGroupAsyncClient} * @@ -52,7 +53,7 @@ import com.google.common.collect.Multimap; public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListSecurityGroups() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "listSecurityGroups", ListSecurityGroupsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -69,7 +70,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testListSecurityGroupsOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "listSecurityGroups", ListSecurityGroupsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSecurityGroupsOptions.Builder.virtualMachineId("4") .domainId("5").id("6"))); @@ -88,7 +89,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testGetSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("getSecurityGroup", String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "getSecurityGroup", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -106,7 +107,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "createSecurityGroup", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo")); assertRequestLineEquals(httpRequest, @@ -133,8 +134,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< .addQueryParam("cidrlist", "1.1.1.1/24,1.2.2.2/16").build(); public void testAuthorizeIngressPortsToCIDRs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToCIDRs", String.class, - String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "authorizeIngressPortsToCIDRs", String.class, + String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "tcp", 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"))); @@ -166,8 +167,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< .addQueryParam("usersecuritygrouplist%5B2%5D.group", "group1").build(); public void testAuthorizeIngressPortsToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToSecurityGroups", String.class, - String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "authorizeIngressPortsToSecurityGroups", String.class, + String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "tcp", 22, 22, ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1"))); @@ -194,8 +195,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< .addQueryParam("cidrlist", "1.1.1.1/24,1.2.2.2/16").build(); public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", String.class , int.class, - int.class, Iterable.class, AccountInDomainOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "authorizeIngressICMPToCIDRs", String.class , int.class, + int.class, Iterable.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"))); assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress1.getRequestLine()); @@ -226,8 +227,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< .addQueryParam("usersecuritygrouplist%5B2%5D.group", "group1").build(); public void testAuthorizeIngressICMPToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToSecurityGroups", String.class, - int.class, int.class, Multimap.class, AccountInDomainOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "authorizeIngressICMPToSecurityGroups", String.class, + int.class, int.class, Multimap.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, 22, 22, ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1"))); @@ -244,8 +245,8 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeIngressRule", String.class, - AccountInDomainOptions[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "revokeIngressRule", String.class, + AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, AccountInDomainOptions.Builder.accountInDomain("adrian", "1"))); @@ -264,7 +265,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< } public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "deleteSecurityGroup", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java index 103a4293c5..a21f1736c7 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; @@ -34,14 +36,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; - +import com.google.common.reflect.Invokable; /** * Tests the behaviour of SnapshotAsyncClient. * @@ -54,7 +55,7 @@ import com.google.common.collect.ImmutableSet; public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testCreateSnapshot() throws NoSuchMethodException { - Invokable method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class)); + Invokable method = method(SnapshotAsyncClient.class, "createSnapshot", String.class, CreateSnapshotOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -70,7 +71,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class)); + Invokable method = method(SnapshotAsyncClient.class, "createSnapshot", String.class, CreateSnapshotOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, CreateSnapshotOptions.Builder.accountInDomain("acc", "7").policyId("9"))); assertRequestLineEquals(httpRequest, @@ -86,7 +87,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class)); + Invokable method = method(SnapshotAsyncClient.class, "listSnapshots", ListSnapshotsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -102,7 +103,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("getSnapshot", String.class)); + Invokable method = method(SnapshotAsyncClient.class, "getSnapshot", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -119,7 +120,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class)); + Invokable method = method(SnapshotAsyncClient.class, "listSnapshots", ListSnapshotsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSnapshotsOptions.Builder.accountInDomain("acc", "7").id("5").interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId("11"))); assertRequestLineEquals(httpRequest, @@ -135,7 +136,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshot", String.class)); + Invokable method = method(SnapshotAsyncClient.class, "deleteSnapshot", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(14)); assertRequestLineEquals(httpRequest, @@ -161,7 +162,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshotPolicy", SnapshotPolicySchedule.class, String.class, String.class, String.class)); + Invokable method = method(SnapshotAsyncClient.class, "createSnapshotPolicy", SnapshotPolicySchedule.class, String.class, String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12)); assertRequestLineEquals(httpRequest,extractIso.getRequestLine()); @@ -176,7 +177,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicy", String.class)); + Invokable method = method(SnapshotAsyncClient.class, "deleteSnapshotPolicy", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7)); assertRequestLineEquals(httpRequest, @@ -192,7 +193,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicies", Iterable.class)); + Invokable method = method(SnapshotAsyncClient.class, "deleteSnapshotPolicies", Iterable.class); Iterable ids = ImmutableSet.of("3", "5", "7"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ids)); @@ -209,7 +210,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class)); + Invokable method = method(SnapshotAsyncClient.class, "listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(10)); assertRequestLineEquals(httpRequest, @@ -225,7 +226,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class)); + Invokable method = method(SnapshotAsyncClient.class, "listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(10, ListSnapshotPoliciesOptions.Builder.accountInDomain("fred", "4").keyword("bob"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java index afef50d3f7..1fca0d84d1 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -41,14 +43,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TemplateAsyncClient} * @@ -60,7 +61,7 @@ import com.google.common.collect.ImmutableSet; public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testCreateTemplate() throws NoSuchMethodException { - Invokable method = Invokable.from(TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build())); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createTemplate&name=thename&ostypeid=10&displaytext=description HTTP/1.1"); @@ -75,7 +76,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), CreateTemplateOptions.Builder.bits(32).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true).snapshotId("11").volumeId("12"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createTemplate&bits=32&isfeatured=true&ispublic=true&passwordenabled=true&requireshvm=true&snapshotid=11&volumeid=12&name=thename&ostypeid=10&displaytext=description HTTP/1.1"); @@ -102,7 +103,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20)); assertRequestLineEquals(httpRequest, registerTemplate.getRequestLine()); @@ -138,7 +139,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20, RegisterTemplateOptions.Builder.accountInDomain("mydomain", "3").bits(32).checksum("ABC").isExtractable(true).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true))); @@ -154,7 +155,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "updateTemplate", String.class, UpdateTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplate&id=17 HTTP/1.1"); @@ -169,7 +170,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "updateTemplate", String.class, UpdateTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, UpdateTemplateOptions.Builder.bootable(true).displayText("description").format(Template.Format.VHD).name("thename").osTypeId("12").passwordEnabled(true))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplate&id=17&bootable=true&displaytext=description&format=VHD&name=thename&ostypeid=12&passwordenabled=true HTTP/1.1"); @@ -192,7 +193,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("copyTemplateToZone", String.class, String.class, String.class)); + Invokable method = method(TemplateAsyncClient.class, "copyTemplateToZone", String.class, String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, 18, 19)); assertRequestLineEquals(httpRequest,copyTemplate.getRequestLine()); @@ -207,7 +208,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "deleteTemplate", String.class, DeleteTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteTemplate&id=17 HTTP/1.1"); @@ -222,7 +223,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "deleteTemplate", String.class, DeleteTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, DeleteTemplateOptions.Builder.zoneId("8"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteTemplate&id=17&zoneid=8 HTTP/1.1"); @@ -237,7 +238,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates")); + Invokable method = method(TemplateAsyncClient.class, "listTemplates"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -254,7 +255,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class)); + Invokable method = method(TemplateAsyncClient.class, "listTemplates", ListTemplatesOptions.class); GeneratedHttpRequest httpRequest = processor .createRequest( method, ImmutableList. of( @@ -276,7 +277,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("getTemplateInZone", String.class, String.class)); + Invokable method = method(TemplateAsyncClient.class, "getTemplateInZone", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, 1)); assertRequestLineEquals( @@ -295,7 +296,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplatePermissions&id=17 HTTP/1.1"); @@ -310,7 +311,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, UpdateTemplatePermissionsOptions.Builder.accounts(ImmutableSet.of("5", "6")).isExtractable(true).isFeatured(true).isPublic(true).op(UpdateTemplatePermissionsOptions.Operation.add))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplatePermissions&id=17&accounts=5,6&isextractable=true&isfeatured=true&ispublic=true&op=add HTTP/1.1"); @@ -325,7 +326,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "listTemplatePermissions", String.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplatePermissions&listAll=true&id=17 HTTP/1.1"); @@ -340,7 +341,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "listTemplatePermissions", String.class, AccountInDomainOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, AccountInDomainOptions.Builder.accountInDomain("fred", "8"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplatePermissions&listAll=true&id=17&account=fred&domainid=8 HTTP/1.1"); @@ -363,7 +364,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5)); assertRequestLineEquals(httpRequest, extractTemplate.getRequestLine()); @@ -387,7 +388,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class)); + Invokable method = method(TemplateAsyncClient.class, "extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractTemplateOptions.Builder.url("http://example.com/"))); assertRequestLineEquals(httpRequest, extractTemplateOptions.getRequestLine()); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java index e503ebe523..d0a5ed443c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -31,13 +33,12 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VMGroupAsyncClient} * @@ -49,7 +50,7 @@ import com.google.common.collect.ImmutableList; public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListVMGroups() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class)); + Invokable method = method(VMGroupAsyncClient.class, "listInstanceGroups", ListVMGroupsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -66,7 +67,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class)); + Invokable method = method(VMGroupAsyncClient.class, "listInstanceGroups", ListVMGroupsOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListVMGroupsOptions.Builder.account("fred") .domainId("5").id("6"))); @@ -85,7 +86,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("getInstanceGroup", String.class)); + Invokable method = method(VMGroupAsyncClient.class, "getInstanceGroup", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -103,7 +104,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class)); + Invokable method = method(VMGroupAsyncClient.class, "createInstanceGroup", String.class, CreateVMGroupOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo")); assertRequestLineEquals(httpRequest, @@ -120,7 +121,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class)); + Invokable method = method(VMGroupAsyncClient.class, "createInstanceGroup", String.class, CreateVMGroupOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo", CreateVMGroupOptions.Builder.account("foo").domainId("42"))); assertRequestLineEquals(httpRequest, @@ -137,7 +138,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("updateInstanceGroup", String.class, UpdateVMGroupOptions[].class)); + Invokable method = method(VMGroupAsyncClient.class, "updateInstanceGroup", String.class, UpdateVMGroupOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, UpdateVMGroupOptions.Builder.name("fred"))); assertRequestLineEquals(httpRequest, @@ -154,7 +155,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("deleteInstanceGroup", String.class)); + Invokable method = method(VMGroupAsyncClient.class, "deleteInstanceGroup", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java index de316b2bb6..47b64808ea 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -31,13 +33,12 @@ import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VirtualMachineAsyncClient} * @@ -48,8 +49,8 @@ import com.google.common.collect.ImmutableList; @Test(groups = "unit", testName = "VirtualMachineAsyncClientTest") public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines", - ListVirtualMachinesOptions[].class)); + Invokable method = method(VirtualMachineAsyncClient.class, "listVirtualMachines", + ListVirtualMachinesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -66,8 +67,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testListVirtualMachinesOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines", - ListVirtualMachinesOptions[].class)); + Invokable method = method(VirtualMachineAsyncClient.class, "listVirtualMachines", + ListVirtualMachinesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListVirtualMachinesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true))); @@ -86,7 +87,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("getVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "getVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -112,8 +113,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest .addQueryParam("templateid", "5").build(); public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", String.class, String.class, - String.class, DeployVirtualMachineOptions[].class)); + Invokable method = method(VirtualMachineAsyncClient.class, "deployVirtualMachineInZone", String.class, String.class, + String.class, DeployVirtualMachineOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, 4, 5)); assertRequestLineEquals(httpRequest, deployVirtualMachine.getRequestLine()); @@ -129,7 +130,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "rebootVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -146,7 +147,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testStartVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("startVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "startVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -163,7 +164,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testStopVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("stopVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "stopVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -180,7 +181,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testResetPasswordForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("resetPasswordForVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "resetPasswordForVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -197,7 +198,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testChangeServiceForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("changeServiceForVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "changeServiceForVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -214,7 +215,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("updateVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "updateVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -231,7 +232,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testDestroyVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("destroyVirtualMachine", String.class)); + Invokable method = method(VirtualMachineAsyncClient.class, "destroyVirtualMachine", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, @@ -248,8 +249,8 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest } public void testAssignVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("assignVirtualMachine", String.class, - AssignVirtualMachineOptions[].class)); + Invokable method = method(VirtualMachineAsyncClient.class, "assignVirtualMachine", String.class, + AssignVirtualMachineOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("abcd", AssignVirtualMachineOptions.Builder.accountInDomain("adrian", "6"))); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java index 9b1c96ab8f..19e2693b7b 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,12 +28,11 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListVolumesOptions; import org.jclouds.http.HttpRequest; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code EventAsyncClient} * @@ -43,7 +44,7 @@ import com.google.common.collect.ImmutableList; public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VolumeAsyncClient.class.getMethod("listVolumes", ListVolumesOptions[].class)); + Invokable method = method(VolumeAsyncClient.class, "listVolumes", ListVolumesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -59,7 +60,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("getVolume", String.class)); + Invokable method = method(VolumeAsyncClient.class, "getVolume", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); assertRequestLineEquals(httpRequest, @@ -83,8 +84,8 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromSnapshotInZone", String.class, String.class, - String.class)); + Invokable method = method(VolumeAsyncClient.class, "createVolumeFromSnapshotInZone", String.class, String.class, + String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-volume", 999L, 111l)); assertRequestLineEquals(httpRequest, createVolumeFromSnapshot.getRequestLine()); @@ -105,8 +106,8 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromDiskOfferingInZone", String.class, String.class, - String.class)); + Invokable method = method(VolumeAsyncClient.class, "createVolumeFromDiskOfferingInZone", String.class, String.class, + String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-volume", 999L, 111L)); @@ -120,7 +121,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("attachVolume", String.class, String.class)); + Invokable method = method(VolumeAsyncClient.class, "attachVolume", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L, 999L)); @@ -135,7 +136,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("detachVolume", String.class)); + Invokable method = method(VolumeAsyncClient.class, "detachVolume", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); @@ -150,7 +151,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("deleteVolume", String.class)); + Invokable method = method(VolumeAsyncClient.class, "deleteVolume", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java index d3d236b69e..c6b887aac6 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.cloudstack.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,14 +28,13 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListZonesOptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ZoneAsyncClient} * @@ -44,7 +45,7 @@ import com.google.common.collect.Iterables; @Test(groups = "unit", testName = "ZoneAsyncClientTest") public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListZones() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class)); + Invokable method = method(ZoneAsyncClient.class, "listZones", ListZonesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -71,7 +72,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class)); + Invokable method = method(ZoneAsyncClient.class, "listZones", ListZonesOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListZonesOptions.Builder.available(true).domainId("5") .id("6"))); @@ -89,7 +90,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ZoneAsyncClient.class.getMethod("getZone", String.class)); + Invokable method = method(ZoneAsyncClient.class, "getZone", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6)); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/internal/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/internal/BaseCloudStackClientLiveTest.java index d4473f09dc..1bda9c5f41 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/internal/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/internal/BaseCloudStackClientLiveTest.java @@ -21,7 +21,7 @@ package org.jclouds.cloudstack.internal; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.get; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Predicates2.retry; import static org.testng.Assert.assertEquals; @@ -86,7 +86,7 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte @Override protected TypeToken viewType() { - return typeTokenOf(CloudStackContext.class); + return typeToken(CloudStackContext.class); } @Override diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java index 9960771441..8e34d9c55a 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.cloudwatch.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -43,7 +43,7 @@ public class CloudWatchRestClientModule extends FormSigningRestClientModule extend @SuppressWarnings("unchecked") public EC2RestClientModule() { // retaining top-level type of EC2Client vs EC2Api until we migrate all functionality up - super(TypeToken.class.cast(typeTokenOf(EC2Client.class)), TypeToken.class.cast(typeTokenOf(EC2AsyncClient.class)), DELEGATE_MAP); + super(TypeToken.class.cast(typeToken(EC2Client.class)), TypeToken.class.cast(typeToken(EC2AsyncClient.class)), DELEGATE_MAP); } protected EC2RestClientModule(TypeToken syncClientType, TypeToken asyncClientType, diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java index 9259e2e5a6..48ac5aaf81 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java @@ -19,6 +19,7 @@ package org.jclouds.ec2.services; import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.executableBy; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -34,13 +35,12 @@ import org.jclouds.ec2.xml.PermissionHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AMIAsyncClient} * @@ -64,8 +64,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, - CreateImageOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -97,8 +97,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, - CreateImageOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() .withDescription("description").noReboot())); @@ -128,8 +128,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, - DescribeImagesOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "describeImagesInRegion", String.class, + DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -163,8 +163,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, - DescribeImagesOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "describeImagesInRegion", String.class, + DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( "1", "2"))); @@ -195,7 +195,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class)); + Invokable method = method(AMIAsyncClient.class, "deregisterImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -226,8 +226,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, - String.class, RegisterImageOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -258,8 +258,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, - String.class, RegisterImageOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() .withDescription("description"))); @@ -293,8 +293,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, - String.class, String.class, RegisterImageBackedByEbsOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -334,8 +334,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, - String.class, String.class, RegisterImageBackedByEbsOptions[].class)); + Invokable method = method(AMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100))); @@ -368,8 +368,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class, - String.class)); + Invokable method = method(AMIAsyncClient.class, "getBlockDeviceMappingsForImageInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -400,7 +400,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class)); + Invokable method = method(AMIAsyncClient.class, "getLaunchPermissionForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -435,8 +435,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion", String.class, - Iterable.class, Iterable.class, String.class)); + Invokable method = method(AMIAsyncClient.class, "addLaunchPermissionsToImageInRegion", String.class, + Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -472,8 +472,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion", String.class, - Iterable.class, Iterable.class, String.class)); + Invokable method = method(AMIAsyncClient.class, "removeLaunchPermissionsFromImageInRegion", String.class, + Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -504,8 +504,8 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class, - String.class)); + Invokable method = method(AMIAsyncClient.class, "resetLaunchPermissionsOnImageInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java index 607c10a355..c748c584d0 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java @@ -20,6 +20,7 @@ package org.jclouds.ec2.services; import static org.jclouds.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones; import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.regions; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -30,12 +31,11 @@ import org.jclouds.ec2.options.DescribeRegionsOptions; import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler; import org.jclouds.ec2.xml.DescribeRegionsResponseHandler; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient} * @@ -47,8 +47,8 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends BaseEC2AsyncClientTest { public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", - String.class, DescribeAvailabilityZonesOptions[].class)); + Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeAvailabilityZonesInRegion", + String.class, DescribeAvailabilityZonesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(Region.US_WEST_1)); assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1"); @@ -64,8 +64,8 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", - String.class, DescribeAvailabilityZonesOptions[].class)); + Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeAvailabilityZonesInRegion", + String.class, DescribeAvailabilityZonesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("us-east-1", availabilityZones("us-east-1a", "us-east-1b"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -82,8 +82,8 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", - DescribeRegionsOptions[].class)); + Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeRegions", + DescribeRegionsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -99,8 +99,8 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", - DescribeRegionsOptions[].class)); + Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeRegions", + DescribeRegionsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(regions(Region.US_EAST_1, Region.US_WEST_1))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java index 01bf8be536..7d988ba642 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java @@ -20,6 +20,7 @@ package org.jclouds.ec2.services; import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy; import static org.jclouds.ec2.options.DetachVolumeOptions.Builder.fromInstance; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -36,13 +37,12 @@ import org.jclouds.ec2.xml.SnapshotHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticBlockStoreAsyncClient} * @@ -53,7 +53,7 @@ import com.google.common.collect.Lists; public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest { public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion", String.class, String.class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "deleteVolumeInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -80,8 +80,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class, - String[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "describeVolumesInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -99,8 +99,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class, - String[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "describeVolumesInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -130,8 +130,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("attachVolumeInRegion", String.class, String.class, - String.class, String.class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "attachVolumeInRegion", String.class, String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", "instanceId", "/device")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -162,8 +162,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class, - boolean.class, DetachVolumeOptions[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "detachVolumeInRegion", String.class, String.class, + boolean.class, DetachVolumeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", false)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -196,8 +196,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class, - boolean.class, DetachVolumeOptions[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "detachVolumeInRegion", String.class, String.class, + boolean.class, DetachVolumeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", true, fromInstance("instanceId").fromDevice( "/device"))); @@ -216,8 +216,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class, - String.class, CreateSnapshotOptions[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "createSnapshotInRegion", String.class, + String.class, CreateSnapshotOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -233,8 +233,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class, - String.class, CreateSnapshotOptions[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "createSnapshotInRegion", String.class, + String.class, CreateSnapshotOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId", CreateSnapshotOptions.Builder .withDescription("description"))); @@ -252,8 +252,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class, - DescribeSnapshotsOptions[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "describeSnapshotsInRegion", String.class, + DescribeSnapshotsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -269,8 +269,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class, - DescribeSnapshotsOptions[].class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "describeSnapshotsInRegion", String.class, + DescribeSnapshotsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ownedBy("o1", "o2").restorableBy("r1", "r2") .snapshotIds("s1", "s2"))); @@ -289,8 +289,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("getCreateVolumePermissionForSnapshotInRegion", - String.class, String.class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "getCreateVolumePermissionForSnapshotInRegion", + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -325,8 +325,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("addCreateVolumePermissionsToSnapshotInRegion", - String.class, Iterable.class, Iterable.class, String.class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "addCreateVolumePermissionsToSnapshotInRegion", + String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "snapshotId")); @@ -363,8 +363,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("removeCreateVolumePermissionsFromSnapshotInRegion", - String.class, Iterable.class, Iterable.class, String.class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "removeCreateVolumePermissionsFromSnapshotInRegion", + String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "snapshotId")); @@ -384,8 +384,8 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("resetCreateVolumePermissionsOnSnapshotInRegion", - String.class, String.class)); + Invokable method = method(ElasticBlockStoreAsyncClient.class, "resetCreateVolumePermissionsOnSnapshotInRegion", + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java index 756223ef75..4ec4da054c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,12 +28,11 @@ import org.jclouds.ec2.xml.DescribeAddressesResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticIPAddressAsyncClient} * @@ -42,8 +43,8 @@ import com.google.common.collect.Lists; public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest { public void testDisassociateAddress() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion", String.class, - String.class)); + Invokable method = method(ElasticIPAddressAsyncClient.class, "disassociateAddressInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -72,8 +73,8 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion", String.class, - String.class, String.class)); + Invokable method = method(ElasticIPAddressAsyncClient.class, "associateAddressInRegion", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1", "me")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -91,7 +92,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion", String.class, String.class)); + Invokable method = method(ElasticIPAddressAsyncClient.class, "releaseAddressInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -107,8 +108,8 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion", String.class, - String[].class)); + Invokable method = method(ElasticIPAddressAsyncClient.class, "describeAddressesInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -124,7 +125,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion", String.class)); + Invokable method = method(ElasticIPAddressAsyncClient.class, "allocateAddressInRegion", String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java index f5f3b9d01f..a6a5aca2ee 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.util.Map; @@ -39,14 +41,13 @@ import org.jclouds.ec2.xml.UnencodeStringValueHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code InstanceAsyncClient} * @@ -56,7 +57,7 @@ import com.google.common.collect.Maps; @Test(groups = "unit", testName = "InstanceAsyncClientTest") public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest { public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); + Invokable method = method(InstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -72,7 +73,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); + Invokable method = method(InstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -88,8 +89,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class, - String[].class)); + Invokable method = method(InstanceAsyncClient.class, "terminateInstancesInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -105,8 +106,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, - String.class, int.class, int.class, RunInstancesOptions[].class)); + Invokable method = method(InstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -127,8 +128,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, - String.class, int.class, int.class, RunInstancesOptions[].class)); + Invokable method = method(InstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", "eu-west-1a", "ami-voo", 1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"))); @@ -154,8 +155,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("stopInstancesInRegion", String.class, boolean.class, - String[].class)); + Invokable method = method(InstanceAsyncClient.class, "stopInstancesInRegion", String.class, boolean.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -171,7 +172,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, String[].class)); + Invokable method = method(InstanceAsyncClient.class, "rebootInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -187,7 +188,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, String[].class)); + Invokable method = method(InstanceAsyncClient.class, "startInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -203,7 +204,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, String.class)); + Invokable method = method(InstanceAsyncClient.class, "getUserDataForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -220,8 +221,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class, - String.class)); + Invokable method = method(InstanceAsyncClient.class, "getRootDeviceNameForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -238,7 +239,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, String.class)); + Invokable method = method(InstanceAsyncClient.class, "getRamdiskForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -256,8 +257,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", String.class, - String.class)); + Invokable method = method(InstanceAsyncClient.class, "isApiTerminationDisabledForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -274,7 +275,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion", String.class, String.class)); + Invokable method = method(InstanceAsyncClient.class, "getKernelForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -290,8 +291,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class, - String.class)); + Invokable method = method(InstanceAsyncClient.class, "getInstanceTypeForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -309,8 +310,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion", - String.class, String.class)); + Invokable method = method(InstanceAsyncClient.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion", + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -329,8 +330,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class, - String.class)); + Invokable method = method(InstanceAsyncClient.class, "getBlockDeviceMappingForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -361,8 +362,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion", String.class, String.class, - byte[].class)); + Invokable method = method(InstanceAsyncClient.class, "setUserDataForInstanceInRegion", String.class, String.class, + byte[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -394,8 +395,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion", String.class, String.class, - String.class)); + Invokable method = method(InstanceAsyncClient.class, "setRamdiskForInstanceInRegion", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -427,8 +428,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion", String.class, String.class, - String.class)); + Invokable method = method(InstanceAsyncClient.class, "setKernelForInstanceInRegion", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -461,8 +462,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setApiTerminationDisabledForInstanceInRegion", String.class, - String.class, boolean.class)); + Invokable method = method(InstanceAsyncClient.class, "setApiTerminationDisabledForInstanceInRegion", String.class, + String.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -494,8 +495,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion", String.class, - String.class, String.class)); + Invokable method = method(InstanceAsyncClient.class, "setInstanceTypeForInstanceInRegion", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -528,8 +529,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setInstanceInitiatedShutdownBehaviorForInstanceInRegion", - String.class, String.class, InstanceInitiatedShutdownBehavior.class)); + Invokable method = method(InstanceAsyncClient.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion", + String.class, String.class, InstanceInitiatedShutdownBehavior.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -548,8 +549,8 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setBlockDeviceMappingForInstanceInRegion", String.class, - String.class, Map.class)); + Invokable method = method(InstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class, + String.class, Map.class); Map mapping = Maps.newLinkedHashMap(); mapping.put("/dev/sda1", new BlockDevice("vol-test1", true)); @@ -574,7 +575,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getConsoleOutputForInstanceInRegion", String.class, String.class)); + Invokable method = method(InstanceAsyncClient.class, "getConsoleOutputForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java index ac12ef0971..d4f6341246 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java @@ -18,18 +18,19 @@ */ package org.jclouds.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code KeyPairAsyncClient} * @@ -40,7 +41,7 @@ import com.google.common.collect.Lists; public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest { public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class)); + Invokable method = method(KeyPairAsyncClient.class, "deleteKeyPairInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -56,7 +57,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class)); + Invokable method = method(KeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -72,7 +73,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class)); + Invokable method = method(KeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java index c7b98c5da3..0b31885a61 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -28,12 +30,11 @@ import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SecurityGroupAsyncClient} * @@ -44,8 +45,8 @@ import com.google.common.collect.Lists; public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest { public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion", String.class, - String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "deleteSecurityGroupInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -74,8 +75,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion", String.class, - String.class, String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "createSecurityGroupInRegion", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -93,8 +94,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class, - String[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "describeSecurityGroupsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -110,8 +111,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class, - String[].class)); + Invokable method = method(SecurityGroupAsyncClient.class, "describeSecurityGroupsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -127,8 +128,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class, - String.class, UserIdGroupPair.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", String.class, + String.class, UserIdGroupPair.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"))); @@ -163,8 +164,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class, - String.class, IpProtocol.class, int.class, int.class, String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", String.class, + String.class, IpProtocol.class, int.class, int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -181,8 +182,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, - String.class, UserIdGroupPair.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + String.class, UserIdGroupPair.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"))); @@ -217,8 +218,8 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, - String.class, IpProtocol.class, int.class, int.class, String.class)); + Invokable method = method(SecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + String.class, IpProtocol.class, int.class, int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java index 7f7bff0bca..d639160990 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,12 +28,11 @@ import org.jclouds.ec2.xml.BundleTaskHandler; import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code WindowsAsyncClient} * @@ -58,8 +59,8 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class, - String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class)); + Invokable method = method(WindowsAsyncClient.class, "bundleInstanceInRegion", String.class, String.class, + String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class); GeneratedHttpRequest request = processor .createRequest( method, @@ -102,8 +103,8 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class, - String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class)); + Invokable method = method(WindowsAsyncClient.class, "bundleInstanceInRegion", String.class, String.class, + String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class); GeneratedHttpRequest request = processor .createRequest( method, @@ -130,7 +131,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class)); + Invokable method = method(WindowsAsyncClient.class, "describeBundleTasksInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -146,7 +147,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class)); + Invokable method = method(WindowsAsyncClient.class, "describeBundleTasksInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java index 911bc4b0b5..bdd23b32a6 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java @@ -21,7 +21,7 @@ package org.jclouds.elasticstack; import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.elasticstack.reference.ElasticStackConstants.PROPERTY_VNC_PASSWORD; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -87,7 +87,7 @@ public class ElasticStackApiMetadata extends BaseRestApiMetadata { .version("1.0") .defaultEndpoint("https://api-lon-p.elastichosts.com") .defaultProperties(ElasticStackApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(ElasticStackRestClientModule.class, ElasticStackComputeServiceContextModule.class)); } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java index 122eb6606a..e2f2b0f4e5 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.elasticstack; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -45,14 +46,13 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticStackAsyncClient} * @@ -62,7 +62,7 @@ import com.google.common.collect.Iterables; @Test(groups = "unit", testName = "ElasticStackAsyncClientTest") public class ElasticStackAsyncClientTest extends BaseAsyncClientTest { public void testListServers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServers")); + Invokable method = method(ElasticStackAsyncClient.class, "listServers"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1"); @@ -89,7 +89,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServerInfo")); + Invokable method = method(ElasticStackAsyncClient.class, "listServerInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/info HTTP/1.1"); @@ -104,7 +104,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getServerInfo", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "getServerInfo", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/uuid/info HTTP/1.1"); @@ -120,7 +120,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createAndStartServer", Server.class)); + Invokable method = method(ElasticStackAsyncClient.class, "createAndStartServer", Server.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( BindServerToPlainTextStringTest.SERVER)); @@ -137,7 +137,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createServer", Server.class)); + Invokable method = method(ElasticStackAsyncClient.class, "createServer", Server.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( BindServerToPlainTextStringTest.SERVER)); @@ -154,7 +154,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class)); + Invokable method = method(ElasticStackAsyncClient.class, "setServerConfiguration", String.class, Server.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", BindServerToPlainTextStringTest.SERVER)); @@ -171,7 +171,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyServer", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "destroyServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/destroy HTTP/1.1"); @@ -187,7 +187,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("startServer", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "startServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/start HTTP/1.1"); @@ -203,7 +203,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("stopServer", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "stopServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/stop HTTP/1.1"); @@ -219,7 +219,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("shutdownServer", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "shutdownServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/shutdown HTTP/1.1"); @@ -235,7 +235,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("resetServer", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "resetServer", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/reset HTTP/1.1"); @@ -251,7 +251,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDrives")); + Invokable method = method(ElasticStackAsyncClient.class, "listDrives"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1"); @@ -278,7 +278,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDriveInfo")); + Invokable method = method(ElasticStackAsyncClient.class, "listDriveInfo"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/info HTTP/1.1"); @@ -293,7 +293,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getDriveInfo", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "getDriveInfo", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/uuid/info HTTP/1.1"); @@ -309,7 +309,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createDrive", Drive.class)); + Invokable method = method(ElasticStackAsyncClient.class, "createDrive", Drive.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( new CreateDriveRequest.Builder().name("foo").size(10000l).build())); @@ -326,7 +326,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class)); + Invokable method = method(ElasticStackAsyncClient.class, "setDriveData", String.class, DriveData.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", new DriveData.Builder().name("foo").size(10000l).tags(ImmutableList.of("production", "candy")).build())); @@ -343,7 +343,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyDrive", String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "destroyDrive", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/uuid/destroy HTTP/1.1"); @@ -359,7 +359,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class)); + Invokable method = method(ElasticStackAsyncClient.class, "imageDrive", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "200")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100 HTTP/1.1"); @@ -375,8 +375,8 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class, - ImageConversionType.class)); + Invokable method = method(ElasticStackAsyncClient.class, "imageDrive", String.class, String.class, + ImageConversionType.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "200", ImageConversionType.GUNZIP)); @@ -393,7 +393,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("readDrive", String.class, long.class, long.class)); + Invokable method = method(ElasticStackAsyncClient.class, "readDrive", String.class, long.class, long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", 1024, 2048)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/read/1024/2048 HTTP/1.1"); @@ -408,7 +408,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class)); + Invokable method = method(ElasticStackAsyncClient.class, "writeDrive", String.class, Payload.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", Payloads.newStringPayload("foo"))); @@ -424,7 +424,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class, long.class)); + Invokable method = method(ElasticStackAsyncClient.class, "writeDrive", String.class, Payload.class, long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", Payloads.newStringPayload("foo"), 2048)); diff --git a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java index 9947f07757..d9cb4bf19b 100644 --- a/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java +++ b/apis/openstack-cinder/src/main/java/org/jclouds/openstack/cinder/v1/config/CinderRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.cinder.v1.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Map; @@ -68,7 +68,7 @@ public class CinderRestClientModule syncClientType, TypeToken asyncClientType, Map, Class> sync2Async) { diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java index a03933e505..2cd6307c7f 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.keystone.v2_0.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Suppliers2.getLastValueInMap; import java.net.URI; @@ -91,7 +91,7 @@ public class KeystoneRestClientModule syncApiType, TypeToken asyncApiType, Map, Class> sync2Async) { diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java index 4fbead7325..0f99fd13aa 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java @@ -1,5 +1,6 @@ package org.jclouds.openstack.v2_0.functions; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -24,7 +25,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; -import com.google.common.reflect.Invokable; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; @@ -66,15 +66,13 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio } InvocationSuccess getFloatingIPExtension(List args) throws SecurityException, NoSuchMethodException { - return InvocationSuccess.create(Invocation.create( - Invokable.from(NovaAsyncApi.class.getDeclaredMethod("getFloatingIPExtensionForZone", String.class)), - args), "foo"); + return InvocationSuccess.create( + Invocation.create(method(NovaAsyncApi.class, "getFloatingIPExtensionForZone", String.class), args), "foo"); } InvocationSuccess getKeyPairExtension(List args) throws SecurityException, NoSuchMethodException { - return InvocationSuccess.create(Invocation.create( - Invokable.from(NovaAsyncApi.class.getDeclaredMethod("getKeyPairExtensionForZone", String.class)), - args), "foo"); + return InvocationSuccess.create( + Invocation.create(method(NovaAsyncApi.class, "getKeyPairExtensionForZone", String.class), args), "foo"); } public void testPresentWhenExtensionsIncludeNamespaceFromAnnotationAbsentWhenNot() throws SecurityException, NoSuchMethodException { diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java index 612c352080..66ac14b333 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.nova.ec2.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -79,7 +79,7 @@ public class NovaEC2RestClientModule extends EC2RestClientModule>builder() .add(KeystoneAuthenticationModule.class) .add(ZoneModule.class) diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java index 875f653a42..d81675114e 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java @@ -17,8 +17,7 @@ * under the License. */ package org.jclouds.openstack.nova.v2_0.config; - -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Map; @@ -121,7 +120,7 @@ public class NovaRestClientModule ext @SuppressWarnings("unchecked") public NovaRestClientModule() { - super(TypeToken.class.cast(typeTokenOf(NovaApi.class)), TypeToken.class.cast(typeTokenOf(NovaAsyncApi.class)), DELEGATE_MAP); + super(TypeToken.class.cast(typeToken(NovaApi.class)), TypeToken.class.cast(typeToken(NovaAsyncApi.class)), DELEGATE_MAP); } protected NovaRestClientModule(TypeToken syncClientType, TypeToken asyncClientType, diff --git a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApiMetadata.java b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApiMetadata.java index 3845dfc89a..dc56ca9a46 100644 --- a/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApiMetadata.java +++ b/apis/rackspace-cloudloadbalancers/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersApiMetadata.java @@ -17,12 +17,11 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -86,7 +85,7 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata { .version("1.0") .defaultEndpoint("https://identity.api.rackspacecloud.com/v2.0/") .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties()) - .view(typeTokenOf(LoadBalancerServiceContext.class)) + .view(typeToken(LoadBalancerServiceContext.class)) .defaultModules( ImmutableSet.> of( CloudIdentityAuthenticationModule.class, diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java index 1fdc07e64e..393102a348 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java @@ -27,7 +27,7 @@ import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; @@ -116,7 +116,7 @@ public class S3ApiMetadata extends BaseRestApiMetadata { .version(S3AsyncClient.VERSION) .defaultProperties(S3ApiMetadata.defaultProperties()) .context(CONTEXT_TOKEN) - .view(typeTokenOf(S3BlobStoreContext.class)) + .view(typeToken(S3BlobStoreContext.class)) .defaultModules(ImmutableSet.>of(S3RestClientModule.class, S3BlobStoreContextModule.class)); } diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java index 41e7458e01..fef88f7ecc 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java @@ -20,7 +20,7 @@ package org.jclouds.s3.blobstore; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; import javax.inject.Inject; import javax.inject.Singleton; @@ -39,7 +39,6 @@ import org.jclouds.s3.options.PutObjectOptions; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; -import com.google.common.reflect.TypeToken; /** * @@ -62,12 +61,9 @@ public class S3BlobRequestSigner implements BlobRequest this.processor = checkNotNull(processor, "processor"); this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - TypeToken interfaceType = typeTokenOf(interfaceClass); - this.getMethod = interfaceType.method(interfaceClass.getMethod("getObject", String.class, String.class, - GetOptions[].class)); - this.deleteMethod = interfaceType.method(interfaceClass.getMethod("deleteObject", String.class, String.class)); - this.createMethod = interfaceType.method(interfaceClass.getMethod("putObject", String.class, S3Object.class, - PutObjectOptions[].class)); + this.getMethod = method(interfaceClass, "getObject", String.class, String.class, GetOptions[].class); + this.deleteMethod = method(interfaceClass, "deleteObject", String.class, String.class); + this.createMethod = method(interfaceClass, "putObject", String.class, S3Object.class, PutObjectOptions[].class); } @Override diff --git a/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java b/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java index 7b8075d4c6..2f3f2d7b09 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java +++ b/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java @@ -17,8 +17,7 @@ * under the License. */ package org.jclouds.s3.config; - -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Set; @@ -77,7 +76,7 @@ public class S3RestClientModule ext @SuppressWarnings("unchecked") public S3RestClientModule() { - this(TypeToken.class.cast(typeTokenOf(S3Client.class)), TypeToken.class.cast(typeTokenOf(S3AsyncClient.class))); + this(TypeToken.class.cast(typeToken(S3Client.class)), TypeToken.class.cast(typeToken(S3AsyncClient.class))); } protected S3RestClientModule(TypeToken syncClientType, TypeToken asyncClientType) { diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java index debed7a9b7..f5fdcbfb6e 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.s3; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -72,7 +73,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; import com.google.inject.Module; - /** * Tests behavior of {@code S3AsyncClient} * @@ -85,15 +85,15 @@ public abstract class S3AsyncClientTest extends BaseS3A protected String url = "s3.amazonaws.com"; public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, - PutBucketOptions[].class)); + Invokable method = method(S3AsyncClient.class, "putBucketInRegion", String.class, String.class, + PutBucketOptions[].class); for (String region : Region.DEFAULT_S3) { processor.createRequest(method, ImmutableList. of(region, "bucket-" + region)); } } public void testGetBucketLocation() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)); + Invokable method = method(S3AsyncClient.class, "getBucketLocation", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1"); @@ -116,7 +116,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testGetBucketPayer() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketPayer", String.class)); + Invokable method = method(S3AsyncClient.class, "getBucketPayer", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?requestPayment HTTP/1.1"); @@ -131,7 +131,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testSetBucketPayerOwner() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class)); + Invokable method = method(S3AsyncClient.class, "setBucketPayer", String.class, Payer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", Payer.BUCKET_OWNER)); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1"); @@ -147,7 +147,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testSetBucketPayerRequester() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class)); + Invokable method = method(S3AsyncClient.class, "setBucketPayer", String.class, Payer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", Payer.REQUESTER)); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1"); @@ -163,8 +163,8 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testListBucket() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("listBucket", String.class, - ListBucketOptions[].class)); + Invokable method = method(S3AsyncClient.class, "listBucket", String.class, + ListBucketOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/ HTTP/1.1"); @@ -179,7 +179,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testBucketExists() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("bucketExists", String.class)); + Invokable method = method(S3AsyncClient.class, "bucketExists", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?max-keys=0 HTTP/1.1"); @@ -196,16 +196,16 @@ public abstract class S3AsyncClientTest extends BaseS3A @Test(expectedExceptions = IllegalArgumentException.class) public void testCopyObjectInvalidName() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class, - String.class, CopyObjectOptions[].class)); + Invokable method = method(S3AsyncClient.class, "copyObject", String.class, String.class, String.class, + String.class, CopyObjectOptions[].class); processor.createRequest(method, ImmutableList. of("sourceBucket", "sourceObject", "destinationBucket", "destinationObject")); } public void testCopyObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class, - String.class, CopyObjectOptions[].class)); + Invokable method = method(S3AsyncClient.class, "copyObject", String.class, String.class, String.class, + String.class, CopyObjectOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("sourceBucket", "sourceObject", "destinationbucket", "destinationObject")); @@ -222,7 +222,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testDeleteBucketIfEmpty() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("deleteBucketIfEmpty", String.class)); + Invokable method = method(S3AsyncClient.class, "deleteBucketIfEmpty", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "DELETE https://bucket." + url + "/ HTTP/1.1"); @@ -237,7 +237,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testDeleteObject() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class)); + Invokable method = method(S3AsyncClient.class, "deleteObject", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "DELETE https://bucket." + url + "/object HTTP/1.1"); @@ -253,7 +253,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testGetBucketACL() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketACL", String.class)); + Invokable method = method(S3AsyncClient.class, "getBucketACL", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?acl HTTP/1.1"); @@ -269,7 +269,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testGetObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class)); + Invokable method = method(S3AsyncClient.class, "getObject", String.class, String.class, GetOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "GET https://bucket." + url + "/object HTTP/1.1"); @@ -285,7 +285,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testGetObjectACL() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getObjectACL", String.class, String.class)); + Invokable method = method(S3AsyncClient.class, "getObjectACL", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "GET https://bucket." + url + "/object?acl HTTP/1.1"); @@ -301,7 +301,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testObjectExists() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("objectExists", String.class, String.class)); + Invokable method = method(S3AsyncClient.class, "objectExists", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "HEAD https://bucket." + url + "/object HTTP/1.1"); @@ -317,7 +317,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testHeadObject() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("headObject", String.class, String.class)); + Invokable method = method(S3AsyncClient.class, "headObject", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "HEAD https://bucket." + url + "/object HTTP/1.1"); @@ -332,7 +332,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testListOwnedBuckets() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("listOwnedBuckets")); + Invokable method = method(S3AsyncClient.class, "listOwnedBuckets"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://" + url + "/ HTTP/1.1"); @@ -347,12 +347,12 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testNewS3Object() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("newS3Object")); + Invokable method = method(S3AsyncClient.class, "newS3Object"); assertEquals(method.getReturnType().getRawType(), S3Object.class); } public void testPutBucketACL() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class)); + Invokable method = method(S3AsyncClient.class, "putBucketACL", String.class, AccessControlList.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", AccessControlList.fromCannedAccessPolicy( CannedAccessPolicy.PRIVATE, "1234"))); @@ -374,8 +374,8 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testPutBucketDefault() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, - PutBucketOptions[].class)); + Invokable method = method(S3AsyncClient.class, "putBucketInRegion", String.class, String.class, + PutBucketOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "bucket")); assertRequestLineEquals(request, "PUT https://bucket." + url + "/ HTTP/1.1"); @@ -392,8 +392,7 @@ public abstract class S3AsyncClientTest extends BaseS3A public void testPutObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class - .getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class)); + Invokable method = method(S3AsyncClient.class, "putObject", String.class, S3Object.class, PutObjectOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", blobToS3Object .apply(BindBlobToMultipartFormTest.TEST_BLOB))); @@ -409,8 +408,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testPutObjectACL() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class - .getMethod("putObjectACL", String.class, String.class, AccessControlList.class)); + Invokable method = method(S3AsyncClient.class, "putObjectACL", String.class, String.class, AccessControlList.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "key", AccessControlList.fromCannedAccessPolicy( CannedAccessPolicy.PRIVATE, "1234"))); @@ -431,7 +429,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testGetBucketLogging() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLogging", String.class)); + Invokable method = method(S3AsyncClient.class, "getBucketLogging", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?logging HTTP/1.1"); @@ -446,7 +444,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testDisableBucketLogging() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("disableBucketLogging", String.class)); + Invokable method = method(S3AsyncClient.class, "disableBucketLogging", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1"); @@ -462,7 +460,7 @@ public abstract class S3AsyncClientTest extends BaseS3A } public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("enableBucketLogging", String.class, BucketLogging.class)); + Invokable method = method(S3AsyncClient.class, "enableBucketLogging", String.class, BucketLogging.class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet . of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))))); diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java index 148b932075..f607aaa560 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java @@ -17,7 +17,7 @@ * under the License. */ package org.jclouds.s3.binders; - +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; import java.io.IOException; @@ -42,7 +42,7 @@ public class BindAsHostPrefixIfConfiguredNoPathTest extends BaseS3AsyncClientTes public void testBucketWithHostnameStyle() throws IOException, SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class)); + Invokable method = method(S3AsyncClient.class, "deleteObject", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("testbucket.example.com", "test.jpg")); assertRequestLineEquals(request, "DELETE https://s3.amazonaws.com/testbucket.example.com/test.jpg HTTP/1.1"); } diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java index d1687ff39e..92b9df9aa3 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.s3.binders; +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_SERVICE_PATH; import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; import static org.testng.Assert.assertEquals; @@ -33,7 +34,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests behavior of {@code BindAsHostPrefixIfConfigured} * @@ -61,7 +61,7 @@ public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class)); + Invokable method = method(S3AsyncClient.class, "deleteObject", String.class, String.class); request = processor.createRequest(method, ImmutableList. of("testbucket.example.com", "test.jpg")); assertRequestLineEquals(request, "DELETE http://euc/services/Walrus/testbucket.example.com/test.jpg HTTP/1.1"); diff --git a/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java b/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java index 1885e738af..85dcdd828c 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java @@ -17,12 +17,12 @@ * under the License. */ package org.jclouds.s3.fallbacks; - import static com.google.common.util.concurrent.Futures.getUnchecked; import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertFalse; import org.jclouds.aws.AWSResponseException; @@ -35,7 +35,6 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * @author Adrian Cole @@ -51,8 +50,8 @@ public class FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTes .method("PUT") .endpoint("https://adriancole-blobstore113.s3.amazonaws.com/") .invocation( - Invocation.create(Invokable.from(S3Client.class.getMethod("putBucketInRegion", String.class, - String.class, PutBucketOptions[].class)), Lists. newArrayList(null, "bucket"))).build(); + Invocation.create(method(S3Client.class, "putBucketInRegion", String.class, + String.class, PutBucketOptions[].class), Lists. newArrayList(null, "bucket"))).build(); } @Test diff --git a/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java b/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java index 9c29bfd233..a95b92a7ff 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java @@ -19,6 +19,7 @@ package org.jclouds.s3.filters; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.util.Properties; @@ -41,8 +42,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.TreeMultimap; -import com.google.common.reflect.Invokable; - /** * Tests behavior of {@code RequestAuthorizeSignature} * @@ -88,7 +87,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest of("bucket")); StringBuilder builder = new StringBuilder(); filter.appendBucketName(request, builder); @@ -105,7 +104,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest of("bucket", AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PRIVATE, "1234"))); } @@ -121,7 +120,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest of("bucket", object)); + return processor.createRequest(method(S3AsyncClient.class, "putObject", String.class, + S3Object.class, PutObjectOptions[].class), ImmutableList. of("bucket", object)); } @Test void testAppendBucketNameURIHost() throws SecurityException, NoSuchMethodException { GeneratedHttpRequest request = processor.createRequest( - Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)), + method(S3AsyncClient.class, "getBucketLocation", String.class), ImmutableList. of("bucket")); assertEquals(request.getEndpoint().getHost(), "bucket.s3.amazonaws.com"); } diff --git a/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSRestClientModule.java b/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSRestClientModule.java index 3f9293f80f..90652338e5 100644 --- a/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSRestClientModule.java +++ b/apis/sqs/src/main/java/org/jclouds/sqs/config/SQSRestClientModule.java @@ -18,7 +18,8 @@ */ package org.jclouds.sqs.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; + +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -56,7 +57,7 @@ public class SQSRestClientModule extends FormSigningRestClientModule>builder() .add(StorageEndpointModule.class) diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java index e046d7ee50..2eb3719cab 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java @@ -25,7 +25,7 @@ import static com.google.common.io.BaseEncoding.base16; import static com.google.common.io.ByteStreams.readBytes; import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; import static org.jclouds.crypto.Macs.asByteProcessor; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.util.Strings2.toInputStream; import java.io.IOException; @@ -56,9 +56,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.io.ByteProcessor; import com.google.common.reflect.Invokable; -import com.google.common.reflect.TypeToken; import com.google.inject.Provider; -import com.google.inject.TypeLiteral; /** * @author Adrian Cole @@ -89,7 +87,7 @@ public class SwiftBlobSigner implements BlobRe protected SwiftBlobSigner(BlobToObject blobToObject, BlobToHttpGetOptions blob2HttpGetOptions, Crypto crypto, @TimeStamp Provider unixEpochTimestampProvider, @TemporaryUrlKey Supplier temporaryUrlKeySupplier, RestAnnotationProcessor processor, - TypeLiteral interfaceType) throws SecurityException, NoSuchMethodException { + Class ownerType) throws SecurityException, NoSuchMethodException { this.processor = checkNotNull(processor, "processor"); this.crypto = checkNotNull(crypto, "crypto"); @@ -98,14 +96,9 @@ public class SwiftBlobSigner implements BlobRe this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - - TypeToken owner = typeTokenOf(interfaceType.getType()); - this.getMethod = owner.method(interfaceType.getRawType().getMethod("getObject", String.class, String.class, - GetOptions[].class)); - this.deleteMethod = owner - .method(interfaceType.getRawType().getMethod("removeObject", String.class, String.class)); - this.createMethod = owner.method(interfaceType.getRawType().getMethod("putObject", String.class, - SwiftObject.class)); + this.getMethod = method(ownerType, "getObject", String.class, String.class, GetOptions[].class); + this.deleteMethod = method(ownerType, "removeObject", String.class, String.class); + this.createMethod = method(ownerType, "putObject", String.class, SwiftObject.class); } @Override diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftKeystoneRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftKeystoneRestClientModule.java index b8586f8584..7f9f9c4c8f 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftKeystoneRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftKeystoneRestClientModule.java @@ -1,6 +1,6 @@ package org.jclouds.openstack.swift.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; @@ -19,7 +19,7 @@ import com.google.inject.Scopes; public class SwiftKeystoneRestClientModule extends SwiftRestClientModule { public SwiftKeystoneRestClientModule() { - super(typeTokenOf(SwiftKeystoneClient.class), typeTokenOf(SwiftKeystoneAsyncClient.class), ImmutableMap + super(typeToken(SwiftKeystoneClient.class), typeToken(SwiftKeystoneAsyncClient.class), ImmutableMap ., Class> of()); } diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java index 141f9fe10a..d997716654 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java @@ -17,7 +17,7 @@ * under the License. */ package org.jclouds.openstack.swift.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Suppliers2.getLastValueInMap; import java.net.URI; @@ -63,8 +63,8 @@ public class SwiftRestClientModule, Class> of()); + this(TypeToken.class.cast(typeToken(SwiftClient.class)), TypeToken.class.cast(typeToken(SwiftAsyncClient.class)), + ImmutableMap., Class> of()); } protected SwiftRestClientModule(TypeToken syncClientType, TypeToken asyncClientType, diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java index 9503cbac6b..93001c826f 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.openstack.swift.internal; +import static org.jclouds.reflect.Reflection2.method; + import java.net.URI; import java.util.List; @@ -31,7 +33,6 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.base.Throwables; -import com.google.common.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; @@ -45,13 +46,11 @@ public class BasePayloadTest { protected GeneratedHttpRequest requestForArgs(List args) { try { - Invocation invocation = Invocation.create(Invokable.from(String.class.getDeclaredMethod("toString")), args); + Invocation invocation = Invocation.create(method(String.class, "toString"), args); return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) .invocation(invocation).build(); } catch (SecurityException e) { throw Throwables.propagate(e); - } catch (NoSuchMethodException e) { - throw Throwables.propagate(e); } } } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java index 8060c64cc3..ee023b3f99 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java @@ -17,12 +17,11 @@ * under the License. */ package org.jclouds.vcloud; - import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; @@ -102,7 +101,7 @@ public class VCloudApiMetadata extends BaseRestApiMetadata { .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.0") .defaultProperties(VCloudApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, VCloudComputeServiceContextModule.class)); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java index 6241fc2f56..f93ef782a1 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java @@ -17,7 +17,7 @@ * under the License. */ package org.jclouds.vcloud; - +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -26,13 +26,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.xml.SupportedVersionsHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VCloudVersionsAsyncClient} @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableList; public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest { public void testVersions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions")); + Invokable method = method(VCloudVersionsAsyncClient.class, "getSupportedVersions"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java index d487459dd4..074493bdc5 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java @@ -18,12 +18,13 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.options.CatalogItemOptions; @@ -32,7 +33,7 @@ import org.jclouds.vcloud.xml.CatalogItemHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code CatalogAsyncClient} * @@ -44,7 +45,7 @@ import com.google.common.collect.ImmutableList; public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest { public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalog", URI.class)); + Invokable method = method(CatalogAsyncClient.class, "getCatalog", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))); @@ -60,7 +61,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class)); + Invokable method = method(CatalogAsyncClient.class, "findCatalogInOrgNamed", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1"); @@ -75,7 +76,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalogItem", URI.class)); + Invokable method = method(CatalogAsyncClient.class, "getCatalogItem", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))); @@ -91,8 +92,8 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, - String.class, String.class)); + Invokable method = method(CatalogAsyncClient.class, "findCatalogItemInOrgCatalogNamed", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1"); @@ -108,8 +109,8 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class, - URI.class, String.class, CatalogItemOptions[].class)); + Invokable method = method(CatalogAsyncClient.class, "addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class, + URI.class, String.class, CatalogItemOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("http://fooentity"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder .description("mydescription"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java index 66a8644c7a..ac3e0bdab5 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java @@ -18,19 +18,20 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.OrgNetworkHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NetworkAsyncClient} * @@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableList; public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest { public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", URI.class)); + Invokable method = method(NetworkAsyncClient.class, "getNetwork", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/network/2"))); @@ -58,8 +59,8 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class, - String.class)); + Invokable method = method(NetworkAsyncClient.class, "findNetworkInOrgVDCNamed", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java index 4591a89eec..6561f283c4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java @@ -18,13 +18,14 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.OrgHandler; @@ -32,7 +33,7 @@ import org.jclouds.vcloud.xml.OrgListHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OrgAsyncClient} * @@ -44,7 +45,7 @@ import com.google.common.collect.ImmutableList; public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest { public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(OrgAsyncClient.class.getMethod("listOrgs")); + Invokable method = method(OrgAsyncClient.class, "listOrgs"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1"); @@ -59,7 +60,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(OrgAsyncClient.class.getMethod("getOrg", URI.class)); + Invokable method = method(OrgAsyncClient.class, "getOrg", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/org/1"))); @@ -75,7 +76,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(OrgAsyncClient.class.getMethod("findOrgNamed", String.class)); + Invokable method = method(OrgAsyncClient.class, "findOrgNamed", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java index d9478049b4..d7f30228d9 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java @@ -18,13 +18,14 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.TaskHandler; @@ -32,7 +33,7 @@ import org.jclouds.vcloud.xml.TasksListHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TaskAsyncClient} * @@ -44,7 +45,7 @@ import com.google.common.collect.ImmutableList; public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest { public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TaskAsyncClient.class.getMethod("getTasksList", URI.class)); + Invokable method = method(TaskAsyncClient.class, "getTasksList", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"))); @@ -60,7 +61,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class)); + Invokable method = method(TaskAsyncClient.class, "findTasksListInOrgNamed", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1"); @@ -75,7 +76,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("getTask", URI.class)); + Invokable method = method(TaskAsyncClient.class, "getTask", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/task/1"))); @@ -91,7 +92,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("cancelTask", URI.class)); + Invokable method = method(TaskAsyncClient.class, "cancelTask", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/task/1"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java index 4abd506852..5539708f81 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; @@ -25,7 +27,6 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; @@ -35,7 +36,7 @@ import org.jclouds.vcloud.xml.VAppHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VAppAsyncClient} * @@ -47,8 +48,8 @@ import com.google.common.collect.ImmutableList; public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest { public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class, - CloneVAppOptions[].class)); + Invokable method = method(VAppAsyncClient.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class, + CloneVAppOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp")); @@ -67,8 +68,8 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class, - CloneVAppOptions[].class)); + Invokable method = method(VAppAsyncClient.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class, + CloneVAppOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() @@ -88,8 +89,8 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("moveVAppToVDCAndRename", URI.class, URI.class, String.class, - CloneVAppOptions[].class)); + Invokable method = method(VAppAsyncClient.class, "moveVAppToVDCAndRename", URI.class, URI.class, String.class, + CloneVAppOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() @@ -109,7 +110,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("deployVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "deployVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -126,7 +127,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("deployAndPowerOnVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "deployAndPowerOnVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -143,7 +144,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("getVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "getVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -159,7 +160,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("rebootVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "rebootVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -176,7 +177,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("undeployVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "undeployVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -194,7 +195,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("undeployAndSaveStateOfVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "undeployAndSaveStateOfVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -213,7 +214,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("deleteVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "deleteVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -229,7 +230,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("powerOnVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "powerOnVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -246,7 +247,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("powerOffVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "powerOffVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -263,7 +264,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("resetVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "resetVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -280,7 +281,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("suspendVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "suspendVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -297,7 +298,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("shutdownVApp", URI.class)); + Invokable method = method(VAppAsyncClient.class, "shutdownVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java index 731e2e0134..799bbe98c8 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; import java.io.IOException; @@ -26,7 +27,6 @@ import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; import org.jclouds.ovf.xml.EnvelopeHandler; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.domain.network.FenceMode; @@ -41,7 +41,7 @@ import org.jclouds.vcloud.xml.VAppTemplateHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VAppTemplateAsyncClient} * @@ -54,8 +54,8 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class, - URI.class, URI.class, InstantiateVAppTemplateOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "createVAppInVDCByInstantiatingTemplate", String.class, + URI.class, URI.class, InstantiateVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("my-vapp", URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), @@ -79,16 +79,16 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class, - URI.class, URI.class, InstantiateVAppTemplateOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "createVAppInVDCByInstantiatingTemplate", String.class, + URI.class, URI.class, InstantiateVAppTemplateOptions[].class); processor.createRequest(method, ImmutableList. of("CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), addNetworkConfig(new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null)))); } public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class, - String.class, CloneVAppTemplateOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class, + String.class, CloneVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate")); @@ -107,8 +107,8 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class, - String.class, CloneVAppTemplateOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class, + String.class, CloneVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", @@ -128,8 +128,8 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("moveVAppTemplateToVDCAndRename", URI.class, URI.class, - String.class, CloneVAppTemplateOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "moveVAppTemplateToVDCAndRename", URI.class, URI.class, + String.class, CloneVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", @@ -149,8 +149,8 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class, - URI.class, CaptureVAppOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "captureVAppAsTemplateInVDC", URI.class, String.class, + URI.class, CaptureVAppOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))); @@ -170,8 +170,8 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class, - URI.class, CaptureVAppOptions[].class)); + Invokable method = method(VAppTemplateAsyncClient.class, "captureVAppAsTemplateInVDC", URI.class, String.class, + URI.class, CaptureVAppOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions() @@ -191,8 +191,8 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class, - String.class, String.class)); + Invokable method = method(VAppTemplateAsyncClient.class, "findVAppTemplateInOrgCatalogNamed", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "template")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); @@ -207,7 +207,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getVAppTemplate", URI.class)); + Invokable method = method(VAppTemplateAsyncClient.class, "getVAppTemplate", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"))); @@ -223,7 +223,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class)); + Invokable method = method(VAppTemplateAsyncClient.class, "getOvfEnvelopeForVAppTemplate", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java index 7a4398575e..7a2ab4c004 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java @@ -18,13 +18,14 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import java.util.NoSuchElementException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.VDCHandler; @@ -32,7 +33,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VDCAsyncClient} * @@ -45,18 +46,18 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class)); + Invokable method = method(VDCAsyncClient.class, "findVDCInOrgNamed", String.class, String.class); processor.createRequest(method, ImmutableList. of("org", "vdc1")); } @Test(expectedExceptions = NoSuchElementException.class) public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class)); + Invokable method = method(VDCAsyncClient.class, "findVDCInOrgNamed", String.class, String.class); processor.createRequest(method, ImmutableList. of("org1", "vdc")); } public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class)); + Invokable method = method(VDCAsyncClient.class, "findVDCInOrgNamed", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "vdc")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); @@ -71,7 +72,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class)); + Invokable method = method(VDCAsyncClient.class, "findVDCInOrgNamed", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null)); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); @@ -86,7 +87,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VDCAsyncClient.class.getMethod("getVDC", URI.class)); + Invokable method = method(VDCAsyncClient.class, "getVDC", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java index 1278fe6b3c..3bb745f7a8 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; @@ -25,7 +27,6 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnInputStream; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.domain.GuestCustomizationSection; @@ -37,7 +38,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VmAsyncClient} * @@ -49,7 +50,7 @@ import com.google.common.collect.ImmutableList; public class VmAsyncClientTest extends BaseVCloudAsyncClientTest { public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "getScreenThumbnailForVm", URI.class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of(URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); @@ -66,8 +67,8 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest @Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402") public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("updateGuestCustomizationOfVm", GuestCustomizationSection.class, - URI.class)); + Invokable method = method(VmAsyncClient.class, "updateGuestCustomizationOfVm", GuestCustomizationSection.class, + URI.class); GuestCustomizationSection guest = new GuestCustomizationSection(URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection")); guest.setCustomizationScript("cat > /tmp/foo.txt< } public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("updateCPUCountOfVm", int.class, URI.class)); + Invokable method = method(VmAsyncClient.class, "updateCPUCountOfVm", int.class, URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); @@ -106,7 +107,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("updateMemoryMBOfVm", int.class, URI.class)); + Invokable method = method(VmAsyncClient.class, "updateMemoryMBOfVm", int.class, URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(512, URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); @@ -124,7 +125,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("deployVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "deployVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -141,7 +142,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("deployAndPowerOnVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "deployAndPowerOnVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -158,7 +159,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testGetVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("getVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "getVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1"))); @@ -174,7 +175,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("rebootVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "rebootVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -191,7 +192,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("undeployVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "undeployVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -209,7 +210,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("undeployAndSaveStateOfVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "undeployAndSaveStateOfVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -228,7 +229,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("powerOnVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "powerOnVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -245,7 +246,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("powerOffVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "powerOffVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -262,7 +263,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testResetVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("resetVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "resetVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -279,7 +280,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("suspendVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "suspendVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); @@ -296,7 +297,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest } public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VmAsyncClient.class.getMethod("shutdownVm", URI.class)); + Invokable method = method(VmAsyncClient.class, "shutdownVm", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java index cdde41b161..92f5b12cf2 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.internal; +import static org.jclouds.reflect.Reflection2.method; + import java.net.URI; import java.util.List; @@ -28,7 +30,6 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.base.Throwables; -import com.google.common.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; @@ -42,13 +43,11 @@ public class BasePayloadTest { protected GeneratedHttpRequest requestForArgs(List args) { try { - Invocation invocation = Invocation.create(Invokable.from(String.class.getDeclaredMethod("toString")), args); + Invocation invocation = Invocation.create(method(String.class, "toString"), args); return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) .invocation(invocation).build(); } catch (SecurityException e) { throw Throwables.propagate(e); - } catch (NoSuchMethodException e) { - throw Throwables.propagate(e); } } } \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java index ae3dcd6c0e..d414172443 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.vcloud.internal; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -30,7 +31,6 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.endpoints.VCloudLogin; @@ -39,10 +39,10 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; - /** * Tests behavior of {@code VCloudLoginAsyncClient} * @@ -53,7 +53,7 @@ import com.google.inject.Provides; public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest { public void testLogin() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VCloudLoginAsyncClient.class.getMethod("login")); + Invokable method = method(VCloudLoginAsyncClient.class, "login"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); diff --git a/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java b/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java index f6438dc6be..aaafe1ced2 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/util/BlobStoreUtils.java @@ -19,7 +19,6 @@ package org.jclouds.blobstore.util; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.reflect.Reflection2.typeTokenOf; import java.util.List; import java.util.Map; diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index df3a48af7b..e26f2e5631 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -20,7 +20,7 @@ package org.jclouds.blobstore.integration.internal; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Throwables.propagateIfPossible; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -524,7 +524,7 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest viewType() { - return typeTokenOf(BlobStoreContext.class); + return typeToken(BlobStoreContext.class); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java index e85fef0d1a..3e939b8596 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.blobstore.internal; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import org.jclouds.View; import org.jclouds.apis.ApiMetadata; @@ -37,7 +37,7 @@ import com.google.common.reflect.TypeToken; public abstract class BaseBlobStoreApiMetadataTest extends BaseApiMetadataTest { public BaseBlobStoreApiMetadataTest(ApiMetadata toTest) { - super(toTest, ImmutableSet.>of(typeTokenOf(BlobStoreContext.class))); + super(toTest, ImmutableSet.>of(typeToken(BlobStoreContext.class))); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java b/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java index fe9f7a5381..a0ac151cbb 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java @@ -24,6 +24,7 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.jclouds.blobstore.util.BlobStoreUtils.createParentIfNeededAsync; import static org.jclouds.blobstore.util.BlobStoreUtils.getNameFor; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -38,8 +39,6 @@ import org.testng.annotations.Test; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; - /** * Tests behavior of {@code BlobStoreUtils} * @@ -126,13 +125,11 @@ public class BlobStoreUtilsTest { GeneratedHttpRequest requestForEndpointAndArgs(String endpoint, List args) { try { - Invocation invocation = Invocation.create(Invokable.from(String.class.getDeclaredMethod("toString")), args); + Invocation invocation = Invocation.create(method(String.class, "toString"), args); return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create(endpoint)).invocation(invocation) .build(); } catch (SecurityException e) { throw Throwables.propagate(e); - } catch (NoSuchMethodException e) { - throw Throwables.propagate(e); } } } diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java index fda2bfd69c..c0c7c9588f 100644 --- a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java +++ b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.azure.storage.filters; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -40,7 +40,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import com.google.inject.Injector; import com.google.inject.Module; @@ -141,9 +140,9 @@ public class SharedKeyLiteAuthenticationTest { .credentials(ACCOUNT, "credential") .modules( ImmutableSet. of(new MockModule(), new NullLoggingModule(), - new AzureStorageRestClientModule(TypeToken - .of(IntegrationTestClient.class), typeTokenOf(IntegrationTestAsyncClient.class)))) - .buildInjector(); + new AzureStorageRestClientModule( + typeToken(IntegrationTestClient.class), typeToken(IntegrationTestAsyncClient.class)))) + .buildInjector(); filter = injector.getInstance(SharedKeyLiteAuthentication.class); } } diff --git a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java index 87f9bb62da..f88d100472 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.openstack.internal; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.apis.ApiMetadata; @@ -26,14 +28,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; -import com.google.common.reflect.Invokable; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OpenStackAuthAsyncClient} * @@ -44,7 +45,7 @@ import com.google.common.collect.ImmutableList; public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest { public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class)); + Invokable method = method(OpenStackAuthAsyncClient.class, "authenticate", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foo", "bar")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); @@ -58,7 +59,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticateStorage", String.class, String.class)); + Invokable method = method(OpenStackAuthAsyncClient.class, "authenticateStorage", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foo", "bar")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java index 82708e4cbe..a0a6198ecc 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.trmk.vcloud_0_8.internal; +import static org.jclouds.reflect.Reflection2.method; + import java.net.URI; import java.util.List; @@ -25,19 +27,16 @@ import org.jclouds.reflect.Invocation; import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Throwables; -import com.google.common.reflect.Invokable; public class BasePayloadTest { protected GeneratedHttpRequest requestForArgs(List args) { try { - Invocation invocation = Invocation.create(Invokable.from(String.class.getDeclaredMethod("toString")), args); + Invocation invocation = Invocation.create(method(String.class, "toString"), args); return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) .invocation(invocation).build(); } catch (SecurityException e) { throw Throwables.propagate(e); - } catch (NoSuchMethodException e) { - throw Throwables.propagate(e); } } } \ No newline at end of file diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java index 08c8dcc08d..02dd0cdfaa 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.trmk.vcloud_0_8.internal; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -30,7 +31,6 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin; @@ -39,6 +39,7 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; +import com.google.common.reflect.Invokable; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; @@ -54,7 +55,7 @@ import com.google.inject.Provides; public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest { public void testLogin() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkVCloudLoginAsyncClient.class.getMethod("login")); + Invokable method = method(TerremarkVCloudLoginAsyncClient.class, "login"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java index 0164fbfc0c..da46c1ade0 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.trmk.vcloud_0_8.internal; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -26,14 +27,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VCloudVersionsAsyncClient} * @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableList; public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest { public void testVersions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkVCloudVersionsAsyncClient.class.getMethod("getSupportedVersions")); + Invokable method = method(TerremarkVCloudVersionsAsyncClient.class, "getSupportedVersions"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1"); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java index ac6579c31b..36bebc5fa1 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java @@ -1,6 +1,6 @@ package org.jclouds.compute.internal; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import org.jclouds.View; import org.jclouds.apis.ApiMetadata; @@ -19,7 +19,7 @@ import com.google.common.reflect.TypeToken; public abstract class BaseComputeServiceApiMetadataTest extends BaseApiMetadataTest { public BaseComputeServiceApiMetadataTest(ApiMetadata toTest) { - super(toTest, ImmutableSet.>of(typeTokenOf(ComputeServiceContext.class))); + super(toTest, ImmutableSet.>of(typeToken(ComputeServiceContext.class))); } } diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java index 5e281e3e7d..7d3f10f7ad 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.compute.internal; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import org.jclouds.compute.ComputeServiceContext; @@ -31,7 +31,7 @@ public abstract class BaseComputeServiceContextLiveTest extends BaseGenericCompu @Override protected TypeToken viewType() { - return typeTokenOf(ComputeServiceContext.class); + return typeToken(ComputeServiceContext.class); } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java index 681e4edc61..1be08999d6 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java @@ -23,7 +23,7 @@ import static org.jclouds.Constants.PROPERTY_MAX_REDIRECTS; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; import static org.jclouds.abiquo.config.AbiquoProperties.CREDENTIAL_IS_TOKEN; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -91,7 +91,7 @@ public class AbiquoApiMetadata extends BaseRestApiMetadata { .defaultEndpoint("http://localhost/api") .version(AbiquoAsyncApi.API_VERSION) .buildVersion(AbiquoAsyncApi.BUILD_VERSION) - .view(typeTokenOf(AbiquoContext.class)) + .view(typeToken(AbiquoContext.class)) .defaultProperties(AbiquoApiMetadata.defaultProperties()) .defaultModules( ImmutableSet.> of(AbiquoRestClientModule.class, diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java index fd0c20a3d3..e4effc8391 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.abiquo.binders; - +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -60,7 +60,7 @@ public class BindToPathTest { @Test(expectedExceptions = NullPointerException.class) public void testInvalidNullInput() throws SecurityException, NoSuchMethodException { - Invokable withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class)); + Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(new TestDto()))) .method(HttpMethod.GET) @@ -72,7 +72,7 @@ public class BindToPathTest { @Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidInputType() throws SecurityException, NoSuchMethodException { - Invokable withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class)); + Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(new TestDto()))) .method(HttpMethod.GET) @@ -85,7 +85,7 @@ public class BindToPathTest { @Test(expectedExceptions = BindException.class) public void testAnnotationNotPresent() throws SecurityException, NoSuchMethodException { TestDto dto = new TestDto(); - Invokable withoutEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withoutEndpointLink", TestDto.class)); + Invokable withoutEndpointLink = method(TestEndpointLink.class, "withoutEndpointLink", TestDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withoutEndpointLink, ImmutableList. of(dto))) .method(HttpMethod.GET) @@ -98,7 +98,7 @@ public class BindToPathTest { @Test(expectedExceptions = NullPointerException.class) public void testLinkNotPresent() throws SecurityException, NoSuchMethodException { TestDto dto = new TestDto(); - Invokable withUnexistingLink = Invokable.from(TestEndpointLink.class.getMethod("withUnexistingLink", TestDto.class)); + Invokable withUnexistingLink = method(TestEndpointLink.class, "withUnexistingLink", TestDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withUnexistingLink, ImmutableList. of(dto))) .method(HttpMethod.GET) @@ -110,7 +110,7 @@ public class BindToPathTest { public void testBindWithoutParameters() throws SecurityException, NoSuchMethodException { TestDto dto = new TestDto(); - Invokable withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class)); + Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(dto))) .method(HttpMethod.GET) @@ -123,7 +123,7 @@ public class BindToPathTest { public void testBindWithQueryParameters() throws SecurityException, NoSuchMethodException { TestDto dto = new TestDto(); - Invokable withEndpointLink = Invokable.from(TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class)); + Invokable withEndpointLink = method(TestEndpointLink.class, "withEndpointLink", TestDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(dto))) .method(HttpMethod.GET) diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java index ee0231d19a..16f65b02d5 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.abiquo.binders.cloud; - +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -62,8 +62,8 @@ public class BindMoveVolumeToPathTest { } private static GeneratedHttpRequest generatedHttpRequest() throws SecurityException, NoSuchMethodException { - Invokable withEndpointLink = Invokable.from(CloudAsyncApi.class.getMethod("moveVolume", VolumeManagementDto.class, - VirtualDatacenterDto.class)); + Invokable withEndpointLink = method(CloudAsyncApi.class, "moveVolume", VolumeManagementDto.class, + VirtualDatacenterDto.class); return GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(CloudResources.volumePut(), CloudResources.virtualDatacenterPut()))) .method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build(); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java index 49b41d7d00..8842a01bd4 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java @@ -21,6 +21,7 @@ package org.jclouds.abiquo.binders.cloud; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; import static org.jclouds.abiquo.util.Assert.assertPayloadEquals; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; import java.net.URI; @@ -43,7 +44,6 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; - /** * Unit tests for the {@link BindNetworkConfigurationRefToPayload} binder. * @@ -68,8 +68,8 @@ public class BindNetworkConfigurationRefToPayloadTest { public void testInvalidNullInput() throws SecurityException, NoSuchMethodException { VirtualMachineDto vm = CloudResources.virtualMachinePut(); - Invokable method = Invokable.from(TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, - VLANNetworkDto.class)); + Invokable method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, + VLANNetworkDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(method, Lists. newArrayList(vm, null))) .method(HttpMethod.GET) @@ -84,8 +84,8 @@ public class BindNetworkConfigurationRefToPayloadTest { VirtualMachineDto vm = CloudResources.virtualMachinePut(); Object network = new Object(); - Invokable method = Invokable.from(TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, - VLANNetworkDto.class)); + Invokable method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, + VLANNetworkDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(method, ImmutableList. of(vm, network))) .method(HttpMethod.GET) @@ -99,8 +99,8 @@ public class BindNetworkConfigurationRefToPayloadTest { public void testBindNetworkConfigurationRefWithoutVirtualMachine() throws SecurityException, NoSuchMethodException { VLANNetworkDto network = NetworkResources.privateNetworkPut(); - Invokable method = Invokable.from(TestNetworkConfig.class.getMethod("withoutVirtualMachine", - VLANNetworkDto.class)); + Invokable method = method(TestNetworkConfig.class, "withoutVirtualMachine", + VLANNetworkDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(method, ImmutableList. of(network))) .method(HttpMethod.GET) @@ -114,8 +114,8 @@ public class BindNetworkConfigurationRefToPayloadTest { VirtualMachineDto vm = CloudResources.virtualMachinePut(); VLANNetworkDto network = NetworkResources.privateNetworkPut(); - Invokable method = Invokable.from(TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, - VLANNetworkDto.class)); + Invokable method = method(TestNetworkConfig.class, "withAll", VirtualMachineDto.class, + VLANNetworkDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(method, ImmutableList. of(vm, network))) .method(HttpMethod.GET) diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java index e7cd227b2d..d0247f0f9a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.abiquo.binders.infrastructure; - +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.net.URI; @@ -60,8 +60,8 @@ public class BindSupportedDevicesLinkToPathTest { BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - Invokable withEndpointLink = Invokable.from(InfrastructureAsyncApi.class.getMethod( - "listSupportedStorageDevices", DatacenterDto.class)); + Invokable withEndpointLink = method(InfrastructureAsyncApi.class, "listSupportedStorageDevices", + DatacenterDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(datacenter))) @@ -77,8 +77,8 @@ public class BindSupportedDevicesLinkToPathTest { BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - Invokable withEndpointLink = Invokable.from(InfrastructureAsyncApi.class.getMethod( - "listSupportedStorageDevices", DatacenterDto.class)); + Invokable withEndpointLink = method(InfrastructureAsyncApi.class, "listSupportedStorageDevices", + DatacenterDto.class); GeneratedHttpRequest request = GeneratedHttpRequest.builder() .invocation(Invocation.create(withEndpointLink, ImmutableList. of(datacenter))) diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java index 7fb153836e..a109bf63e2 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java @@ -20,6 +20,7 @@ package org.jclouds.abiquo.features; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -37,7 +38,6 @@ import com.abiquo.server.core.enterprise.RolesDto; import com.abiquo.server.core.enterprise.UserDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code AdminAsyncApi} * @@ -49,7 +49,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Role ***********************/ public void testListRoles() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("listRoles")); + Invokable method = method(AdminAsyncApi.class, "listRoles"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/admin/roles HTTP/1.1"); @@ -64,7 +64,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetRoleFromUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("getRole", UserDto.class)); + Invokable method = method(AdminAsyncApi.class, "getRole", UserDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.userPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1"); @@ -79,7 +79,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateRole() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("createRole", RoleDto.class)); + Invokable method = method(AdminAsyncApi.class, "createRole", RoleDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(AdminResources.rolePost())); assertRequestLineEquals(request, "POST http://localhost/api/admin/roles HTTP/1.1"); @@ -95,7 +95,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteRole() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("deleteRole", RoleDto.class)); + Invokable method = method(AdminAsyncApi.class, "deleteRole", RoleDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(AdminResources.rolePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/roles/1 HTTP/1.1"); @@ -110,7 +110,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateRole() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("updateRole", RoleDto.class)); + Invokable method = method(AdminAsyncApi.class, "updateRole", RoleDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(AdminResources.rolePut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/roles/1 HTTP/1.1"); @@ -126,7 +126,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetRoleById() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("getRole", Integer.class)); + Invokable method = method(AdminAsyncApi.class, "getRole", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1"); @@ -141,7 +141,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListPrivilegesByRoles() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("listPrivileges", RoleDto.class)); + Invokable method = method(AdminAsyncApi.class, "listPrivileges", RoleDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(AdminResources.rolePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1/action/privileges HTTP/1.1"); @@ -158,7 +158,7 @@ public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Current User **********************/ public void testGetCurrentUser() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AdminAsyncApi.class.getMethod("getCurrentUser")); + Invokable method = method(AdminAsyncApi.class, "getCurrentUser"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/login HTTP/1.1"); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java index 98617ac2a2..1ce95e0108 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.abiquo.features; - import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -90,7 +90,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Virtual Datacenter ***********************/ public void testListVirtualDatacentersParams() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listVirtualDatacenters", VirtualDatacenterOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(VirtualDatacenterOptions.builder().datacenterId(1) .enterpriseId(1).build())); @@ -107,7 +107,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListVirtualDatacentersNoParams() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listVirtualDatacenters", VirtualDatacenterOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(VirtualDatacenterOptions.builder().build())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters HTTP/1.1"); @@ -122,8 +122,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("createVirtualDatacenter", VirtualDatacenterDto.class, - DatacenterDto.class, EnterpriseDto.class)); + Invokable method = method(CloudAsyncApi.class, "createVirtualDatacenter", VirtualDatacenterDto.class, + DatacenterDto.class, EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPost(), InfrastructureResources.datacenterPut(), EnterpriseResources.enterprisePut())); @@ -141,7 +141,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualDatacenter", Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualDatacenter", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); @@ -156,7 +156,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualDatacenter", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "updateVirtualDatacenter", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); @@ -172,7 +172,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteVirtualDatacenter() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVirtualDatacenter", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "deleteVirtualDatacenter", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); @@ -190,8 +190,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { public void testListAvailablePublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { IpOptions options = IpOptions.builder().limit(5).build(); - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listAvailablePublicIps", VirtualDatacenterDto.class, - IpOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listAvailablePublicIps", VirtualDatacenterDto.class, + IpOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), options)); assertRequestLineEquals(request, @@ -208,8 +208,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { public void testListPurchasedPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { IpOptions options = IpOptions.builder().limit(5).build(); - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listPurchasedPublicIps", VirtualDatacenterDto.class, - IpOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listPurchasedPublicIps", VirtualDatacenterDto.class, + IpOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), options)); assertRequestLineEquals(request, @@ -225,7 +225,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testPurchasePublicIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("purchasePublicIp", PublicIpDto.class)); + Invokable method = method(CloudAsyncApi.class, "purchasePublicIp", PublicIpDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicIpToPurchase())); assertRequestLineEquals(request, @@ -241,7 +241,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testReleasePublicIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("releasePublicIp", PublicIpDto.class)); + Invokable method = method(CloudAsyncApi.class, "releasePublicIp", PublicIpDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicIpToRelease())); assertRequestLineEquals(request, @@ -259,7 +259,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Available templates ***********************/ public void testListAvailableTemplates() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "listAvailableTemplates", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates HTTP/1.1"); @@ -274,8 +274,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListAvailableTemplatesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class, - VirtualMachineTemplateOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listAvailableTemplates", VirtualDatacenterDto.class, + VirtualMachineTemplateOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), VirtualMachineTemplateOptions.builder().hypervisorType(HypervisorType.XENSERVER).categoryName("Firewalls") .idTemplate(1).build())); @@ -295,7 +295,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Storage Tiers ***********************/ public void testListStorageTiers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listStorageTiers", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "listStorageTiers", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/tiers HTTP/1.1"); @@ -310,7 +310,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetStorageTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getStorageTier", VirtualDatacenterDto.class, Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getStorageTier", VirtualDatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/tiers/1 HTTP/1.1"); @@ -325,7 +325,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetDefaultNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getDefaultNetwork", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "getDefaultNetwork", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); @@ -340,8 +340,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testSetDefaultNetworkInternal() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "setDefaultNetwork", VirtualDatacenterDto.class, + VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), NetworkResources.privateNetworkPut())); @@ -361,8 +361,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testSetDefaultNetworkExternal() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "setDefaultNetwork", VirtualDatacenterDto.class, + VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), NetworkResources.externalNetworkPut())); @@ -384,7 +384,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Private Network ***********************/ public void testListPrivateNetworks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listPrivateNetworks", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "listPrivateNetworks", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1"); @@ -399,7 +399,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetPrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getPrivateNetwork", VirtualDatacenterDto.class, Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getPrivateNetwork", VirtualDatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); @@ -414,8 +414,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("createPrivateNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "createPrivateNetwork", VirtualDatacenterDto.class, + VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), NetworkResources.vlanPost())); @@ -432,7 +432,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("updatePrivateNetwork", VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "updatePrivateNetwork", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.privateNetworkPut())); assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); @@ -448,7 +448,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeletePrivateNetwork() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deletePrivateNetwork", VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "deletePrivateNetwork", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.privateNetworkPut())); assertRequestLineEquals(request, @@ -466,7 +466,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Private Network IPs ***********************/ public void testListPrivateNetworkIps() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "listPrivateNetworkIps", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.privateNetworkPut())); assertRequestLineEquals(request, @@ -483,7 +483,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { public void testListPrivateNetworkIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { IpOptions options = IpOptions.builder().startWith(10).build(); - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class, IpOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listPrivateNetworkIps", VLANNetworkDto.class, IpOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.privateNetworkPut(), options)); assertRequestLineEquals(request, @@ -499,7 +499,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetPrivateNetworkIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getPrivateNetworkIp", VLANNetworkDto.class, Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getPrivateNetworkIp", VLANNetworkDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.privateNetworkPut(), 1)); assertRequestLineEquals(request, @@ -517,7 +517,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Virtual Appliance ***********************/ public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualAppliances", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "listVirtualAppliances", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances HTTP/1.1"); @@ -532,7 +532,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualAppliance", VirtualDatacenterDto.class, Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualAppliance", VirtualDatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), 1)); assertRequestLineEquals(request, @@ -548,7 +548,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVirtualApplianceState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualApplianceState", VirtualApplianceDto.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualApplianceState", VirtualApplianceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut())); assertRequestLineEquals(request, @@ -564,8 +564,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("createVirtualAppliance", VirtualDatacenterDto.class, - VirtualApplianceDto.class)); + Invokable method = method(CloudAsyncApi.class, "createVirtualAppliance", VirtualDatacenterDto.class, + VirtualApplianceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), CloudResources.virtualAppliancePost())); @@ -583,7 +583,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualAppliance", VirtualApplianceDto.class)); + Invokable method = method(CloudAsyncApi.class, "updateVirtualAppliance", VirtualApplianceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut())); assertRequestLineEquals(request, @@ -600,7 +600,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteVirtualAppliance() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVirtualAppliance", VirtualApplianceDto.class)); + Invokable method = method(CloudAsyncApi.class, "deleteVirtualAppliance", VirtualApplianceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut())); assertRequestLineEquals(request, @@ -616,8 +616,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deployVirtualAppliance", VirtualApplianceDto.class, - VirtualMachineTaskDto.class)); + Invokable method = method(CloudAsyncApi.class, "deployVirtualAppliance", VirtualApplianceDto.class, + VirtualMachineTaskDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut(), CloudResources.deployOptions())); @@ -635,8 +635,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUndeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("undeployVirtualAppliance", VirtualApplianceDto.class, - VirtualMachineTaskDto.class)); + Invokable method = method(CloudAsyncApi.class, "undeployVirtualAppliance", VirtualApplianceDto.class, + VirtualMachineTaskDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut(), CloudResources.undeployOptions())); @@ -654,7 +654,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVirtualAppliancePrice() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualAppliancePrice", VirtualApplianceDto.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualAppliancePrice", VirtualApplianceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut())); assertRequestLineEquals(request, @@ -672,7 +672,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Virtual Machine ***********************/ public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class)); + Invokable method = method(CloudAsyncApi.class, "listVirtualMachines", VirtualApplianceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut())); assertRequestLineEquals(request, @@ -688,8 +688,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListVirtualMachinesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class, - VirtualMachineOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listVirtualMachines", VirtualApplianceDto.class, + VirtualMachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut(), VirtualMachineOptions.builder().disablePagination().build())); @@ -706,7 +706,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualMachine", VirtualApplianceDto.class, Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualMachine", VirtualApplianceDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut(), 1)); assertRequestLineEquals(request, @@ -722,8 +722,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("createVirtualMachine", VirtualApplianceDto.class, - VirtualMachineWithNodeExtendedDto.class)); + Invokable method = method(CloudAsyncApi.class, "createVirtualMachine", VirtualApplianceDto.class, + VirtualMachineWithNodeExtendedDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualAppliancePut(), CloudResources.virtualMachinePost())); @@ -741,7 +741,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class)); + Invokable method = method(CloudAsyncApi.class, "updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -758,8 +758,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateVirtualMachineWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class, - VirtualMachineOptions.class)); + Invokable method = method(CloudAsyncApi.class, "updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class, + VirtualMachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut(), VirtualMachineOptions.builder().force(true).build())); @@ -777,8 +777,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testChangeVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("changeVirtualMachineState", VirtualMachineDto.class, - VirtualMachineStateDto.class)); + Invokable method = method(CloudAsyncApi.class, "changeVirtualMachineState", VirtualMachineDto.class, + VirtualMachineStateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut(), CloudResources.virtualMachineState())); @@ -796,7 +796,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteVirtualMachine() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVirtualMachine", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "deleteVirtualMachine", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -812,7 +812,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualMachineState", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualMachineState", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -828,8 +828,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deployVirtualMachine", VirtualMachineDto.class, - VirtualMachineTaskDto.class)); + Invokable method = method(CloudAsyncApi.class, "deployVirtualMachine", VirtualMachineDto.class, + VirtualMachineTaskDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut(), CloudResources.deployOptions())); @@ -847,8 +847,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUndeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("undeployVirtualMachine", VirtualMachineDto.class, - VirtualMachineTaskDto.class)); + Invokable method = method(CloudAsyncApi.class, "undeployVirtualMachine", VirtualMachineDto.class, + VirtualMachineTaskDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut(), CloudResources.undeployOptions())); @@ -866,7 +866,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("rebootVirtualMachine", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "rebootVirtualMachine", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -882,7 +882,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListNetworkConfigurations() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listNetworkConfigurations", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "listNetworkConfigurations", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals( @@ -899,7 +899,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testSetGatewayNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("setGatewayNetwork", VirtualMachineDto.class, VLANNetworkDto.class)); + Invokable method = method(CloudAsyncApi.class, "setGatewayNetwork", VirtualMachineDto.class, VLANNetworkDto.class); VirtualMachineDto vm = CloudResources.virtualMachinePut(); VLANNetworkDto network = NetworkResources.privateNetworkPut(); @@ -925,7 +925,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Virtual Machine Template ***********************/ public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVirtualMachineTemplate", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "getVirtualMachineTemplate", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -941,7 +941,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListAttachedVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listAttachedVolumes", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "listAttachedVolumes", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -957,7 +957,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDetachAllVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("detachAllVolumes", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "detachAllVolumes", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -977,8 +977,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { VolumeManagementDto second = CloudResources.volumePut(); second.getEditLink().setHref(second.getEditLink().getHref() + "second"); - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("replaceVolumes", VirtualMachineDto.class, - VirtualMachineOptions.class, VolumeManagementDto[].class)); + Invokable method = method(CloudAsyncApi.class, "replaceVolumes", VirtualMachineDto.class, + VirtualMachineOptions.class, VolumeManagementDto[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut(), VirtualMachineOptions.builder().force(true).build(), new VolumeManagementDto[] { first, second })); @@ -998,7 +998,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListAttachedHardDisks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listAttachedHardDisks", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "listAttachedHardDisks", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -1014,7 +1014,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDetachAllHardDisks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("detachAllHardDisks", VirtualMachineDto.class)); + Invokable method = method(CloudAsyncApi.class, "detachAllHardDisks", VirtualMachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -1034,8 +1034,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { DiskManagementDto second = CloudResources.hardDiskPut(); second.getEditLink().setHref(second.getEditLink().getHref() + "second"); - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("replaceHardDisks", VirtualMachineDto.class, - DiskManagementDto[].class)); + Invokable method = method(CloudAsyncApi.class, "replaceHardDisks", VirtualMachineDto.class, + DiskManagementDto[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut(), new DiskManagementDto[] { first, second })); @@ -1056,7 +1056,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Hard disks ***********************/ public void testListHardDisks() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listHardDisks", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "listHardDisks", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1"); @@ -1071,7 +1071,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetHardDisk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getHardDisk", VirtualDatacenterDto.class, Integer.class));; + Invokable method = method(CloudAsyncApi.class, "getHardDisk", VirtualDatacenterDto.class, Integer.class);; GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1"); @@ -1086,8 +1086,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateHardDisk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("createHardDisk", VirtualDatacenterDto.class, - DiskManagementDto.class)); + Invokable method = method(CloudAsyncApi.class, "createHardDisk", VirtualDatacenterDto.class, + DiskManagementDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), CloudResources.hardDiskPost())); @@ -1104,7 +1104,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteHardDisk() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deleteHardDisk", DiskManagementDto.class)); + Invokable method = method(CloudAsyncApi.class, "deleteHardDisk", DiskManagementDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.hardDiskPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1"); @@ -1121,7 +1121,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Volumes ***********************/ public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "listVolumes", VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1"); @@ -1136,7 +1136,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListVolumesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listVolumes", VirtualDatacenterDto.class, VolumeOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), VolumeOptions.builder().onlyAvailable(true).build())); @@ -1153,7 +1153,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListVolumesWithFilterOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class)); + Invokable method = method(CloudAsyncApi.class, "listVolumes", VirtualDatacenterDto.class, VolumeOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), VolumeOptions.builder().has("vol").orderBy(OrderBy.NAME).ascendant(true).build())); @@ -1171,7 +1171,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("getVolume", VirtualDatacenterDto.class, Integer.class)); + Invokable method = method(CloudAsyncApi.class, "getVolume", VirtualDatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); @@ -1186,8 +1186,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("createVolume", VirtualDatacenterDto.class, - VolumeManagementDto.class)); + Invokable method = method(CloudAsyncApi.class, "createVolume", VirtualDatacenterDto.class, + VolumeManagementDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualDatacenterPut(), CloudResources.volumePost())); @@ -1204,7 +1204,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("updateVolume", VolumeManagementDto.class)); + Invokable method = method(CloudAsyncApi.class, "updateVolume", VolumeManagementDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.volumePut())); assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); @@ -1220,7 +1220,7 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class.getMethod("deleteVolume", VolumeManagementDto.class)); + Invokable method = method(CloudAsyncApi.class, "deleteVolume", VolumeManagementDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.volumePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); @@ -1235,8 +1235,8 @@ public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testMoveVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(CloudAsyncApi.class - .getMethod("moveVolume", VolumeManagementDto.class, VirtualDatacenterDto.class)); + Invokable method = method(CloudAsyncApi.class, "moveVolume", VolumeManagementDto.class, + VirtualDatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.volumePut(), CloudResources.virtualDatacenterPut())); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java index fcd4c844df..2e4cf272f6 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java @@ -20,6 +20,7 @@ package org.jclouds.abiquo.features; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -42,7 +43,6 @@ import com.abiquo.server.core.enterprise.PrivilegeDto; import com.abiquo.server.core.enterprise.PrivilegesDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code AdminAsyncApi}. * @@ -54,7 +54,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** License ***********************/ public void testListLicenses() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("listLicenses")); + Invokable method = method(ConfigAsyncApi.class, "listLicenses"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/licenses HTTP/1.1"); @@ -69,7 +69,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListLicenseWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("listLicenses", LicenseOptions.class)); + Invokable method = method(ConfigAsyncApi.class, "listLicenses", LicenseOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(LicenseOptions.builder().active(true).build())); assertRequestLineEquals(request, "GET http://localhost/api/config/licenses?active=true HTTP/1.1"); @@ -84,7 +84,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testAddLicense() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("addLicense", LicenseDto.class)); + Invokable method = method(ConfigAsyncApi.class, "addLicense", LicenseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(ConfigResources.licensePost())); assertRequestLineEquals(request, "POST http://localhost/api/config/licenses HTTP/1.1"); @@ -100,7 +100,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testRemoveLicense() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("removeLicense", LicenseDto.class)); + Invokable method = method(ConfigAsyncApi.class, "removeLicense", LicenseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(ConfigResources.licensePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/config/licenses/1 HTTP/1.1"); @@ -117,7 +117,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Privilege ***********************/ public void testListPrivileges() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("listPrivileges")); + Invokable method = method(ConfigAsyncApi.class, "listPrivileges"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/privileges HTTP/1.1"); @@ -132,7 +132,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetPrivilege() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("getPrivilege", Integer.class)); + Invokable method = method(ConfigAsyncApi.class, "getPrivilege", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/privileges/1 HTTP/1.1"); @@ -149,7 +149,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** System Properties ***********************/ public void testListSystemProperties() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("listSystemProperties")); + Invokable method = method(ConfigAsyncApi.class, "listSystemProperties"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/properties HTTP/1.1"); @@ -164,7 +164,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListSystemPropertiesWithOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("listSystemProperties", PropertyOptions.class)); + Invokable method = method(ConfigAsyncApi.class, "listSystemProperties", PropertyOptions.class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of(PropertyOptions.builder().component("api").build())); @@ -180,7 +180,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateSystemProperty() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("updateSystemProperty", SystemPropertyDto.class)); + Invokable method = method(ConfigAsyncApi.class, "updateSystemProperty", SystemPropertyDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(ConfigResources.propertyPut())); assertRequestLineEquals(request, "PUT http://localhost/api/config/properties/1 HTTP/1.1"); @@ -198,7 +198,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Category ***********************/ public void testListCategories() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("listCategories")); + Invokable method = method(ConfigAsyncApi.class, "listCategories"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/categories HTTP/1.1"); @@ -213,7 +213,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("getCategory", Integer.class)); + Invokable method = method(ConfigAsyncApi.class, "getCategory", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/categories/1 HTTP/1.1"); @@ -228,7 +228,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testCreateCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("createCategory", CategoryDto.class)); + Invokable method = method(ConfigAsyncApi.class, "createCategory", CategoryDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(ConfigResources.categoryPost())); assertRequestLineEquals(request, "POST http://localhost/api/config/categories HTTP/1.1"); @@ -244,7 +244,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testUpdateCategory() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("updateCategory", CategoryDto.class)); + Invokable method = method(ConfigAsyncApi.class, "updateCategory", CategoryDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(ConfigResources.categoryPut())); assertRequestLineEquals(request, "PUT http://localhost/api/config/categories/1 HTTP/1.1"); @@ -260,7 +260,7 @@ public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testDeleteCategory() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(ConfigAsyncApi.class.getMethod("deleteCategory", CategoryDto.class)); + Invokable method = method(ConfigAsyncApi.class, "deleteCategory", CategoryDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(ConfigResources.categoryPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/config/categories/1 HTTP/1.1"); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java index be6cf8232a..90a81ca1f3 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java @@ -20,6 +20,7 @@ package org.jclouds.abiquo.features; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -54,7 +55,6 @@ import com.abiquo.server.core.infrastructure.MachinesDto; import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code EnterpriseAsyncApi} * @@ -66,7 +66,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listEnterprises")); + Invokable method = method(EnterpriseAsyncApi.class, "listEnterprises"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises HTTP/1.1"); @@ -83,7 +83,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listEnterprises", EnterpriseOptions.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listEnterprises", EnterpriseOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(options)); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises?has=abi&by=name&asc=true HTTP/1.1"); @@ -100,8 +100,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listEnterprises", DatacenterDto.class, - EnterpriseOptions.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listEnterprises", DatacenterDto.class, + EnterpriseOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), options)); assertRequestLineEquals(request, @@ -117,7 +117,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createEnterprise", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "createEnterprise", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePost())); assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises HTTP/1.1"); @@ -133,7 +133,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getEnterprise", Integer.class)); + Invokable method = method(EnterpriseAsyncApi.class, "getEnterprise", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1 HTTP/1.1"); @@ -148,7 +148,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateEnterprise", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "updateEnterprise", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1 HTTP/1.1"); @@ -164,7 +164,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteEnterprise", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "deleteEnterprise", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1 HTTP/1.1"); @@ -179,7 +179,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listAllowedDatacenters", Integer.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listAllowedDatacenters", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters?idEnterprise=1 HTTP/1.1"); @@ -194,7 +194,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualDatacenters", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listVirtualDatacenters", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, @@ -212,7 +212,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getEnterpriseProperties", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "getEnterpriseProperties", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/properties HTTP/1.1"); @@ -227,7 +227,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateEnterpriseProperties", EnterprisePropertiesDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "updateEnterpriseProperties", EnterprisePropertiesDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePropertiesPut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/properties HTTP/1.1"); @@ -249,8 +249,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createLimits", EnterpriseDto.class, DatacenterDto.class, - DatacenterLimitsDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "createLimits", EnterpriseDto.class, DatacenterDto.class, + DatacenterLimitsDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(enterprise, datacenter, limits)); String limitsUri = enterprise.searchLink("limits").getHref(); @@ -272,7 +272,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getLimits", EnterpriseDto.class, DatacenterDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "getLimits", EnterpriseDto.class, DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(enterprise, datacenter)); String limitsUri = enterprise.searchLink("limits").getHref(); @@ -292,7 +292,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateLimits", DatacenterLimitsDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "updateLimits", DatacenterLimitsDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.datacenterLimitsPut(enterprise))); @@ -311,7 +311,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteLimits", DatacenterLimitsDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "deleteLimits", DatacenterLimitsDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.datacenterLimitsPut(enterprise))); @@ -327,7 +327,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listLimits", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listLimits", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits HTTP/1.1"); @@ -344,7 +344,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getUser", EnterpriseDto.class, Integer.class)); + Invokable method = method(EnterpriseAsyncApi.class, "getUser", EnterpriseDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); @@ -359,7 +359,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listUsers", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listUsers", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users HTTP/1.1"); @@ -377,7 +377,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createUser", EnterpriseDto.class, UserDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "createUser", EnterpriseDto.class, UserDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(enterprise, user)); assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises/1/users HTTP/1.1"); @@ -393,7 +393,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateUser", UserDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "updateUser", UserDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.userPut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); @@ -409,7 +409,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteUser", UserDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "deleteUser", UserDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.userPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); @@ -424,7 +424,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualMachines", UserDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listVirtualMachines", UserDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.userPut())); assertRequestLineEquals(request, @@ -442,7 +442,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getDatacenterRepository", EnterpriseDto.class, Integer.class)); + Invokable method = method(EnterpriseAsyncApi.class, "getDatacenterRepository", EnterpriseDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut(), InfrastructureResources.datacenterPut().getId())); @@ -458,7 +458,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("refreshTemplateRepository", Integer.class, Integer.class)); + Invokable method = method(EnterpriseAsyncApi.class, "refreshTemplateRepository", Integer.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut().getId(), InfrastructureResources.datacenterPut().getId())); @@ -477,7 +477,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listExternalNetworks", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listExternalNetworks", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/externalnetworks HTTP/1.1"); @@ -494,7 +494,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualMachines", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listVirtualMachines", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualmachines HTTP/1.1"); @@ -509,7 +509,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listVirtualAppliances", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listVirtualAppliances", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualappliances HTTP/1.1"); @@ -526,7 +526,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listReservedMachines", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listReservedMachines", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/reservedmachines HTTP/1.1"); @@ -543,7 +543,7 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listTemplateDefinitionLists", EnterpriseDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listTemplateDefinitionLists", EnterpriseDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut())); assertRequestLineEquals(request, @@ -562,8 +562,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("createTemplateDefinitionList", EnterpriseDto.class, - TemplateDefinitionListDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "createTemplateDefinitionList", EnterpriseDto.class, + TemplateDefinitionListDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(enterprise, template)); assertRequestLineEquals(request, @@ -582,8 +582,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("updateTemplateDefinitionList", - TemplateDefinitionListDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "updateTemplateDefinitionList", + TemplateDefinitionListDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(template)); assertRequestLineEquals(request, @@ -600,8 +600,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("deleteTemplateDefinitionList", - TemplateDefinitionListDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "deleteTemplateDefinitionList", + TemplateDefinitionListDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.templateListPut())); assertRequestLineEquals(request, @@ -617,8 +617,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("getTemplateDefinitionList", EnterpriseDto.class, - Integer.class)); + Invokable method = method(EnterpriseAsyncApi.class, "getTemplateDefinitionList", EnterpriseDto.class, + Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut(), 1)); assertRequestLineEquals(request, @@ -634,8 +634,8 @@ public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(EnterpriseAsyncApi.class.getMethod("listTemplateListStatus", TemplateDefinitionListDto.class, - DatacenterDto.class)); + Invokable method = method(EnterpriseAsyncApi.class, "listTemplateListStatus", TemplateDefinitionListDto.class, + DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.templateListPut(), InfrastructureResources.datacenterPut())); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java index 4a9e964327..5aadbcd384 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java @@ -19,6 +19,8 @@ package org.jclouds.abiquo.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.http.functions.ParseXMLWithJAXB; @@ -28,7 +30,6 @@ import org.testng.annotations.Test; import com.abiquo.server.core.event.EventsDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code EventAsyncApi} * @@ -38,7 +39,7 @@ import com.google.common.reflect.Invokable; @Test(groups = "unit", testName = "EventAsyncApiTest") public class EventAsyncApiTest extends BaseAbiquoAsyncApiTest { public void testListEvents() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(EventAsyncApi.class.getMethod("listEvents")); + Invokable method = method(EventAsyncApi.class, "listEvents"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/events HTTP/1.1"); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java index 681338a1ec..fa7b2034a0 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java @@ -20,6 +20,7 @@ package org.jclouds.abiquo.features; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -90,7 +91,6 @@ import com.abiquo.server.core.infrastructure.storage.TierDto; import com.abiquo.server.core.infrastructure.storage.TiersDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code InfrastructureAsyncApi} * @@ -101,7 +101,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listDatacenters")); + Invokable method = method(InfrastructureAsyncApi.class, "listDatacenters"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters HTTP/1.1"); @@ -116,7 +116,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("createDatacenter", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createDatacenter", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPost())); assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters HTTP/1.1"); @@ -132,7 +132,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getDatacenter", Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getDatacenter", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1 HTTP/1.1"); @@ -147,7 +147,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateDatacenter", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateDatacenter", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1 HTTP/1.1"); @@ -163,7 +163,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteDatacenter", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteDatacenter", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1 HTTP/1.1"); @@ -178,7 +178,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listLimits", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listLimits", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/action/getLimits HTTP/1.1"); @@ -195,8 +195,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getHypervisorTypeFromMachine", DatacenterDto.class, - DatacenterOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getHypervisorTypeFromMachine", DatacenterDto.class, + DatacenterOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), DatacenterOptions.builder().ip("10.60.1.120").build())); @@ -213,7 +213,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getHypervisorTypes", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getHypervisorTypes", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/hypervisors HTTP/1.1"); @@ -230,7 +230,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listRacks", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listRacks", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); @@ -245,7 +245,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("createRack", DatacenterDto.class, RackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createRack", DatacenterDto.class, RackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), InfrastructureResources.rackPost())); @@ -262,7 +262,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getRack", DatacenterDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getRack", DatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); @@ -277,7 +277,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateRack", RackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateRack", RackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.rackPut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); @@ -293,7 +293,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteRack", RackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteRack", RackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.rackPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); @@ -310,7 +310,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listManagedRacks", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listManagedRacks", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); @@ -325,8 +325,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class - .getMethod("createManagedRack", DatacenterDto.class, UcsRackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createManagedRack", DatacenterDto.class, UcsRackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), InfrastructureResources.managedRackPost())); @@ -343,7 +342,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getManagedRack", DatacenterDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getManagedRack", DatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); @@ -358,7 +357,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateManagedRack", UcsRackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateManagedRack", UcsRackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut())); @@ -375,7 +374,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listServiceProfiles", UcsRackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfiles", UcsRackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/logicservers HTTP/1.1"); @@ -392,8 +391,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listServiceProfiles", UcsRackDto.class, - FilterOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfiles", UcsRackDto.class, + FilterOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), options)); assertRequestLineEquals(request, @@ -409,7 +408,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listOrganizations", UcsRackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listOrganizations", UcsRackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/organizations HTTP/1.1"); @@ -426,8 +425,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class - .getMethod("listOrganizations", UcsRackDto.class, FilterOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listOrganizations", UcsRackDto.class, FilterOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), options)); assertRequestLineEquals(request, @@ -443,7 +441,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listServiceProfileTemplates", UcsRackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfileTemplates", UcsRackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/lstemplates HTTP/1.1"); @@ -461,8 +459,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listServiceProfileTemplates", UcsRackDto.class, - FilterOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listServiceProfileTemplates", UcsRackDto.class, + FilterOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), options)); assertRequestLineEquals(request, @@ -478,8 +476,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("associateLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "associateLogicServer", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "blade")); @@ -497,8 +495,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("associateTemplate", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "associateTemplate", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "newname", "blade")); @@ -516,8 +514,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("cloneAndAssociateLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "cloneAndAssociateLogicServer", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "newname", "blade")); @@ -535,8 +533,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("dissociateLogicServer", UcsRackDto.class, - LogicServerDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "dissociateLogicServer", UcsRackDto.class, + LogicServerDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut())); @@ -553,8 +551,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("cloneLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "cloneLogicServer", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "name")); @@ -572,8 +570,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteLogicServer", UcsRackDto.class, - LogicServerDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteLogicServer", UcsRackDto.class, + LogicServerDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), InfrastructureResources.logicServerPut())); @@ -590,7 +588,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listFsms", UcsRackDto.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listFsms", UcsRackDto.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.managedRackPut(), "dn")); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/fsm?dn=dn HTTP/1.1"); @@ -607,7 +605,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listRemoteServices", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listRemoteServices", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/remoteservices HTTP/1.1"); @@ -622,8 +620,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("createRemoteService", DatacenterDto.class, - RemoteServiceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createRemoteService", DatacenterDto.class, + RemoteServiceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), InfrastructureResources.remoteServicePost())); @@ -640,8 +638,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getRemoteService", DatacenterDto.class, - RemoteServiceType.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getRemoteService", DatacenterDto.class, + RemoteServiceType.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), RemoteServiceType.STORAGE_SYSTEM_MONITOR)); @@ -658,7 +656,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateRemoteService", RemoteServiceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateRemoteService", RemoteServiceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.remoteServicePut())); assertRequestLineEquals(request, @@ -675,7 +673,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteRemoteService", RemoteServiceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteRemoteService", RemoteServiceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.remoteServicePut())); assertRequestLineEquals(request, @@ -691,7 +689,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("isAvailable", RemoteServiceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "isAvailable", RemoteServiceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.remoteServicePut())); String checkUri = InfrastructureResources.remoteServicePut().searchLink("check").getHref(); @@ -709,8 +707,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "discoverSingleMachine", DatacenterDto.class, + String.class, HypervisorType.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", HypervisorType.XENSERVER, "user", "pass")); @@ -730,8 +728,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, MachineOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "discoverSingleMachine", DatacenterDto.class, + String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "80.80.80.80", HypervisorType.KVM, "user", "pass", MachineOptions.builder().port(8889).build())); @@ -751,8 +749,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, MachineOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "discoverSingleMachine", DatacenterDto.class, + String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "80.80.80.80", HypervisorType.KVM, "user", "pass", MachineOptions.builder().build())); @@ -773,8 +771,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("discoverMultipleMachines", DatacenterDto.class, - String.class, String.class, HypervisorType.class, String.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "discoverMultipleMachines", DatacenterDto.class, + String.class, String.class, HypervisorType.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", "10.60.1.250", HypervisorType.XENSERVER, "user", "pass")); @@ -794,8 +792,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("discoverMultipleMachines", DatacenterDto.class, - String.class, String.class, HypervisorType.class, String.class, String.class, MachineOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "discoverMultipleMachines", DatacenterDto.class, + String.class, String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "80.80.80.80", "80.80.80.86", HypervisorType.KVM, "user", "pass", MachineOptions.builder().port(8889) .build())); @@ -816,8 +814,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("checkMachineState", DatacenterDto.class, String.class, - HypervisorType.class, String.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkMachineState", DatacenterDto.class, String.class, + HypervisorType.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", HypervisorType.XENSERVER, "user", "pass")); @@ -837,8 +835,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("checkMachineState", DatacenterDto.class, String.class, - HypervisorType.class, String.class, String.class, MachineOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkMachineState", DatacenterDto.class, String.class, + HypervisorType.class, String.class, String.class, MachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", HypervisorType.XENSERVER, "user", "pass", MachineOptions.builder().port(8889).build())); @@ -858,8 +856,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", DatacenterDto.class, - String.class, String.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkMachineIpmiState", DatacenterDto.class, + String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", "user", "pass")); @@ -879,8 +877,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", DatacenterDto.class, - String.class, String.class, String.class, IpmiOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkMachineIpmiState", DatacenterDto.class, + String.class, String.class, String.class, IpmiOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), "10.60.1.222", "user", "pass", IpmiOptions.builder().port(8889).build())); @@ -900,7 +898,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listMachines", RackDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listMachines", RackDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.rackPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines HTTP/1.1"); @@ -915,7 +913,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getMachine", RackDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getMachine", RackDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.rackPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); @@ -930,7 +928,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("checkMachineState", MachineDto.class, boolean.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkMachineState", MachineDto.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut(), true)); assertRequestLineEquals(request, @@ -946,7 +944,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkMachineIpmiState", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, @@ -962,7 +960,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("createMachine", RackDto.class, MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createMachine", RackDto.class, MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.rackPut(), InfrastructureResources.machinePost())); @@ -979,7 +977,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateMachine", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateMachine", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); @@ -995,7 +993,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteMachine", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteMachine", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); @@ -1010,7 +1008,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("reserveMachine", EnterpriseDto.class, MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "reserveMachine", EnterpriseDto.class, MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut(), InfrastructureResources.machinePut())); @@ -1027,8 +1025,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class - .getMethod("cancelReservation", EnterpriseDto.class, MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "cancelReservation", EnterpriseDto.class, MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(EnterpriseResources.enterprisePut(), InfrastructureResources.machinePut())); @@ -1046,8 +1043,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listVirtualMachinesByMachine", MachineDto.class, - MachineOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listVirtualMachinesByMachine", MachineDto.class, + MachineOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut(), options)); assertRequestLineEquals(request, @@ -1064,7 +1061,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getVirtualMachine", MachineDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getVirtualMachine", MachineDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut(), 1)); assertRequestLineEquals(request, @@ -1082,7 +1079,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("powerOff", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "powerOff", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, @@ -1098,7 +1095,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("powerOn", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "powerOn", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, @@ -1114,7 +1111,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getLogicServer", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getLogicServer", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, @@ -1130,7 +1127,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("ledOn", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "ledOn", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, @@ -1146,7 +1143,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("ledOff", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "ledOff", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, @@ -1162,7 +1159,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getLocatorLed", MachineDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getLocatorLed", MachineDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.machinePut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/led HTTP/1.1"); @@ -1179,7 +1176,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listStorageDevices", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listStorageDevices", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices HTTP/1.1"); @@ -1194,7 +1191,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listSupportedStorageDevices", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, @@ -1210,8 +1207,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("createStorageDevice", DatacenterDto.class, - StorageDeviceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createStorageDevice", DatacenterDto.class, + StorageDeviceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), InfrastructureResources.storageDevicePost())); @@ -1228,7 +1225,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteStorageDevice", StorageDeviceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteStorageDevice", StorageDeviceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storageDevicePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); @@ -1243,7 +1240,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateStorageDevice", StorageDeviceDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateStorageDevice", StorageDeviceDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storageDevicePut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); @@ -1259,7 +1256,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getStorageDevice", DatacenterDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getStorageDevice", DatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); @@ -1276,7 +1273,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listTiers", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listTiers", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/tiers HTTP/1.1"); @@ -1291,7 +1288,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateTier", TierDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateTier", TierDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.tierPut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/storage/tiers/1 HTTP/1.1"); @@ -1307,7 +1304,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getTier", DatacenterDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getTier", DatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/tiers/1 HTTP/1.1"); @@ -1324,8 +1321,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listStoragePools", StorageDeviceDto.class, - StoragePoolOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listStoragePools", StorageDeviceDto.class, + StoragePoolOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storageDevicePut(), StoragePoolOptions.builder().sync(true).build())); @@ -1342,7 +1339,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listStoragePools", TierDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listStoragePools", TierDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.tierPut(), StoragePoolOptions.builder().sync(true).build())); @@ -1358,8 +1355,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listStoragePools", StorageDeviceDto.class, - StoragePoolOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listStoragePools", StorageDeviceDto.class, + StoragePoolOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storageDevicePut(), StoragePoolOptions.builder().build())); @@ -1375,8 +1372,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("createStoragePool", StorageDeviceDto.class, - StoragePoolDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createStoragePool", StorageDeviceDto.class, + StoragePoolDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storageDevicePut(), InfrastructureResources.storagePoolPost())); @@ -1393,7 +1390,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateStoragePool", StoragePoolDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateStoragePool", StoragePoolDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storagePoolPut())); assertRequestLineEquals(request, @@ -1410,7 +1407,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteStoragePool", StoragePoolDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteStoragePool", StoragePoolDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storagePoolPut())); assertRequestLineEquals(request, @@ -1426,7 +1423,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getStoragePool", StorageDeviceDto.class, String.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getStoragePool", StorageDeviceDto.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storageDevicePut(), InfrastructureResources.storagePoolPut().getIdStorage())); @@ -1443,8 +1440,8 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("refreshStoragePool", StoragePoolDto.class, - StoragePoolOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "refreshStoragePool", StoragePoolDto.class, + StoragePoolOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.storagePoolPut(), StoragePoolOptions.builder().sync(true).build())); @@ -1463,7 +1460,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listNetworks", DatacenterDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listNetworks", DatacenterDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network HTTP/1.1"); @@ -1480,7 +1477,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listNetworks", DatacenterDto.class, NetworkOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listNetworks", DatacenterDto.class, NetworkOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), options)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network?type=PUBLIC HTTP/1.1"); @@ -1495,7 +1492,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getNetwork", DatacenterDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getNetwork", DatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); @@ -1510,8 +1507,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class - .getMethod("createNetwork", DatacenterDto.class, VLANNetworkDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "createNetwork", DatacenterDto.class, VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), NetworkResources.vlanPost())); @@ -1528,7 +1524,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("updateNetwork", VLANNetworkDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "updateNetwork", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicNetworkPut())); assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); @@ -1544,7 +1540,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("deleteNetwork", VLANNetworkDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "deleteNetwork", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicNetworkPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); @@ -1559,8 +1555,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class - .getMethod("checkTagAvailability", DatacenterDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "checkTagAvailability", DatacenterDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(InfrastructureResources.datacenterPut(), 2)); assertRequestLineEquals(request, @@ -1578,7 +1573,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listPublicIps", VLANNetworkDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listPublicIps", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicNetworkPut())); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1/ips HTTP/1.1"); @@ -1594,7 +1589,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listPublicIps", VLANNetworkDto.class, IpOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listPublicIps", VLANNetworkDto.class, IpOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicNetworkPut(), options)); assertRequestLineEquals(request, @@ -1610,7 +1605,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getPublicIp", VLANNetworkDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getPublicIp", VLANNetworkDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.publicNetworkPut(), 1)); assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1/ips/1 HTTP/1.1"); @@ -1625,7 +1620,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listExternalIps", VLANNetworkDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listExternalIps", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.externalNetworkPut())); assertRequestLineEquals(request, @@ -1642,7 +1637,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listExternalIps", VLANNetworkDto.class, IpOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listExternalIps", VLANNetworkDto.class, IpOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.externalNetworkPut(), options)); assertRequestLineEquals(request, @@ -1658,7 +1653,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getExternalIp", VLANNetworkDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getExternalIp", VLANNetworkDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.externalNetworkPut(), 1)); assertRequestLineEquals(request, @@ -1674,7 +1669,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listUnmanagedIps", VLANNetworkDto.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listUnmanagedIps", VLANNetworkDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.unmanagedNetworkPut())); assertRequestLineEquals(request, @@ -1691,7 +1686,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("listUnmanagedIps", VLANNetworkDto.class, IpOptions.class)); + Invokable method = method(InfrastructureAsyncApi.class, "listUnmanagedIps", VLANNetworkDto.class, IpOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.unmanagedNetworkPut(), options)); assertRequestLineEquals(request, @@ -1707,7 +1702,7 @@ public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(InfrastructureAsyncApi.class.getMethod("getUnmanagedIp", VLANNetworkDto.class, Integer.class)); + Invokable method = method(InfrastructureAsyncApi.class, "getUnmanagedIp", VLANNetworkDto.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(NetworkResources.externalNetworkPut(), 1)); assertRequestLineEquals(request, diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java index 978a3d0f85..958335b9d0 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java @@ -20,6 +20,7 @@ package org.jclouds.abiquo.features; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -43,7 +44,6 @@ import com.abiquo.server.core.pricing.PricingTierDto; import com.abiquo.server.core.pricing.PricingTiersDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code PricingAsyncApi}. * @@ -55,7 +55,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest /*********************** Currency ***********************/ public void testListCurrencies() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("listCurrencies")); + Invokable method = method(PricingAsyncApi.class, "listCurrencies"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/currencies HTTP/1.1"); @@ -70,7 +70,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testGetCurrency() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getCurrency", Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getCurrency", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/currencies/1 HTTP/1.1"); @@ -85,7 +85,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testCreateCurrency() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("createCurrency", CurrencyDto.class)); + Invokable method = method(PricingAsyncApi.class, "createCurrency", CurrencyDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.currencyPost())); assertRequestLineEquals(request, "POST http://localhost/api/config/currencies HTTP/1.1"); @@ -101,7 +101,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testUpdateCurrency() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("updateCurrency", CurrencyDto.class)); + Invokable method = method(PricingAsyncApi.class, "updateCurrency", CurrencyDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.currencyPut())); assertRequestLineEquals(request, "PUT http://localhost/api/config/currencies/1 HTTP/1.1"); @@ -117,7 +117,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testDeleteCurrency() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("deleteCurrency", CurrencyDto.class)); + Invokable method = method(PricingAsyncApi.class, "deleteCurrency", CurrencyDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.currencyPut())); assertRequestLineEquals(request, "DELETE http://localhost/api/config/currencies/1 HTTP/1.1"); @@ -134,7 +134,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest /*********************** Cost Code ***********************/ public void testListCostCodes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("listCostCodes")); + Invokable method = method(PricingAsyncApi.class, "listCostCodes"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes HTTP/1.1"); @@ -149,7 +149,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testGetCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getCostCode", Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getCostCode", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1 HTTP/1.1"); @@ -164,7 +164,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testCreateCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("createCostCode", CostCodeDto.class)); + Invokable method = method(PricingAsyncApi.class, "createCostCode", CostCodeDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.costcodePost())); assertRequestLineEquals(request, "POST http://localhost/api/config/costcodes HTTP/1.1"); @@ -180,7 +180,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testUpdateCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("updateCostCode", CostCodeDto.class)); + Invokable method = method(PricingAsyncApi.class, "updateCostCode", CostCodeDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.costcodePut())); assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1 HTTP/1.1"); @@ -196,7 +196,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testDeleteCostCode() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("deleteCostCode", CostCodeDto.class)); + Invokable method = method(PricingAsyncApi.class, "deleteCostCode", CostCodeDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.costcodePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/config/costcodes/1 HTTP/1.1"); @@ -213,7 +213,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest /*********************** Pricing Template ***********************/ public void testListPricingTemplates() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("listPricingTemplates")); + Invokable method = method(PricingAsyncApi.class, "listPricingTemplates"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates HTTP/1.1"); @@ -228,7 +228,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testGetPricingTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getPricingTemplate", Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getPricingTemplate", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); @@ -243,7 +243,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testCreatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("createPricingTemplate", PricingTemplateDto.class)); + Invokable method = method(PricingAsyncApi.class, "createPricingTemplate", PricingTemplateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.pricingtemplatePost())); assertRequestLineEquals(request, "POST http://localhost/api/config/pricingtemplates HTTP/1.1"); @@ -259,7 +259,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testUpdatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("updatePricingTemplate", PricingTemplateDto.class)); + Invokable method = method(PricingAsyncApi.class, "updatePricingTemplate", PricingTemplateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.pricingtemplatePut())); assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); @@ -275,7 +275,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testDeletePricingTemplate() throws SecurityException, NoSuchMethodException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("deletePricingTemplate", PricingTemplateDto.class)); + Invokable method = method(PricingAsyncApi.class, "deletePricingTemplate", PricingTemplateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.pricingtemplatePut())); assertRequestLineEquals(request, "DELETE http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); @@ -292,7 +292,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest /*********************** Cost Code Currency ***********************/ public void testGetCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getCostCodeCurrencies", Integer.class, Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getCostCodeCurrencies", Integer.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1)); assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1/currencies?idCurrency=1 HTTP/1.1"); @@ -307,8 +307,8 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testUpdateCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("updateCostCodeCurrencies", Integer.class, - CostCodeCurrenciesDto.class)); + Invokable method = method(PricingAsyncApi.class, "updateCostCodeCurrencies", Integer.class, + CostCodeCurrenciesDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, PricingResources.costcodecurrencyPut())); assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1/currencies HTTP/1.1"); @@ -326,7 +326,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest /*********************** Pricing Cost Code ***********************/ public void testGetPricingCostCodes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getPricingCostCodes", Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getPricingCostCodes", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/costcodes HTTP/1.1"); @@ -341,7 +341,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testGetPricingCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getPricingCostCode", Integer.class, Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getPricingCostCode", Integer.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1)); assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1"); @@ -356,8 +356,8 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testUpdatePricingCostCode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("updatePricingCostCode", PricingCostCodeDto.class, Integer.class, - Integer.class)); + Invokable method = method(PricingAsyncApi.class, "updatePricingCostCode", PricingCostCodeDto.class, Integer.class, + Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.pricingCostcodePut(), 1, 1)); assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1"); @@ -375,7 +375,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest /*********************** Pricing Tier ***************************/ public void testGetPricingTiers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getPricingTiers", Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getPricingTiers", Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/tiers HTTP/1.1"); @@ -390,7 +390,7 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testGetPricingTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("getPricingTier", Integer.class, Integer.class)); + Invokable method = method(PricingAsyncApi.class, "getPricingTier", Integer.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1)); assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/tiers/1 HTTP/1.1"); @@ -405,8 +405,8 @@ public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest } public void testUpdatePricingTier() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PricingAsyncApi.class.getMethod("updatePricingTier", PricingTierDto.class, Integer.class, - Integer.class)); + Invokable method = method(PricingAsyncApi.class, "updatePricingTier", PricingTierDto.class, Integer.class, + Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(PricingResources.pricingTierPut(), 1, 2)); assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1/tiers/2 HTTP/1.1"); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java index b215ddb3fc..dacfa61ac3 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java @@ -19,6 +19,8 @@ package org.jclouds.abiquo.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.abiquo.AbiquoFallbacks.NullOn303; @@ -34,7 +36,6 @@ import com.abiquo.server.core.task.TaskDto; import com.abiquo.server.core.task.TasksDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code TaskAsyncApi} * @@ -46,7 +47,7 @@ public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest { /*********************** Task ***********************/ public void testGetTaskVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TaskAsyncApi.class.getMethod("getTask", RESTLink.class)); + Invokable method = method(TaskAsyncApi.class, "getTask", RESTLink.class); GeneratedHttpRequest request = processor .createRequest( method, @@ -68,7 +69,7 @@ public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListTasksVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TaskAsyncApi.class.getMethod("listTasks", SingleResourceTransportDto.class)); + Invokable method = method(TaskAsyncApi.class, "listTasks", SingleResourceTransportDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(CloudResources.virtualMachinePut())); assertRequestLineEquals(request, @@ -84,7 +85,7 @@ public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testGetTaskVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TaskAsyncApi.class.getMethod("getTask", RESTLink.class)); + Invokable method = method(TaskAsyncApi.class, "getTask", RESTLink.class); GeneratedHttpRequest request = processor .createRequest( method, @@ -106,7 +107,7 @@ public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest { } public void testListTasksVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TaskAsyncApi.class.getMethod("listTasks", SingleResourceTransportDto.class)); + Invokable method = method(TaskAsyncApi.class, "listTasks", SingleResourceTransportDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut())); assertRequestLineEquals(request, diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java index 1c0b47562c..b0ba199c78 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java @@ -20,6 +20,7 @@ package org.jclouds.abiquo.features; import static org.jclouds.abiquo.domain.DomainUtils.withHeader; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; @@ -44,7 +45,6 @@ import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code VirtualMachineTemplateAsyncApi} * @@ -56,8 +56,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("listVirtualMachineTemplates", Integer.class, - Integer.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listVirtualMachineTemplates", Integer.class, + Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1)); assertRequestLineEquals(request, @@ -74,8 +74,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("listVirtualMachineTemplates", Integer.class, - Integer.class, VirtualMachineTemplateOptions.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listVirtualMachineTemplates", Integer.class, + Integer.class, VirtualMachineTemplateOptions.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1, VirtualMachineTemplateOptions.builder() .hypervisorType(HypervisorType.XENSERVER).categoryName("Firewalls").build())); @@ -93,8 +93,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("getVirtualMachineTemplate", Integer.class, - Integer.class, Integer.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "getVirtualMachineTemplate", Integer.class, + Integer.class, Integer.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1, 1)); assertRequestLineEquals(request, @@ -110,8 +110,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("updateVirtualMachineTemplate", - VirtualMachineTemplateDto.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "updateVirtualMachineTemplate", + VirtualMachineTemplateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut())); assertRequestLineEquals(request, @@ -128,8 +128,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("deleteVirtualMachineTemplate", - VirtualMachineTemplateDto.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "deleteVirtualMachineTemplate", + VirtualMachineTemplateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut())); assertRequestLineEquals(request, @@ -146,8 +146,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("createPersistentVirtualMachineTemplate", - Integer.class, Integer.class, VirtualMachineTemplatePersistentDto.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "createPersistentVirtualMachineTemplate", + Integer.class, Integer.class, VirtualMachineTemplatePersistentDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(1, 1, TemplateResources.persistentData())); assertRequestLineEquals(request, @@ -166,8 +166,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("requestConversion", - VirtualMachineTemplateDto.class, DiskFormatType.class, ConversionDto.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "requestConversion", + VirtualMachineTemplateDto.class, DiskFormatType.class, ConversionDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut(), DiskFormatType.VMDK_STREAM_OPTIMIZED, TemplateResources.conversionPut())); @@ -188,8 +188,7 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class - .getMethod("listConversions", VirtualMachineTemplateDto.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listConversions", VirtualMachineTemplateDto.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut())); assertRequestLineEquals(request, @@ -205,8 +204,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("listConversions", - VirtualMachineTemplateDto.class, ConversionOptions.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "listConversions", + VirtualMachineTemplateDto.class, ConversionOptions.class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut(), @@ -227,8 +226,8 @@ public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest method = Invokable.from(VirtualMachineTemplateAsyncApi.class.getMethod("getConversion", VirtualMachineTemplateDto.class, - DiskFormatType.class)); + Invokable method = method(VirtualMachineTemplateAsyncApi.class, "getConversion", VirtualMachineTemplateDto.class, + DiskFormatType.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(TemplateResources.virtualMachineTemplatePut(), DiskFormatType.RAW)); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java index e42cba3619..fcf0f1602b 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java @@ -521,7 +521,6 @@ public class AsyncMonitorTest { public int numTimeouts = 0; @Subscribe - @SuppressWarnings("unused") public void handle(final MonitorEvent event) { switch (event.getType()) { case COMPLETED: diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java index 737f37ff49..1690b0e500 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java @@ -18,7 +18,7 @@ */ package org.jclouds.abiquo.internal; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Properties; @@ -59,7 +59,7 @@ public abstract class BaseAbiquoLiveApiTest extends BaseViewLiveTest viewType() { - return typeTokenOf(AbiquoContext.class); + return typeToken(AbiquoContext.class); } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java index 2151e3e204..83115a260f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java @@ -19,6 +19,8 @@ package org.jclouds.abiquo.rest.internal; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; @@ -31,7 +33,6 @@ import com.abiquo.model.rest.RESTLink; import com.abiquo.server.core.infrastructure.DatacentersDto; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; - /** * Tests annotation parsing of {@code AbiquoHttpAsyncApi}. * @@ -43,7 +44,7 @@ public class AbiquoHttpAsyncClientTest extends BaseAbiquoAsyncApiTest method = Invokable.from(AbiquoHttpAsyncClient.class.getMethod("get", RESTLink.class)); + Invokable method = method(AbiquoHttpAsyncClient.class, "get", RESTLink.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(link)); assertRequestLineEquals(request, "GET http://foo/bar HTTP/1.1"); diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java index 4230f092f0..0979139b40 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java @@ -17,11 +17,10 @@ * under the License. */ package org.jclouds.azure.management; - import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.azure.management.config.AzureManagementProperties.SUBSCRIPTION_ID; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -83,7 +82,7 @@ public class AzureManagementApiMetadata extends BaseRestApiMetadata { .endpointName("Service Management Endpoint ending in your Subscription Id") .documentation(URI.create("http://msdn.microsoft.com/en-us/library/ee460799")) .defaultProperties(AzureManagementApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.> of(AzureManagementComputeServiceContextModule.class, AzureManagementRestClientModule.class)); } diff --git a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java index aa4d0d4144..caccbe1c92 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java +++ b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.elb.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -52,6 +52,6 @@ public class ELBRestClientModule extends FormSigningRestClientModule> of( FGCPComputeServiceContextModule.class, diff --git a/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java b/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java index 90eee2d161..68b2a27905 100644 --- a/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java +++ b/labs/iam/src/main/java/org/jclouds/iam/config/IAMRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.iam.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -43,7 +43,7 @@ public class IAMRestClientModule extends FormSigningRestClientModule> of(DatacentersAreZonesModule.class, JoyentCloudRestClientModule.class, JoyentCloudComputeServiceContextModule.class)); } diff --git a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java index 45ab0c07cb..84b498fd4e 100644 --- a/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java +++ b/labs/joyent-cloudapi/src/main/java/org/jclouds/joyent/cloudapi/v6_5/reference/Metadata.java @@ -18,7 +18,7 @@ */ package org.jclouds.joyent.cloudapi.v6_5.reference; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.lang.reflect.Type; import java.util.Map; @@ -32,7 +32,7 @@ import com.google.common.reflect.TypeToken; * @author Adrian Cole */ public enum Metadata { - ROOT_AUTHORIZED_KEYS(typeTokenOf(String.class).getType()), + ROOT_AUTHORIZED_KEYS(typeToken(String.class).getType()), /** * If the dataset you create a machine from is set to generate passwords for * you, the username/password pairs will be returned in the metadata response @@ -46,6 +46,7 @@ public enum Metadata { * */ CREDENTIALS(new TypeToken>() { + private static final long serialVersionUID = 1L; }.getType()); private final Type valueType; diff --git a/labs/oauth/src/main/java/org/jclouds/oauth/v2/config/OAuthRestClientModule.java b/labs/oauth/src/main/java/org/jclouds/oauth/v2/config/OAuthRestClientModule.java index 485e1c7b0a..f54f8001a7 100644 --- a/labs/oauth/src/main/java/org/jclouds/oauth/v2/config/OAuthRestClientModule.java +++ b/labs/oauth/src/main/java/org/jclouds/oauth/v2/config/OAuthRestClientModule.java @@ -1,6 +1,6 @@ package org.jclouds.oauth.v2.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; @@ -14,7 +14,6 @@ import org.jclouds.rest.config.RestClientModule; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import com.google.common.reflect.TypeToken; import com.google.inject.Provides; /** @@ -26,8 +25,7 @@ import com.google.inject.Provides; public class OAuthRestClientModule extends RestClientModule { public OAuthRestClientModule() { - super(TypeToken.class.cast(typeTokenOf(OAuthApi.class)), TypeToken.class.cast(typeTokenOf(OAuthAsyncApi - .class))); + super(typeToken(OAuthApi.class), typeToken(OAuthAsyncApi.class)); } @Provides diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java index a28270c73e..e6b2fc0b6a 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java @@ -18,7 +18,8 @@ */ package org.jclouds.openstack.glance.v1_0.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; + +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Map; @@ -70,7 +71,7 @@ public class GlanceRestClientModule syncClientType, TypeToken asyncClientType, Map, Class> sync2Async) { diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java index 4f2591ab60..85ce355795 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.quantum.v1_0.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Map; @@ -74,7 +74,7 @@ public class QuantumRestClientModule syncClientType, TypeToken asyncClientType, Map, Class> sync2Async) { diff --git a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java index 58914ab047..3e39f737e4 100644 --- a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java +++ b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java @@ -17,8 +17,7 @@ * under the License. */ package org.jclouds.openstack.swift.v1.config; - -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Map; @@ -77,7 +76,7 @@ public class SwiftRestClientModule @SuppressWarnings("unchecked") public SwiftRestClientModule() { - super(TypeToken.class.cast(typeTokenOf(SwiftApi.class)), TypeToken.class.cast(typeTokenOf(SwiftAsyncApi.class)), DELEGATE_MAP); + super(TypeToken.class.cast(typeToken(SwiftApi.class)), TypeToken.class.cast(typeToken(SwiftAsyncApi.class)), DELEGATE_MAP); } protected SwiftRestClientModule(TypeToken syncClientType, TypeToken asyncClientType, Map, Class> sync2Async) { diff --git a/labs/rds/src/main/java/org/jclouds/rds/config/RDSRestClientModule.java b/labs/rds/src/main/java/org/jclouds/rds/config/RDSRestClientModule.java index 4008ce82ef..676beeeb02 100644 --- a/labs/rds/src/main/java/org/jclouds/rds/config/RDSRestClientModule.java +++ b/labs/rds/src/main/java/org/jclouds/rds/config/RDSRestClientModule.java @@ -18,7 +18,8 @@ */ package org.jclouds.rds.config; -import static org.jclouds.reflect.Reflection2.typeTokenOf; + +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -49,6 +50,6 @@ public class RDSRestClientModule extends FormSigningRestClientModule>of(VPDCRestClientModule.class, VPDCComputeServiceContextModule.class)); } diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java index 2bc984bccd..9225798308 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java @@ -17,13 +17,13 @@ * under the License. */ package org.jclouds.savvis.vpdc.features; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.options.GetVMOptions; import org.jclouds.savvis.vpdc.xml.FirewallServiceHandler; @@ -36,6 +36,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code BrowsingAsyncApi} @@ -46,7 +47,7 @@ import com.google.common.collect.Lists; public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest { public void testOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getOrg", String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getOrg", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11 HTTP/1.1"); @@ -61,7 +62,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testOrgNull() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getOrg", String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getOrg", String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1 HTTP/1.1"); @@ -76,7 +77,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVDCInOrg", String.class, String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getVDCInOrg", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22 HTTP/1.1"); @@ -91,7 +92,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testVDCWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVDCInOrg", String.class, String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getVDCInOrg", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22 HTTP/1.1"); @@ -106,7 +107,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getNetworkInVDC", String.class, String.class, String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getNetworkInVDC", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "VM-Tier01")); assertRequestLineEquals(request, @@ -122,7 +123,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testNetworkWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getNetworkInVDC", String.class, String.class, String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getNetworkInVDC", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22", "VM-Tier01")); assertRequestLineEquals(request, @@ -138,8 +139,8 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testVMVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVMInVDC", String.class, String.class, String.class, - GetVMOptions[].class)); + Invokable method = method(BrowsingAsyncApi.class, "getVMInVDC", String.class, String.class, String.class, + GetVMOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, @@ -155,7 +156,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testVM() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVM", URI.class, GetVMOptions[].class)); + Invokable method = method(BrowsingAsyncApi.class, "getVM", URI.class, GetVMOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33"))); @@ -172,8 +173,8 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testVMWithPowerState() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVMInVDC", String.class, String.class, String.class, - GetVMOptions[].class)); + Invokable method = method(BrowsingAsyncApi.class, "getVMInVDC", String.class, String.class, String.class, + GetVMOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "VM-Tier01", GetVMOptions.Builder .withPowerState())); @@ -190,8 +191,8 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testVMWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVMInVDC", String.class, String.class, String.class, - GetVMOptions[].class)); + Invokable method = method(BrowsingAsyncApi.class, "getVMInVDC", String.class, String.class, String.class, + GetVMOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22", "VM-Tier01")); assertRequestLineEquals(request, @@ -207,7 +208,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getTask", String.class)); + Invokable method = method(BrowsingAsyncApi.class, "getTask", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/task/1 HTTP/1.1"); @@ -222,7 +223,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest } public void testListFirewallRules() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("listFirewallRules", String.class, String.class)); + Invokable method = method(BrowsingAsyncApi.class, "listFirewallRules", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22")); assertRequestLineEquals(request, diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java index 1191a790c8..adb3012472 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java @@ -18,11 +18,12 @@ */ package org.jclouds.savvis.vpdc.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.domain.FirewallRule; import org.jclouds.savvis.vpdc.xml.TaskHandler; @@ -30,7 +31,7 @@ import org.jclouds.util.Strings2; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code FirewallAsyncApi} * @@ -40,8 +41,8 @@ import com.google.common.collect.ImmutableList; public class FirewallAsyncApiTest extends BaseVPDCAsyncApiTest { public void testAddFirewallRule() throws NoSuchMethodException, IOException { - Invokable method = Invokable.from(FirewallAsyncApi.class.getMethod("addFirewallRule", String.class, String.class, - FirewallRule.class)); + Invokable method = method(FirewallAsyncApi.class, "addFirewallRule", String.class, String.class, + FirewallRule.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", FirewallRule.builder().firewallType( "SERVER_TIER_FIREWALL").isEnabled(true).source("internet").destination("VM Tier01").port("22").protocol( "Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build())); @@ -59,8 +60,8 @@ public class FirewallAsyncApiTest extends BaseVPDCAsyncApiTest } public void testDeleteFirewallRule() throws NoSuchMethodException, IOException { - Invokable method = Invokable.from(FirewallAsyncApi.class.getMethod("deleteFirewallRule", String.class, String.class, - FirewallRule.class)); + Invokable method = method(FirewallAsyncApi.class, "deleteFirewallRule", String.class, String.class, + FirewallRule.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", FirewallRule.builder().firewallType( "SERVER_TIER_FIREWALL").isEnabled(true).source("internet").destination("VM Tier01").port("22").protocol( "Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build())); diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java index b65426ac25..1ac98c13fa 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java @@ -18,18 +18,19 @@ */ package org.jclouds.savvis.vpdc.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.xml.TaskHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code ServiceManagementAsyncApi} * @@ -39,8 +40,8 @@ import com.google.common.collect.ImmutableList; public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest { public void testPowerOnVMVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOnVMInVDC", String.class, String.class, - String.class)); + Invokable method = method(ServiceManagementAsyncApi.class, "powerOnVMInVDC", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, @@ -56,7 +57,7 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOnVM", URI.class)); + Invokable method = method(ServiceManagementAsyncApi.class, "powerOnVM", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33"))); @@ -73,8 +74,8 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOffVMInVDC", String.class, String.class, - String.class)); + Invokable method = method(ServiceManagementAsyncApi.class, "powerOffVMInVDC", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, @@ -90,7 +91,7 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOffVM", URI.class)); + Invokable method = method(ServiceManagementAsyncApi.class, "powerOffVM", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33"))); diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java index 2d04b19b51..b24377a09d 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.savvis.vpdc.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import java.util.Set; @@ -27,7 +29,6 @@ import org.jclouds.cim.OSType; import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.domain.VMSpec; import org.jclouds.savvis.vpdc.xml.TaskHandler; @@ -39,9 +40,9 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.reflect.Invokable; import com.google.inject.Key; import com.google.inject.TypeLiteral; - /** * Tests annotation parsing of {@code VMAsyncApi} * @@ -51,7 +52,7 @@ import com.google.inject.TypeLiteral; public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testAddVMIntoVDCURI() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("addVMIntoVDC", URI.class, VMSpec.class)); + Invokable method = method(VMAsyncApi.class, "addVMIntoVDC", URI.class, VMSpec.class); CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral>() { })), new Predicate() { @@ -81,7 +82,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testAddVMIntoVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("addVMIntoVDC", String.class, String.class, VMSpec.class)); + Invokable method = method(VMAsyncApi.class, "addVMIntoVDC", String.class, String.class, VMSpec.class); CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral>() { })), new Predicate() { @@ -109,7 +110,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testCaptureVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("captureVApp", String.class, String.class, URI.class)); + Invokable method = method(VMAsyncApi.class, "captureVApp", String.class, String.class, URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("100000.0", "2736", URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"))); assertRequestLineEquals(request, @@ -125,7 +126,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testCloneVApp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("cloneVApp", URI.class, String.class, String.class)); + Invokable method = method(VMAsyncApi.class, "cloneVApp", URI.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"), "clonedvm", "VM Tier01")); assertRequestLineEquals(request, @@ -141,7 +142,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testAddMultipleVMsIntoVDCURI() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("addMultipleVMsIntoVDC", URI.class, Iterable.class)); + Invokable method = method(VMAsyncApi.class, "addMultipleVMsIntoVDC", URI.class, Iterable.class); CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral>() { })), new Predicate() { @@ -171,8 +172,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testAddMultipleVMsIntoVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class - .getMethod("addMultipleVMsIntoVDC", String.class, String.class, Iterable.class)); + Invokable method = method(VMAsyncApi.class, "addMultipleVMsIntoVDC", String.class, String.class, Iterable.class); CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral>() { })), new Predicate() { @@ -200,7 +200,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testRemoveVMFromVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("removeVMFromVDC", String.class, String.class, String.class)); + Invokable method = method(VMAsyncApi.class, "removeVMFromVDC", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, @@ -216,7 +216,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testRemoveVM() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("removeVM", URI.class)); + Invokable method = method(VMAsyncApi.class, "removeVM", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33"))); @@ -233,7 +233,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testPowerOffVM() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("powerOffVM", URI.class)); + Invokable method = method(VMAsyncApi.class, "powerOffVM", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33"))); @@ -250,7 +250,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { } public void testPowerOnVM() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VMAsyncApi.class.getMethod("powerOnVM", URI.class)); + Invokable method = method(VMAsyncApi.class, "powerOnVM", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33"))); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java index b7d0052e53..f81ac7f3b3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -21,7 +21,7 @@ package org.jclouds.vcloud.director.v1_5; import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE; @@ -45,7 +45,7 @@ import com.google.common.reflect.TypeToken; */ public class VCloudDirectorApiMetadata extends BaseRestApiMetadata { - public static final TypeToken CONTEXT_TOKEN = typeTokenOf(VCloudDirectorContext.class); + public static final TypeToken CONTEXT_TOKEN = typeToken(VCloudDirectorContext.class); @Override public Builder toBuilder() { @@ -89,7 +89,7 @@ public class VCloudDirectorApiMetadata extends BaseRestApiMetadata { .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.5") .defaultProperties(VCloudDirectorApiMetadata.defaultProperties()) - .context(typeTokenOf(VCloudDirectorContext.class)) + .context(typeToken(VCloudDirectorContext.class)) .defaultModule(VCloudDirectorRestClientModule.class); } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java index e9e296aeed..bf6a19960a 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java @@ -20,7 +20,7 @@ package org.jclouds.loadbalancer; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Predicates2.retry; import static org.testng.Assert.assertNotNull; @@ -184,6 +184,6 @@ public abstract class BaseLoadBalancerServiceLiveTest extends BaseViewLiveTest viewType() { - return typeTokenOf(LoadBalancerServiceContext.class); + return typeToken(LoadBalancerServiceContext.class); } } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java index cd40a0c8e1..917d786e53 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java @@ -18,7 +18,8 @@ */ package org.jclouds.loadbalancer.internal; -import static org.jclouds.reflect.Reflection2.typeTokenOf; + +import static org.jclouds.reflect.Reflection2.typeToken; import org.jclouds.View; import org.jclouds.apis.ApiMetadata; @@ -37,7 +38,7 @@ import com.google.common.reflect.TypeToken; public abstract class BaseLoadBalancerServiceApiMetadataTest extends BaseApiMetadataTest { public BaseLoadBalancerServiceApiMetadataTest(ApiMetadata toTest) { - super(toTest, ImmutableSet.>of(typeTokenOf(LoadBalancerServiceContext.class))); + super(toTest, ImmutableSet.>of(typeToken(LoadBalancerServiceContext.class))); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java index 106b4dd8ba..acace29e86 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java @@ -17,8 +17,7 @@ * under the License. */ package org.jclouds.aws.ec2.config; - -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Map; @@ -98,7 +97,7 @@ public class AWSEC2RestClientModule extends EC2RestClientModule method = Invokable.from(AWSAMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, - CreateImageOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -101,8 +101,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, - CreateImageOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() .withDescription("description").noReboot())); @@ -132,8 +132,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, - DescribeImagesOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "describeImagesInRegion", String.class, + DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -167,8 +167,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, - DescribeImagesOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "describeImagesInRegion", String.class, + DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( "1", "2"))); @@ -199,7 +199,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "deregisterImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -230,8 +230,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, - String.class, RegisterImageOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -262,8 +262,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, - String.class, RegisterImageOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() .withDescription("description"))); @@ -297,8 +297,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, - String.class, String.class, RegisterImageBackedByEbsOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -338,8 +338,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, - String.class, String.class, RegisterImageBackedByEbsOptions[].class)); + Invokable method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100))); @@ -372,8 +372,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class, - String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "getBlockDeviceMappingsForImageInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -404,7 +404,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "getLaunchPermissionForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -439,8 +439,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion", String.class, - Iterable.class, Iterable.class, String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "addLaunchPermissionsToImageInRegion", String.class, + Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -476,8 +476,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion", String.class, - Iterable.class, Iterable.class, String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "removeLaunchPermissionsFromImageInRegion", String.class, + Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -508,8 +508,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class, - String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "resetLaunchPermissionsOnImageInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -526,7 +526,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("getProductCodesForImageInRegion", String.class, String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "getProductCodesForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -543,8 +543,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("addProductCodesToImageInRegion", String.class, Iterable.class, - String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "addProductCodesToImageInRegion", String.class, Iterable.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -562,8 +562,8 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("removeProductCodesFromImageInRegion", String.class, - Iterable.class, String.class)); + Invokable method = method(AWSAMIAsyncClient.class, "removeProductCodesFromImageInRegion", String.class, + Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java index 7e9136590f..0f1826882d 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.util.Map; @@ -39,13 +41,12 @@ import org.jclouds.ec2.xml.UnencodeStringValueHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.collect.Maps; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSInstanceAsyncClient} * @@ -56,7 +57,7 @@ import com.google.common.collect.Maps; @Test(groups = "unit", testName = "AWSInstanceAsyncClientTest") public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest { public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -72,7 +73,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -88,7 +89,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class, String[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "terminateInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -104,8 +105,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, - String.class, int.class, int.class, RunInstancesOptions[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -120,8 +121,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, - String.class, int.class, int.class, RunInstancesOptions[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, Lists. newArrayList("us-east-1", @@ -146,8 +147,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("stopInstancesInRegion", String.class, boolean.class, - String[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "stopInstancesInRegion", String.class, boolean.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -163,8 +164,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, - String[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "rebootInstancesInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -180,8 +181,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, - String[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "startInstancesInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -197,8 +198,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getUserDataForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -215,8 +216,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getRootDeviceNameForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -233,8 +234,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getRamdiskForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -252,8 +253,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", - String.class, String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "isApiTerminationDisabledForInstanceInRegion", + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -270,8 +271,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class - .getMethod("getKernelForInstanceInRegion", String.class, String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getKernelForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -287,8 +287,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getInstanceTypeForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -306,8 +306,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion", - String.class, String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion", + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -326,8 +326,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "getBlockDeviceMappingForInstanceInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -358,8 +358,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion", String.class, String.class, - byte[].class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setUserDataForInstanceInRegion", String.class, String.class, + byte[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -391,8 +391,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion", String.class, String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setRamdiskForInstanceInRegion", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -424,8 +424,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion", String.class, String.class, - String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setKernelForInstanceInRegion", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -458,8 +458,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setApiTerminationDisabledForInstanceInRegion", String.class, - String.class, boolean.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setApiTerminationDisabledForInstanceInRegion", String.class, + String.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -491,8 +491,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion", String.class, - String.class, String.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setInstanceTypeForInstanceInRegion", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -525,8 +525,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setInstanceInitiatedShutdownBehaviorForInstanceInRegion", - String.class, String.class, InstanceInitiatedShutdownBehavior.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion", + String.class, String.class, InstanceInitiatedShutdownBehavior.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -545,8 +545,8 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setBlockDeviceMappingForInstanceInRegion", String.class, - String.class, Map.class)); + Invokable method = method(AWSInstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class, + String.class, Map.class); Map mapping = Maps.newLinkedHashMap(); mapping.put("/dev/sda1", new BlockDevice("vol-test1", true)); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java index ab13528d48..270ca84132 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,12 +28,11 @@ import org.jclouds.ec2.xml.KeyPairResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSKeyPairAsyncClient} * @@ -42,7 +43,7 @@ import com.google.common.collect.Lists; public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest { public void testCreateKeyPair() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("createKeyPairInRegion", String.class, String.class)); + Invokable method = method(AWSKeyPairAsyncClient.class, "createKeyPairInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -71,8 +72,8 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("importKeyPairInRegion", String.class, String.class, - String.class)); + Invokable method = method(AWSKeyPairAsyncClient.class, "importKeyPairInRegion", String.class, String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey", "ssh-rsa AA")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -90,7 +91,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class)); + Invokable method = method(AWSKeyPairAsyncClient.class, "deleteKeyPairInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -106,8 +107,8 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, - String[].class)); + Invokable method = method(AWSKeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -123,8 +124,8 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, - String[].class)); + Invokable method = method(AWSKeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java index dfa232b858..3defddcbbe 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -29,13 +31,12 @@ import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSSecurityGroupAsyncClient} * @@ -50,8 +51,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegionById", String.class, - String.class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "deleteSecurityGroupInRegionById", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -67,8 +68,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegionById", String.class, - String[].class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "describeSecurityGroupsInRegionById", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -84,8 +85,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegionById", String.class, - String[].class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "describeSecurityGroupsInRegionById", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -114,8 +115,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion", String.class, - String.class, String.class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "createSecurityGroupInRegion", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -133,8 +134,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", - String.class, String.class, IpPermission.class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", + String.class, String.class, IpPermission.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -152,8 +153,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", - String.class, String.class, Iterable.class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", + String.class, String.class, Iterable.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0) .originatingFromSecurityGroupId("groupId")))); @@ -173,8 +174,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, - String.class, IpPermission.class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + String.class, IpPermission.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -192,8 +193,8 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, - String.class, Iterable.class)); + Invokable method = method(AWSSecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + String.class, Iterable.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0) .originatingFromSecurityGroupId("groupId")))); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java index 05c2997f36..e90fe42e5a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.aws.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.aws.ec2.xml.MonitoringStateHandler; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code MonitoringAsyncClient} * @@ -38,8 +39,8 @@ import com.google.common.collect.Lists; public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest { public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(MonitoringAsyncClient.class.getMethod("unmonitorInstancesInRegion", String.class, String.class, - String[].class)); + Invokable method = method(MonitoringAsyncClient.class, "unmonitorInstancesInRegion", String.class, String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -55,8 +56,8 @@ public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(MonitoringAsyncClient.class.getMethod("monitorInstancesInRegion", String.class, String.class, - String[].class)); + Invokable method = method(MonitoringAsyncClient.class, "monitorInstancesInRegion", String.class, String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java index 41713adf92..a2eb4a03ab 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,12 +28,11 @@ import org.jclouds.aws.ec2.xml.DescribePlacementGroupsResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code PlacementGroupAsyncClient} * @@ -42,8 +43,8 @@ import com.google.common.collect.Lists; public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest { public void testDeletePlacementGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("deletePlacementGroupInRegion", String.class, - String.class)); + Invokable method = method(PlacementGroupAsyncClient.class, "deletePlacementGroupInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -72,8 +73,8 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("createPlacementGroupInRegion", String.class, - String.class, String.class)); + Invokable method = method(PlacementGroupAsyncClient.class, "createPlacementGroupInRegion", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "cluster")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -91,8 +92,8 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("createPlacementGroupInRegion", String.class, - String.class)); + Invokable method = method(PlacementGroupAsyncClient.class, "createPlacementGroupInRegion", String.class, + String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -108,8 +109,8 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("describePlacementGroupsInRegion", String.class, - String[].class)); + Invokable method = method(PlacementGroupAsyncClient.class, "describePlacementGroupsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -125,8 +126,8 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("describePlacementGroupsInRegion", String.class, - String[].class)); + Invokable method = method(PlacementGroupAsyncClient.class, "describePlacementGroupsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java index 5a33767bb5..4e34e70265 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.ec2.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.util.Date; @@ -32,13 +34,12 @@ import org.jclouds.aws.ec2.xml.SpotInstancesHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SpotInstanceAsyncClient} * @@ -63,8 +64,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("requestSpotInstanceInRegion", String.class, - float.class, String.class, String.class)); + Invokable method = method(SpotInstanceAsyncClient.class, "requestSpotInstanceInRegion", String.class, + float.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, 0.01f, "m1.small", "ami-voo")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -104,8 +105,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("requestSpotInstancesInRegion", String.class, - float.class, int.class, LaunchSpecification.class, RequestSpotInstancesOptions[].class)); + Invokable method = method(SpotInstanceAsyncClient.class, "requestSpotInstancesInRegion", String.class, + float.class, int.class, LaunchSpecification.class, RequestSpotInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", 0.01, 3, LaunchSpecification.builder().instanceType("m1.small").imageId("ami-voo").availabilityZone("eu-west-1a") .kernelId("kernelId").securityGroupName("group1").build(), new RequestSpotInstancesOptions().validFrom(from) @@ -126,8 +127,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("cancelSpotInstanceRequestsInRegion", String.class, - String[].class)); + Invokable method = method(SpotInstanceAsyncClient.class, "cancelSpotInstanceRequestsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -143,8 +144,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotInstanceRequestsInRegion", String.class, - String[].class)); + Invokable method = method(SpotInstanceAsyncClient.class, "describeSpotInstanceRequestsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -160,8 +161,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotInstanceRequestsInRegion", String.class, - String[].class)); + Invokable method = method(SpotInstanceAsyncClient.class, "describeSpotInstanceRequestsInRegion", String.class, + String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -179,8 +180,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotPriceHistoryInRegion", String.class, - DescribeSpotPriceHistoryOptions[].class)); + Invokable method = method(SpotInstanceAsyncClient.class, "describeSpotPriceHistoryInRegion", String.class, + DescribeSpotPriceHistoryOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -199,8 +200,8 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotPriceHistoryInRegion", String.class, - DescribeSpotPriceHistoryOptions[].class)); + Invokable method = method(SpotInstanceAsyncClient.class, "describeSpotPriceHistoryInRegion", String.class, + DescribeSpotPriceHistoryOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, DescribeSpotPriceHistoryOptions.Builder.from(from) .to(to).productDescription("description").instanceType("m1.small"))); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java index 3875461be2..1a503b8153 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java @@ -18,7 +18,7 @@ */ package org.jclouds.aws.s3; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.util.Properties; @@ -69,7 +69,7 @@ public class AWSS3ApiMetadata extends S3ApiMetadata { .name("Amazon-specific S3 API") .defaultProperties(AWSS3ApiMetadata.defaultProperties()) .context(CONTEXT_TOKEN) - .view(typeTokenOf(AWSS3BlobStoreContext.class)) + .view(typeToken(AWSS3BlobStoreContext.class)) .defaultModules(ImmutableSet.>of(AWSS3RestClientModule.class, AWSS3BlobStoreContextModule.class)); } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java index d0050b8e95..13dd7959f1 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java @@ -19,7 +19,7 @@ package org.jclouds.aws.s3.config; import static org.jclouds.aws.domain.Region.US_STANDARD; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import javax.inject.Singleton; @@ -47,7 +47,7 @@ import com.google.inject.Provides; public class AWSS3RestClientModule extends S3RestClientModule { public AWSS3RestClientModule() { - super(typeTokenOf(AWSS3Client.class), typeTokenOf(AWSS3AsyncClient.class)); + super(typeToken(AWSS3Client.class), typeToken(AWSS3AsyncClient.class)); } @Override diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java index 2200546090..0e1524738b 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.aws.s3; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.util.Map; import java.util.Set; @@ -36,7 +38,6 @@ import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.location.Region; -import com.google.common.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.s3.S3AsyncClient; @@ -59,8 +60,8 @@ import com.google.common.cache.CacheLoader; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.google.common.reflect.Invokable; import com.google.inject.Module; - /** * @author Adrian Cole */ @@ -73,14 +74,14 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testCopyObjectInvalidName() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { // For AWS S3, S3AsyncClientTest#testCopyObjectInvalidName() will not throw an exception - Invokable method = Invokable.from(S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class, + Invokable method = method(S3AsyncClient.class, "copyObject", String.class, String.class, String.class, String.class, - CopyObjectOptions[].class)); + CopyObjectOptions[].class); processor.createRequest(method, ImmutableList. of("sourceBucket", "sourceObject", "destinationbucket", "destinationObject")); } public void testGetBucketLocationEUIsStillDefault() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class)); + Invokable method = method(AWSS3AsyncClient.class, "getBucketLocation", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket-eu-west-1")); assertRequestLineEquals(request, "GET https://bucket-eu-west-1.s3.amazonaws.com/?location HTTP/1.1"); @@ -98,8 +99,8 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testPutObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("putObject", String.class, S3Object.class, - PutObjectOptions[].class)); + Invokable method = method(AWSS3AsyncClient.class, "putObject", String.class, S3Object.class, + PutObjectOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB))); @@ -116,7 +117,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { @Override public void testGetBucketLocation() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class)); + Invokable method = method(AWSS3AsyncClient.class, "getBucketLocation", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket.s3.amazonaws.com/?location HTTP/1.1"); @@ -141,8 +142,8 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { @Override public void testPutBucketDefault() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, - PutBucketOptions[].class)); + Invokable method = method(AWSS3AsyncClient.class, "putBucketInRegion", String.class, String.class, + PutBucketOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "bucket")); assertRequestLineEquals(request, "PUT https://bucket.s3.amazonaws.com/ HTTP/1.1"); @@ -158,8 +159,8 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testInitiateMultipartUpload() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("initiateMultipartUpload", String.class, ObjectMetadata.class, - PutObjectOptions[].class)); + Invokable method = method(AWSS3AsyncClient.class, "initiateMultipartUpload", String.class, ObjectMetadata.class, + PutObjectOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", ObjectMetadataBuilder.create().key("foo") .contentMD5(new byte[] { 1, 2, 3, 4 }).build())); @@ -187,8 +188,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { } public void testAbortMultipartUpload() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { - Invokable method = Invokable.from(AWSS3AsyncClient.class - .getMethod("abortMultipartUpload", String.class, String.class, String.class)); + Invokable method = method(AWSS3AsyncClient.class, "abortMultipartUpload", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", "asdsadasdas", 1, Payloads.newStringPayload(""))); @@ -204,8 +204,8 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { } public void testUploadPart() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("uploadPart", String.class, String.class, int.class, - String.class, Payload.class)); + Invokable method = method(AWSS3AsyncClient.class, "uploadPart", String.class, String.class, int.class, + String.class, Payload.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", 1, "asdsadasdas", Payloads.newStringPayload(""))); @@ -222,8 +222,8 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testCompleteMultipartUpload() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("completeMultipartUpload", String.class, String.class, - String.class, Map.class)); + Invokable method = method(AWSS3AsyncClient.class, "completeMultipartUpload", String.class, String.class, + String.class, Map.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", "asdsadasdas", ImmutableMap. of(1, "\"a54357aff0632cce46d942af68356b38\""))); @@ -243,8 +243,8 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testPutBucketEu() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, - PutBucketOptions[].class)); + Invokable method = method(AWSS3AsyncClient.class, "putBucketInRegion", String.class, String.class, + PutBucketOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("EU", "bucket")); assertRequestLineEquals(request, "PUT https://bucket.s3.amazonaws.com/ HTTP/1.1"); diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java index 100fe0c60e..fd29d31da8 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java @@ -21,7 +21,7 @@ package org.jclouds.azureblob; import static java.util.concurrent.TimeUnit.MINUTES; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -86,7 +86,7 @@ public class AzureBlobApiMetadata extends BaseRestApiMetadata { .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) .defaultProperties(AzureBlobApiMetadata.defaultProperties()) - .view(typeTokenOf(BlobStoreContext.class)) + .view(typeToken(BlobStoreContext.class)) .defaultModules(ImmutableSet.>of(AzureBlobRestClientModule.class, AzureBlobStoreContextModule.class)); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java index 934f7a8e44..559e8b76f2 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java @@ -20,6 +20,7 @@ package org.jclouds.azureblob.blobstore; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; +import static org.jclouds.reflect.Reflection2.method; import javax.inject.Inject; import javax.inject.Singleton; @@ -58,12 +59,9 @@ public class AzureBlobRequestSigner implements BlobRequestSigner { this.processor = checkNotNull(processor, "processor"); this.blobToBlob = checkNotNull(blobToBlob, "blobToBlob"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - this.getMethod = Invokable.from(AzureBlobAsyncClient.class.getMethod("getBlob", String.class, String.class, - GetOptions[].class)); - this.deleteMethod = Invokable - .from(AzureBlobAsyncClient.class.getMethod("deleteBlob", String.class, String.class)); - this.createMethod = Invokable - .from(AzureBlobAsyncClient.class.getMethod("putBlob", String.class, AzureBlob.class)); + this.getMethod = method(AzureBlobAsyncClient.class, "getBlob", String.class, String.class, GetOptions[].class); + this.deleteMethod = method(AzureBlobAsyncClient.class, "deleteBlob", String.class, String.class); + this.createMethod = method(AzureBlobAsyncClient.class, "putBlob", String.class, AzureBlob.class); } @Override diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java index 4327090d90..57bf803374 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java @@ -20,6 +20,7 @@ package org.jclouds.azureblob; import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults; import static org.jclouds.azureblob.options.CreateContainerOptions.Builder.withPublicAccess; +import static org.jclouds.reflect.Reflection2.method; import static org.testng.Assert.assertEquals; import java.io.IOException; @@ -45,7 +46,6 @@ import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.options.GetOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; @@ -53,7 +53,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AzureBlobAsyncClient} * @@ -64,7 +64,7 @@ import com.google.common.collect.ImmutableMultimap; public class AzureBlobAsyncClientTest extends BaseAsyncClientTest { public void testListContainers() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listContainers", ListOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "listContainers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/?comp=list HTTP/1.1"); @@ -78,7 +78,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listContainers", ListOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "listContainers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(maxResults(1).marker("marker").prefix("prefix"))); assertRequestLineEquals(request, @@ -92,8 +92,8 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createContainer", String.class, - CreateContainerOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "createContainer", String.class, + CreateContainerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, @@ -107,7 +107,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("deleteContainer", String.class)); + Invokable method = method(AzureBlobAsyncClient.class, "deleteContainer", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, @@ -121,8 +121,8 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createContainer", String.class, - CreateContainerOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "createContainer", String.class, + CreateContainerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", withPublicAccess(PublicAccess.BLOB) .withMetadata(ImmutableMultimap.of("foo", "bar")))); @@ -138,7 +138,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createRootContainer", CreateContainerOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "createRootContainer", CreateContainerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); @@ -152,7 +152,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("deleteRootContainer")); + Invokable method = method(AzureBlobAsyncClient.class, "deleteRootContainer"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "DELETE https://identity.blob.core.windows.net/$root?restype=container HTTP/1.1"); @@ -165,7 +165,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createRootContainer", CreateContainerOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "createRootContainer", CreateContainerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withPublicAccess(PublicAccess.BLOB).withMetadata( ImmutableMultimap.of("foo", "bar")))); @@ -180,7 +180,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listBlobs", String.class, ListBlobsOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "listBlobs", String.class, ListBlobsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, @@ -194,7 +194,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listBlobs", ListBlobsOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "listBlobs", ListBlobsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, @@ -208,7 +208,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("getContainerProperties", String.class)); + Invokable method = method(AzureBlobAsyncClient.class, "getContainerProperties", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, @@ -222,7 +222,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("getPublicAccessForContainer", String.class)); + Invokable method = method(AzureBlobAsyncClient.class, "getPublicAccessForContainer", String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, @@ -236,7 +236,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("setResourceMetadata", String.class, Map.class)); + Invokable method = method(AzureBlobAsyncClient.class, "setResourceMetadata", String.class, Map.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", ImmutableMap.of("key", "value"))); @@ -251,7 +251,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("getBlob", String.class, String.class, GetOptions[].class)); + Invokable method = method(AzureBlobAsyncClient.class, "getBlob", String.class, String.class, GetOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", "blob")); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/container/blob HTTP/1.1"); @@ -264,7 +264,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("setBlobMetadata", String.class, String.class, Map.class)); + Invokable method = method(AzureBlobAsyncClient.class, "setBlobMetadata", String.class, String.class, Map.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", "blob", ImmutableMap.of("key", "value"))); assertRequestLineEquals(request, diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java index 1266ad4bb3..bc6ba1ff48 100644 --- a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java +++ b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java @@ -21,7 +21,7 @@ package org.jclouds.glesys; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -84,7 +84,7 @@ public class GleSYSApiMetadata extends BaseRestApiMetadata { .buildVersion("3.5.0") .defaultEndpoint("https://api.glesys.com") .defaultProperties(GleSYSApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(GleSYSComputeServiceContextModule.class, GleSYSRestClientModule.class)); } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java index b932d49df1..4965cfac02 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java @@ -20,7 +20,7 @@ package org.jclouds.gogrid; import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -80,7 +80,7 @@ public class GoGridApiMetadata extends BaseRestApiMetadata { .version(GoGridAsyncClient.VERSION) .defaultEndpoint("https://api.gogrid.com/api") .defaultProperties(GoGridApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(GoGridRestClientModule.class, GoGridComputeServiceContextModule.class)); } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java index dcc80dc49e..c8e435d32f 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.gogrid.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; @@ -27,13 +29,12 @@ import org.jclouds.gogrid.functions.ParseImageFromJsonResponse; import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse; import org.jclouds.gogrid.options.GetImageListOptions; import org.jclouds.gogrid.options.SaveImageOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridImageAsyncClient} * @@ -46,7 +47,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("getImageList", GetImageListOptions[].class)); + Invokable method = method(GridImageAsyncClient.class, "getImageList", GetImageListOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest( method, ImmutableList. of( new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE) @@ -73,7 +74,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("getImagesByName", String[].class)); + Invokable method = method(GridImageAsyncClient.class, "getImagesByName", String[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name1", "name2")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&" @@ -96,7 +97,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("editImageDescription", String.class, String.class)); + Invokable method = method(GridImageAsyncClient.class, "editImageDescription", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("imageName", "newDesc")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&" @@ -119,7 +120,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("editImageFriendlyName", String.class, String.class)); + Invokable method = method(GridImageAsyncClient.class, "editImageFriendlyName", String.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("imageName", "newFriendlyName")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&" @@ -143,7 +144,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("deleteById", long.class)); + Invokable method = method(GridImageAsyncClient.class, "deleteById", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1"); @@ -157,8 +158,8 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("saveImageFromServer", String.class, String.class, - SaveImageOptions[].class)); + Invokable method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class, + SaveImageOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("friendly", "serverName")); assertRequestLineEquals(httpRequest, @@ -174,8 +175,8 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("saveImageFromServer", String.class, String.class, - SaveImageOptions[].class)); + Invokable method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class, + SaveImageOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("friendly", "serverName", new SaveImageOptions().withDescription("fooy"))); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java index 3791023a30..e118167ae4 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java @@ -18,18 +18,19 @@ */ package org.jclouds.gogrid.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.gogrid.domain.IpType; import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse; import org.jclouds.gogrid.options.GetIpListOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridIpAsyncClient} * @@ -41,7 +42,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridIpAsyncClient.class.getMethod("getIpList", GetIpListOptions[].class)); + Invokable method = method(GridIpAsyncClient.class, "getIpList", GetIpListOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(new GetIpListOptions() .onlyUnassigned().onlyWithType(IpType.PUBLIC))); @@ -65,7 +66,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridIpAsyncClient.class.getMethod("getAssignedIpList")); + Invokable method = method(GridIpAsyncClient.class, "getAssignedIpList"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java index a05004417e..6a77ac220e 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java @@ -19,6 +19,7 @@ package org.jclouds.gogrid.services; import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate; +import static org.jclouds.reflect.Reflection2.method; import java.io.IOException; import java.util.Date; @@ -27,13 +28,12 @@ import org.jclouds.gogrid.domain.JobState; import org.jclouds.gogrid.domain.ObjectType; import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse; import org.jclouds.gogrid.options.GetJobListOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridJobAsyncClient} * @@ -45,7 +45,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobList", GetJobListOptions[].class)); + Invokable method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class); GeneratedHttpRequest httpRequest = processor .createRequest(method, ImmutableList. of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L)) .onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING))); @@ -73,7 +73,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobList", GetJobListOptions[].class)); + Invokable method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1"); @@ -83,7 +83,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobsForObjectName", String.class)); + Invokable method = method(GridJobAsyncClient.class, "getJobsForObjectName", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("MyServer")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&" @@ -106,7 +106,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobsById", long[].class)); + Invokable method = method(GridJobAsyncClient.class, "getJobsById", long[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L, 456L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&" diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java index 25c2d012f8..e9149f75b7 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.gogrid.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.util.List; @@ -29,13 +31,12 @@ import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse; import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse; import org.jclouds.gogrid.options.AddLoadBalancerOptions; import org.jclouds.http.HttpRequest; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridLoadBalancerAsyncClient} * @@ -47,7 +48,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancerList")); + Invokable method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancerList"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1"); @@ -84,8 +85,8 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class, IpPortPair.class, - List.class, AddLoadBalancerOptions[].class)); + Invokable method = method(GridLoadBalancerAsyncClient.class, "addLoadBalancer", String.class, IpPortPair.class, + List.class, AddLoadBalancerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("BalanceIt", IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(), ImmutableList.of(IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), @@ -108,7 +109,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", long.class, List.class)); + Invokable method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancer", long.class, List.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1l, ImmutableList.of( IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()))); @@ -135,7 +136,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancerNamed", String.class, List.class)); + Invokable method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancerNamed", String.class, List.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("BalanceIt", ImmutableList.of( IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()))); @@ -162,7 +163,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName", String[].class)); + Invokable method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancersByName", String[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( "My Load Balancer", "My Load Balancer 2")); @@ -187,7 +188,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("deleteById", Long.class)); + Invokable method = method(GridLoadBalancerAsyncClient.class, "deleteById", Long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(55L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java index ad6dc2a57c..6a3ee7906a 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.gogrid.services; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -26,13 +28,12 @@ import org.jclouds.gogrid.domain.PowerCommand; import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse; import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse; import org.jclouds.gogrid.options.GetServerListOptions; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridServerAsyncClient} * @@ -44,7 +45,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServerList", GetServerListOptions[].class)); + Invokable method = method(GridServerAsyncClient.class, "getServerList", GetServerListOptions[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( new GetServerListOptions.Builder().onlySandboxServers())); @@ -67,7 +68,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServersByName", String[].class)); + Invokable method = method(GridServerAsyncClient.class, "getServersByName", String[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("server1")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1"); @@ -88,7 +89,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServersById", long[].class)); + Invokable method = method(GridServerAsyncClient.class, "getServersById", long[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1"); @@ -110,7 +111,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("power", String.class, PowerCommand.class)); + Invokable method = method(GridServerAsyncClient.class, "power", String.class, PowerCommand.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("PowerServer", PowerCommand.RESTART)); @@ -133,7 +134,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("deleteByName", String.class)); + Invokable method = method(GridServerAsyncClient.class, "deleteByName", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("PowerServer")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&" @@ -155,7 +156,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getRamSizes")); + Invokable method = method(GridServerAsyncClient.class, "getRamSizes"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram " @@ -178,7 +179,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServerCredentials", long.class)); + Invokable method = method(GridServerAsyncClient.class, "getServerCredentials", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(httpRequest, @@ -193,7 +194,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getTypes")); + Invokable method = method(GridServerAsyncClient.class, "getTypes"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -208,7 +209,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("editServerDescription", long.class, String.class)); + Invokable method = method(GridServerAsyncClient.class, "editServerDescription", long.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "newDesc")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" @@ -230,7 +231,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("editServerRam", long.class, String.class)); + Invokable method = method(GridServerAsyncClient.class, "editServerRam", long.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "1GB")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" @@ -252,7 +253,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("editServerType", long.class, String.class)); + Invokable method = method(GridServerAsyncClient.class, "editServerType", long.class, String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "web")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java index 456ede0de4..db1adffadb 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java @@ -28,7 +28,7 @@ import static com.google.common.io.BaseEncoding.base16; import static com.google.common.io.ByteStreams.readBytes; import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; import static org.jclouds.crypto.Macs.asByteProcessor; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.util.Strings2.toInputStream; import java.io.IOException; @@ -59,7 +59,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.io.ByteProcessor; import com.google.common.reflect.Invokable; -import com.google.common.reflect.TypeToken; import com.google.inject.Provider; /** @@ -100,12 +99,9 @@ public class HPCloudObjectStorageBlobRequestSigner implements BlobRequestSigner this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - Class interfaceClass = HPCloudObjectStorageAsyncApi.class; - TypeToken interfaceType = typeTokenOf(HPCloudObjectStorageAsyncApi.class); - this.getMethod = interfaceType.method(interfaceClass.getMethod("getObject", String.class, String.class, - GetOptions[].class)); - this.deleteMethod = interfaceType.method(interfaceClass.getMethod("removeObject", String.class, String.class)); - this.createMethod = interfaceType.method(interfaceClass.getMethod("putObject", String.class, SwiftObject.class)); + this.getMethod = method(HPCloudObjectStorageAsyncApi.class, "getObject", String.class, String.class, GetOptions[].class); + this.deleteMethod = method(HPCloudObjectStorageAsyncApi.class, "removeObject", String.class, String.class); + this.createMethod = method(HPCloudObjectStorageAsyncApi.class, "putObject", String.class, SwiftObject.class); } @Override diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java index b8f148aead..bb1f81b391 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java @@ -17,8 +17,7 @@ * under the License. */ package org.jclouds.hpcloud.objectstorage.config; - -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import static org.jclouds.util.Suppliers2.getLastValueInMap; import java.net.URI; @@ -55,7 +54,7 @@ public class HPCloudObjectStorageRestClientModule extends CDNContainerApi.class, CDNContainerAsyncApi.class).build(); public HPCloudObjectStorageRestClientModule() { - super(typeTokenOf(HPCloudObjectStorageApi.class), typeTokenOf(HPCloudObjectStorageAsyncApi.class), + super(typeToken(HPCloudObjectStorageApi.class), typeToken(HPCloudObjectStorageAsyncApi.class), DELEGATE_MAP); } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java index 842a00cab8..1f751f7105 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java @@ -21,7 +21,7 @@ package org.jclouds.softlayer; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; -import static org.jclouds.reflect.Reflection2.typeTokenOf; +import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; import java.util.Properties; @@ -82,7 +82,7 @@ public class SoftLayerApiMetadata extends BaseRestApiMetadata { .version("3") .defaultEndpoint("https://api.softlayer.com/rest") .defaultProperties(SoftLayerApiMetadata.defaultProperties()) - .view(typeTokenOf(ComputeServiceContext.class)) + .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of(SoftLayerRestClientModule.class, SoftLayerComputeServiceContextModule.class)); } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java index 93fe09e067..fdafc49fe0 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.softlayer.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseJson; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code AccountAsyncClient} * @@ -37,7 +38,7 @@ import com.google.common.collect.ImmutableList; public class AccountAsyncClientTest extends BaseSoftLayerAsyncClientTest { public void testGetActivePackages() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(AccountAsyncClient.class.getMethod("getActivePackages")); + Invokable method = method(AccountAsyncClient.class, "getActivePackages"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals( diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java index 99a054ad0a..ff357ab776 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java @@ -18,18 +18,19 @@ */ package org.jclouds.softlayer.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseJson; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code DatacenterAsyncClient} * @@ -39,7 +40,7 @@ import com.google.common.collect.Iterables; public class DatacenterAsyncClientTest extends BaseSoftLayerAsyncClientTest { public void testListDatacenters() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(DatacenterAsyncClient.class.getMethod("listDatacenters")); + Invokable method = method(DatacenterAsyncClient.class, "listDatacenters"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, @@ -68,7 +69,7 @@ public class DatacenterAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(DatacenterAsyncClient.class.getMethod("getDatacenter", long.class)); + Invokable method = method(DatacenterAsyncClient.class, "getDatacenter", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java index 2bb6307b53..7470791a65 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java @@ -18,16 +18,17 @@ */ package org.jclouds.softlayer.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.http.functions.ParseJson; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code ProductPackageAsyncClient} * @@ -37,7 +38,7 @@ import com.google.common.collect.ImmutableList; public class ProductPackageAsyncClientTest extends BaseSoftLayerAsyncClientTest { public void testGetProductPackage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(ProductPackageAsyncClient.class.getMethod("getProductPackage", long.class)); + Invokable method = method(ProductPackageAsyncClient.class, "getProductPackage", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals( diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java index 222f8a62b9..2cd6daf5cd 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java @@ -18,6 +18,8 @@ */ package org.jclouds.softlayer.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; @@ -25,13 +27,12 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.http.functions.ParseJson; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; - +import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code VirtualGuestAsyncClient} * @@ -41,7 +42,7 @@ import com.google.common.collect.Iterables; public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest { public void testListVirtualGuests() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("listVirtualGuests")); + Invokable method = method(VirtualGuestAsyncClient.class, "listVirtualGuests"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals( @@ -72,7 +73,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("getVirtualGuest", long.class)); + Invokable method = method(VirtualGuestAsyncClient.class, "getVirtualGuest", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals( @@ -90,7 +91,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("rebootHardVirtualGuest", long.class)); + Invokable method = method(VirtualGuestAsyncClient.class, "rebootHardVirtualGuest", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, @@ -107,7 +108,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("powerOffVirtualGuest", long.class)); + Invokable method = method(VirtualGuestAsyncClient.class, "powerOffVirtualGuest", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, @@ -124,7 +125,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("powerOnVirtualGuest", long.class)); + Invokable method = method(VirtualGuestAsyncClient.class, "powerOnVirtualGuest", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, @@ -141,7 +142,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("pauseVirtualGuest", long.class)); + Invokable method = method(VirtualGuestAsyncClient.class, "pauseVirtualGuest", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, @@ -158,7 +159,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("resumeVirtualGuest", long.class)); + Invokable method = method(VirtualGuestAsyncClient.class, "resumeVirtualGuest", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java index 76e1b5ff27..3e41abe5bc 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.trmk.ecloud; +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions.Builder.disabled; import static org.testng.Assert.assertEquals; @@ -29,7 +30,6 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; -import com.google.common.reflect.Invokable; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.domain.Protocol; @@ -58,7 +58,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TerremarkECloudAsyncClient} * @@ -75,7 +75,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getNetwork", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))); @@ -91,7 +91,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testDelete() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteVApp", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "deleteVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"))); @@ -107,8 +107,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, - String.class, String.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "findNetworkInOrgVDCNamed", String.class, + String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1"); @@ -126,7 +126,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie * ignore parameter of catalog id since this doesn't work */ public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getCatalog", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getCatalog", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://catalog"))); assertRequestLineEquals(request, "GET https://catalog HTTP/1.1"); @@ -141,7 +141,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getVDC", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getVDC", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/vdc/1"))); assertRequestLineEquals(request, "GET https://vcloud/vdc/1 HTTP/1.1"); @@ -156,8 +156,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "instantiateVAppTemplateInVDC", URI.class, URI.class, + String.class, InstantiateVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), "name")); @@ -178,8 +178,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "instantiateVAppTemplateInVDC", URI.class, URI.class, + String.class, InstantiateVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), @@ -204,7 +204,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testActivatePublicIpInVDC() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("activatePublicIpInVDC", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "activatePublicIpInVDC", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))); @@ -220,7 +220,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getAllInternetServicesInVDC", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))); @@ -236,7 +236,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetInternetService() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getInternetService", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getInternetService", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12 HTTP/1.1"); @@ -251,7 +251,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testDeleteInternetService() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteInternetService", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "deleteInternetService", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/internetService/12 HTTP/1.1"); @@ -266,8 +266,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testAddInternetServiceToExistingIp() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, - String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "addInternetServiceToExistingIp", URI.class, + String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22)); @@ -287,8 +287,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testAddInternetServiceToExistingIpOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, - String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "addInternetServiceToExistingIp", URI.class, + String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22, disabled().withDescription("yahoo").monitorDisabled())); @@ -306,8 +306,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testAddNode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addNode", URI.class, String.class, String.class, - int.class, AddNodeOptions[].class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "addNode", URI.class, String.class, String.class, + int.class, AddNodeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22)); @@ -327,8 +327,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testAddNodeOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addNode", URI.class, String.class, String.class, - int.class, AddNodeOptions[].class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "addNode", URI.class, String.class, String.class, + int.class, AddNodeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22, AddNodeOptions.Builder.disabled().withDescription("yahoo"))); @@ -348,7 +348,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "findKeyPairInOrg", URI.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair")); @@ -364,8 +364,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testConfigureNodeWithDescription() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("configureNode", URI.class, String.class, - boolean.class, String.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "configureNode", URI.class, String.class, + boolean.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, "eggs")); @@ -383,8 +383,8 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testConfigureNodeNoDescription() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("configureNode", URI.class, String.class, - boolean.class, String.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "configureNode", URI.class, String.class, + boolean.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, null)); @@ -402,7 +402,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetNodes() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getNodes", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getNodes", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); @@ -417,7 +417,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteNode", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "deleteNode", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -432,7 +432,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetCustomizationOptionsOfCatalogItem() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getCustomizationOptions", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getCustomizationOptions", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/template/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/template/12 HTTP/1.1"); @@ -448,7 +448,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "listKeyPairsInOrg", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); @@ -465,12 +465,12 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie @Test(expectedExceptions = ResourceNotFoundException.class) public void testListKeyPairsInOrgNotFound() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "listKeyPairsInOrg", URI.class); processor.createRequest(method, ImmutableList. of(URI.create("d"))); } public void testGetKeyPair() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getKeyPair", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getKeyPair", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/key/12 HTTP/1.1"); @@ -485,7 +485,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteKeyPair", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "deleteKeyPair", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/key/12 HTTP/1.1"); @@ -500,7 +500,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetNode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getNode", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getNode", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -515,7 +515,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie } public void testGetExtendedInfo() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getVAppExtendedInfo", URI.class)); + Invokable method = method(TerremarkECloudAsyncClient.class, "getVAppExtendedInfo", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/vapp/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/vapp/12 HTTP/1.1"); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java index fae8cd6d6a..279e386ebd 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java @@ -18,19 +18,20 @@ */ package org.jclouds.trmk.ecloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.ecloud.BaseTerremarkECloudAsyncClientTest; import org.jclouds.trmk.vcloud_0_8.xml.DataCentersHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code DataCenterOperationsAsyncClient} * @@ -43,7 +44,7 @@ public class DataCenterOperationsAsyncClientTest extends BaseTerremarkECloudAsyncClientTest { public void testlistDataCenters() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(DataCenterOperationsAsyncClient.class.getMethod("listDataCenters", URI.class)); + Invokable method = method(DataCenterOperationsAsyncClient.class, "listDataCenters", URI.class); GeneratedHttpRequest request = processor .createRequest( method, ImmutableList. of( @@ -62,7 +63,7 @@ public class DataCenterOperationsAsyncClientTest extends } public void testlistDataCentersInOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(DataCenterOperationsAsyncClient.class.getMethod("listDataCentersInOrg", URI.class)); + Invokable method = method(DataCenterOperationsAsyncClient.class, "listDataCentersInOrg", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java index fe7c3c4bc8..ccf181541a 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java @@ -18,19 +18,20 @@ */ package org.jclouds.trmk.ecloud.features; +import static org.jclouds.reflect.Reflection2.method; + import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; import org.jclouds.http.functions.ParseSax; -import com.google.common.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.ecloud.BaseTerremarkECloudAsyncClientTest; import org.jclouds.trmk.ecloud.xml.TagNameToUsageCountHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; - +import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TagOperationsAsyncClient} * @@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableList; public class TagOperationsAsyncClientTest extends BaseTerremarkECloudAsyncClientTest { public void testgetTagNameToUsageCount() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TagOperationsAsyncClient.class.getMethod("getTagNameToUsageCount", URI.class)); + Invokable method = method(TagOperationsAsyncClient.class, "getTagNameToUsageCount", URI.class); GeneratedHttpRequest request = processor .createRequest( method, ImmutableList. of( @@ -61,7 +62,7 @@ public class TagOperationsAsyncClientTest extends BaseTerremarkECloudAsyncClient } public void testgetTagNameToUsageCountInOrg() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TagOperationsAsyncClient.class.getMethod("getTagNameToUsageCountInOrg", URI.class)); + Invokable method = method(TagOperationsAsyncClient.class, "getTagNameToUsageCountInOrg", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java index f1c8b02e9e..ca46846a83 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java @@ -19,6 +19,7 @@ package org.jclouds.trmk.vcloudexpress; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.CATALOG_XML; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.NETWORK_XML; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.ORG_XML; @@ -43,7 +44,6 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.providers.ProviderMetadata; -import com.google.common.reflect.Invokable; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ResourceNotFoundException; @@ -88,10 +88,10 @@ import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.google.common.reflect.Invokable; import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.TypeLiteral; - /** * Tests behavior of {@code TerremarkVCloudExpressAsyncClient} * @@ -108,7 +108,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getCatalogItem", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))); @@ -124,7 +124,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteVApp", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "deleteVApp", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"))); @@ -140,8 +140,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", - String.class, String.class, String.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "findCatalogItemInOrgCatalogNamed", + String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1 HTTP/1.1"); @@ -159,7 +159,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalog", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getCatalog", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://catalog"))); assertRequestLineEquals(request, "GET https://catalog HTTP/1.1"); @@ -174,7 +174,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getVDC", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getVDC", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/vdc/1"))); assertRequestLineEquals(request, "GET https://vcloud/vdc/1 HTTP/1.1"); @@ -189,8 +189,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, - URI.class, String.class, InstantiateVAppTemplateOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "instantiateVAppTemplateInVDC", URI.class, + URI.class, String.class, InstantiateVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), "name")); @@ -211,8 +211,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, - URI.class, String.class, InstantiateVAppTemplateOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "instantiateVAppTemplateInVDC", URI.class, + URI.class, String.class, InstantiateVAppTemplateOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), @@ -237,8 +237,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class, - String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "addInternetServiceToVDC", URI.class, + String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22)); @@ -256,8 +256,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class, - String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "addInternetServiceToVDC", URI.class, + String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22, disabled() .withDescription("yahoo"))); @@ -275,7 +275,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getAllInternetServicesInVDC", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))); @@ -291,7 +291,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getInternetService", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getInternetService", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12 HTTP/1.1"); @@ -306,7 +306,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteInternetService", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "deleteInternetService", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/internetService/12 HTTP/1.1"); @@ -321,8 +321,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, - String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "addInternetServiceToExistingIp", URI.class, + String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22)); @@ -340,8 +340,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, - String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "addInternetServiceToExistingIp", URI.class, + String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22, disabled().withDescription("yahoo"))); @@ -358,8 +358,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addNode", URI.class, String.class, - String.class, int.class, AddNodeOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "addNode", URI.class, String.class, + String.class, int.class, AddNodeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22)); @@ -377,8 +377,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addNode", URI.class, String.class, - String.class, int.class, AddNodeOptions[].class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "addNode", URI.class, String.class, + String.class, int.class, AddNodeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22, AddNodeOptions.Builder.disabled().withDescription("yahoo"))); @@ -396,7 +396,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "findKeyPairInOrg", URI.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair")); @@ -412,8 +412,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("configureNode", URI.class, String.class, - boolean.class, String.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "configureNode", URI.class, String.class, + boolean.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, "eggs")); @@ -431,8 +431,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("configureNode", URI.class, String.class, - boolean.class, String.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "configureNode", URI.class, String.class, + boolean.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, null)); @@ -450,7 +450,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getNodes", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getNodes", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); @@ -465,7 +465,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteNode", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "deleteNode", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -480,7 +480,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getCustomizationOptions", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getCustomizationOptions", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud/extensions/template/12/options/customization"))); @@ -497,7 +497,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "listKeyPairsInOrg", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); @@ -513,7 +513,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "listKeyPairsInOrg", URI.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((URI) null)); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); @@ -529,12 +529,12 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "listKeyPairsInOrg", URI.class); processor.createRequest(method, ImmutableList. of(URI.create("d"))); } public void testGetNode() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getNode", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getNode", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -549,7 +549,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getKeyPair", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "getKeyPair", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/key/12 HTTP/1.1"); @@ -564,7 +564,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteKeyPair", URI.class)); + Invokable method = method(TerremarkVCloudExpressAsyncClient.class, "deleteKeyPair", URI.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/key/12 HTTP/1.1");