Permalink
Browse files

Make the API more fluid and easier to use

  • Loading branch information...
1 parent 2985d0b commit e5fe10218e701ee90aaf8f1e0713cfdb47dbd69d @jfarcand jfarcand committed Jun 9, 2011
View
205 .../MethodBasedServiceDefinitionCreator.java → ...eator/MethodServiceDefinitionBuilder.java
@@ -23,7 +23,6 @@
import org.sonatype.restsimple.api.DefaultServiceDefinition;
import org.sonatype.restsimple.api.DeleteServiceHandler;
import org.sonatype.restsimple.api.GetServiceHandler;
-import org.sonatype.restsimple.api.MediaType;
import org.sonatype.restsimple.api.PostServiceHandler;
import org.sonatype.restsimple.api.PutServiceHandler;
import org.sonatype.restsimple.api.ServiceDefinition;
@@ -35,7 +34,7 @@
import java.lang.reflect.Method;
/**
- * A {@link ServiceDefinitionCreator} that generate on the fly {@link ServiceDefinition} from a class that follow the {@link ServiceDefinition} convention.
+ * A {@link ServiceDefinitionBuilder} that generate on the fly {@link ServiceDefinition} from a class that follow the {@link ServiceDefinition} convention.
* The {@link ServiceDefinition} convention is defined as:
* <p/>
* The following table described how a class' methods are mapped to {@link ServiceHandler} and {@link ServiceDefinition}
@@ -50,38 +49,30 @@
*/
@Named
@Singleton
-public class MethodBasedServiceDefinitionCreator implements ServiceDefinitionCreator {
+public class MethodServiceDefinitionBuilder implements ServiceDefinitionBuilder {
- private final static Logger logger = LoggerFactory.getLogger(MethodBasedServiceDefinitionCreator.class);
+ private final static Logger logger = LoggerFactory.getLogger(MethodServiceDefinitionBuilder.class);
+ private Class<?> type;
+ private ServiceDefinitionCreatorConfig config = ServiceDefinitionCreatorConfig.config();
- private final MediaType APPLICATION_JSON = new MediaType(ServiceDefinitionCreatorConfig.APPLICATION, ServiceDefinitionCreatorConfig.JSON);
+ @Override
+ public ServiceDefinitionBuilder type(Class<?> type) throws Exception {
+ this.type = type;
+ return this;
+ }
- /**
- * Create a {@link ServiceDefinition} from a Class. The mapping between the class methods and {@link ServiceHandler}
- * will be determined by the default's {@link ServiceDefinitionCreatorConfig} value.
- *
- * @param application a class
- * @return {@link ServiceDefinition}
- * @throws Exception
- */
- public ServiceDefinition create(Class<?> application) throws Exception {
- return create(application, new ServiceDefinitionCreatorConfig());
+ @Override
+ public ServiceDefinitionBuilder config(ServiceDefinitionCreatorConfig config) throws Exception {
+ this.config = config;
+ return this;
}
- /**
- * Create a {@link ServiceDefinition} from a Class by using the {@link ServiceDefinitionCreatorConfig} to get some hints about
- * how uri are generated.
- *
- * @param application a class
- * @param config {@link ServiceDefinitionCreatorConfig}
- * @return {@link ServiceDefinition}
- * @throws Exception
- */
- public ServiceDefinition create(Class<?> application, ServiceDefinitionCreatorConfig config) throws Exception {
+ @Override
+ public ServiceDefinition build() throws Exception {
ServiceDefinition serviceDefinition = new DefaultServiceDefinition();
- Method[] methods = application.getDeclaredMethods();
- Object instance = application.newInstance();
+ Method[] methods = type.getDeclaredMethods();
+ Object instance = type.newInstance();
for (Method method : methods) {
ServiceHandler serviceHandler = null;
Class[] types = method.getParameterTypes();
@@ -96,19 +87,19 @@ public ServiceDefinition create(Class<?> application, ServiceDefinitionCreatorCo
switch (methodMapper.getMethod()) {
case GET:
if (types.length == 1) {
- serviceHandler = new GetServiceHandler("/" + methodMapper.getMethodMappedTo() + "/:id", ActionGenerator.generate(instance, application, method));
+ serviceHandler = new GetServiceHandler("/" + methodMapper.getMethodMappedTo() + "/:id", ActionGenerator.generate(instance, type, method));
} else {
- serviceHandler = new GetServiceHandler("/" + methodMapper.getMethodMappedTo(), ActionGenerator.generate(instance, application, method));
+ serviceHandler = new GetServiceHandler("/" + methodMapper.getMethodMappedTo(), ActionGenerator.generate(instance, type, method));
}
break;
case POST:
- serviceHandler = new PostServiceHandler("/" + methodMapper.getMethodMappedTo(), ActionGenerator.generate(instance, application, method));
+ serviceHandler = new PostServiceHandler("/" + methodMapper.getMethodMappedTo(), ActionGenerator.generate(instance, type, method));
break;
case DELETE:
- serviceHandler = new DeleteServiceHandler("/" + methodMapper.getMethodMappedTo() + "/:id", ActionGenerator.generate(instance, application, method));
+ serviceHandler = new DeleteServiceHandler("/" + methodMapper.getMethodMappedTo() + "/:id", ActionGenerator.generate(instance, type, method));
break;
case PUT:
- serviceHandler = new PutServiceHandler("/" + methodMapper.getMethodMappedTo(), ActionGenerator.generate(instance, application, method));
+ serviceHandler = new PutServiceHandler("/" + methodMapper.getMethodMappedTo(), ActionGenerator.generate(instance, type, method));
break;
default:
throw new IllegalStateException();
@@ -219,81 +210,81 @@ public ServiceDefinition create(Class<?> application, ServiceDefinitionCreatorCo
mv.visitMaxs(6, 3);
mv.visitEnd();
}
- {
- mv = cw.visitMethod( ACC_PRIVATE + ACC_FINAL + ACC_STATIC, "getActionType",
- "(Lorg/sonatype/restsimple/api/ActionContext;)Ljava/lang/Object;",
- "(Lorg/sonatype/restsimple/api/ActionContext<Ljava/lang/Integer;>;)Ljava/lang/Object;",
- null );
- mv.visitCode();
- mv.visitVarInsn( ALOAD, 0 );
- mv.visitMethodInsn( INVOKEVIRTUAL, "org/sonatype/restsimple/api/ActionContext", "get",
- "()Ljava/lang/Object;" );
- mv.visitVarInsn( ASTORE, 1 );
- mv.visitLdcInsn( Type.getType( "Ljava/lang/String;" ) );
- mv.visitVarInsn( ALOAD, 1 );
- mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;" );
- mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "isAssignableFrom", "(Ljava/lang/Class;)Z" );
- Label l0 = new Label();
- mv.visitJumpInsn( IFEQ, l0 );
- mv.visitLdcInsn( Type.getType( "Ljava/lang/String;" ) );
- mv.visitVarInsn( ALOAD, 1 );
- mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/Class", "cast", "(Ljava/lang/Object;)Ljava/lang/Object;" );
- mv.visitTypeInsn( CHECKCAST, "java/lang/String" );
- mv.visitLdcInsn( "" );
- mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/String", "equalsIgnoreCase", "(Ljava/lang/String;)Z" );
- mv.visitJumpInsn( IFEQ, l0 );
- mv.visitVarInsn( ALOAD, 0 );
- mv.visitMethodInsn( INVOKEVIRTUAL, "org/sonatype/restsimple/api/ActionContext", "pathParams",
- "()Ljava/util/Map;" );
- mv.visitVarInsn( ASTORE, 2 );
- mv.visitVarInsn( ALOAD, 2 );
- mv.visitMethodInsn( INVOKEINTERFACE, "java/util/Map", "entrySet", "()Ljava/util/Set;" );
- mv.visitMethodInsn( INVOKEINTERFACE, "java/util/Set", "iterator", "()Ljava/util/Iterator;" );
- mv.visitVarInsn( ASTORE, 3 );
- Label l1 = new Label();
- mv.visitLabel( l1 );
- mv.visitFrame( Opcodes.F_APPEND, 3,
- new Object[]{ "java/lang/Object", "java/util/Map", "java/util/Iterator" }, 0, null );
- mv.visitVarInsn( ALOAD, 3 );
- mv.visitMethodInsn( INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z" );
- mv.visitJumpInsn( IFEQ, l0 );
- mv.visitVarInsn( ALOAD, 3 );
- mv.visitMethodInsn( INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;" );
- mv.visitTypeInsn( CHECKCAST, "java/util/Map$Entry" );
- mv.visitVarInsn( ASTORE, 4 );
- mv.visitVarInsn( ALOAD, 4 );
- mv.visitMethodInsn( INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;" );
- mv.visitTypeInsn( CHECKCAST, "java/lang/String" );
- mv.visitMethodInsn( INVOKEVIRTUAL, "java/lang/String", "isEmpty", "()Z" );
- Label l2 = new Label();
- mv.visitJumpInsn( IFNE, l2 );
- mv.visitVarInsn( ALOAD, 4 );
- mv.visitMethodInsn( INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;" );
- mv.visitVarInsn( ASTORE, 1 );
- mv.visitLabel( l2 );
- mv.visitFrame( Opcodes.F_SAME, 0, null, 0, null );
- mv.visitJumpInsn( GOTO, l1 );
- mv.visitLabel( l0 );
- mv.visitFrame( Opcodes.F_CHOP, 2, null, 0, null );
- mv.visitVarInsn( ALOAD, 1 );
- mv.visitInsn( ARETURN );
- mv.visitMaxs( 2, 5 );
- mv.visitEnd();
- }
- {
- mv = cw.visitMethod( ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "action",
- "(Lorg/sonatype/restsimple/api/ActionContext;)Ljava/lang/Object;", null,
- new String[]{ "org/sonatype/restsimple/api/ActionException" } );
- mv.visitCode();
- mv.visitVarInsn( ALOAD, 0 );
- mv.visitVarInsn( ALOAD, 1 );
- mv.visitMethodInsn( INVOKEVIRTUAL, className, "action",
- "(Lorg/sonatype/restsimple/api/ActionContext;)L" + returnType + ";" );
- mv.visitInsn( ARETURN );
- mv.visitMaxs( 2, 2 );
- mv.visitEnd();
- }
- cw.visitEnd();
+ {
+ mv = cw.visitMethod(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, "getActionType",
+ "(Lorg/sonatype/restsimple/api/ActionContext;)Ljava/lang/Object;",
+ "(Lorg/sonatype/restsimple/api/ActionContext<Ljava/lang/Integer;>;)Ljava/lang/Object;",
+ null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "org/sonatype/restsimple/api/ActionContext", "get",
+ "()Ljava/lang/Object;");
+ mv.visitVarInsn(ASTORE, 1);
+ mv.visitLdcInsn(Type.getType("Ljava/lang/String;"));
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "getClass", "()Ljava/lang/Class;");
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "isAssignableFrom", "(Ljava/lang/Class;)Z");
+ Label l0 = new Label();
+ mv.visitJumpInsn(IFEQ, l0);
+ mv.visitLdcInsn(Type.getType("Ljava/lang/String;"));
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "cast", "(Ljava/lang/Object;)Ljava/lang/Object;");
+ mv.visitTypeInsn(CHECKCAST, "java/lang/String");
+ mv.visitLdcInsn("");
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equalsIgnoreCase", "(Ljava/lang/String;)Z");
+ mv.visitJumpInsn(IFEQ, l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKEVIRTUAL, "org/sonatype/restsimple/api/ActionContext", "pathParams",
+ "()Ljava/util/Map;");
+ mv.visitVarInsn(ASTORE, 2);
+ mv.visitVarInsn(ALOAD, 2);
+ mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "entrySet", "()Ljava/util/Set;");
+ mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Set", "iterator", "()Ljava/util/Iterator;");
+ mv.visitVarInsn(ASTORE, 3);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitFrame(Opcodes.F_APPEND, 3,
+ new Object[]{"java/lang/Object", "java/util/Map", "java/util/Iterator"}, 0, null);
+ mv.visitVarInsn(ALOAD, 3);
+ mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z");
+ mv.visitJumpInsn(IFEQ, l0);
+ mv.visitVarInsn(ALOAD, 3);
+ mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;");
+ mv.visitTypeInsn(CHECKCAST, "java/util/Map$Entry");
+ mv.visitVarInsn(ASTORE, 4);
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;");
+ mv.visitTypeInsn(CHECKCAST, "java/lang/String");
+ mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "isEmpty", "()Z");
+ Label l2 = new Label();
+ mv.visitJumpInsn(IFNE, l2);
+ mv.visitVarInsn(ALOAD, 4);
+ mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;");
+ mv.visitVarInsn(ASTORE, 1);
+ mv.visitLabel(l2);
+ mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
+ mv.visitJumpInsn(GOTO, l1);
+ mv.visitLabel(l0);
+ mv.visitFrame(Opcodes.F_CHOP, 2, null, 0, null);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitInsn(ARETURN);
+ mv.visitMaxs(2, 5);
+ mv.visitEnd();
+ }
+ {
+ mv = cw.visitMethod(ACC_PUBLIC + ACC_BRIDGE + ACC_SYNTHETIC, "action",
+ "(Lorg/sonatype/restsimple/api/ActionContext;)Ljava/lang/Object;", null,
+ new String[]{"org/sonatype/restsimple/api/ActionException"});
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitMethodInsn(INVOKEVIRTUAL, className, "action",
+ "(Lorg/sonatype/restsimple/api/ActionContext;)L" + returnType + ";");
+ mv.visitInsn(ARETURN);
+ mv.visitMaxs(2, 2);
+ mv.visitEnd();
+ }
+ cw.visitEnd();
byte[] bytes = cw.toByteArray();
View
13 ...ple/creator/ServiceDefinitionCreator.java → ...ple/creator/ServiceDefinitionBuilder.java
@@ -16,7 +16,7 @@
/**
* Generate {@link ServiceDefinition} from a class.
*/
-public interface ServiceDefinitionCreator {
+public interface ServiceDefinitionBuilder {
/**
* Generate {@link ServiceDefinition} from a class. The default mapping described in {@link ServiceDefinitionCreatorConfig}
@@ -26,17 +26,22 @@
* @throws Exception
* @throws IllegalAccessException
*/
- ServiceDefinition create(Class<?> application) throws Exception, IllegalAccessException;
+ ServiceDefinitionBuilder type(Class<?> application) throws Exception, IllegalAccessException;
/**
* Generate {@link ServiceDefinition} from a class using {@link ServiceDefinitionCreatorConfig} as an hint.
* will be used.
- * @param application any class.
* @param config a {@link ServiceDefinitionCreatorConfig}
* @return {@link ServiceDefinition}
* @throws Exception
* @throws IllegalAccessException
*/
- ServiceDefinition create(Class<?> application, ServiceDefinitionCreatorConfig config) throws Exception, IllegalAccessException;
+ ServiceDefinitionBuilder config(ServiceDefinitionCreatorConfig config) throws Exception, IllegalAccessException;
+
+ /**
+ * Build a {@link ServiceDefinition}
+ * @return a {@link ServiceDefinition}
+ */
+ ServiceDefinition build() throws Exception ;
}
View
50 ...creator/src/main/java/org/sonatype/restsimple/creator/ServiceDefinitionCreatorConfig.java
@@ -16,9 +16,9 @@
import java.util.HashMap;
/**
- * A configuration object used by {@link org.sonatype.restsimple.creator.ServiceDefinitionCreator} when generating
+ * A configuration object used by {@link ServiceDefinitionBuilder} when generating
* {@link org.sonatype.restsimple.api.ServiceDefinition}
- *
+ * <p/>
* The following table described how a class' methods are mapped to {@link org.sonatype.restsimple.api.ServiceHandler}
* and {@link org.sonatype.restsimple.api.ServiceDefinition}
* <p/>
@@ -50,34 +50,56 @@
private final HashMap<String, MethodMapper> methodMappers = new HashMap<String, MethodMapper>();
+ public final static ServiceDefinitionCreatorConfig config() {
+ return new ServiceDefinitionCreatorConfig();
+ }
+
/**
* Create a ServiceDefinitionCreatorConfig that use the default mapping.
*/
- public ServiceDefinitionCreatorConfig() {
- addMethodMapper(new MethodMapper(CREATE, METHOD.POST, APPLICATION_JSON, APPLICATION_JSON));
- addMethodMapper(new MethodMapper(READ, METHOD.GET, APPLICATION_JSON, APPLICATION_JSON));
- addMethodMapper(new MethodMapper(READS, METHOD.GET, APPLICATION_JSON, APPLICATION_JSON));
- addMethodMapper(new MethodMapper(UPDATE, METHOD.PUT, APPLICATION_JSON, APPLICATION_JSON));
- addMethodMapper(new MethodMapper(DELETE, METHOD.DELETE, APPLICATION_JSON, APPLICATION_JSON));
+ private ServiceDefinitionCreatorConfig() {
+ map(CREATE, METHOD.POST, APPLICATION_JSON, APPLICATION_JSON);
+ map(READ, METHOD.GET, APPLICATION_JSON, APPLICATION_JSON);
+ map(READS, METHOD.GET, APPLICATION_JSON, APPLICATION_JSON);
+ map(UPDATE, METHOD.PUT, APPLICATION_JSON, APPLICATION_JSON);
+ map(DELETE, METHOD.DELETE, APPLICATION_JSON, APPLICATION_JSON);
+ }
+
+ /**
+ * Add a method mapper used by a {@link ServiceDefinitionBuilder} when
+ * generating {@link org.sonatype.restsimple.api.ServiceDefinition} from any POJO/Class.
+ *
+ * @param methodName a method name used for the mapping
+ * @param method the HTTP Method type
+ * @return this
+ */
+ public ServiceDefinitionCreatorConfig map(String methodName, METHOD method) {
+ methodMappers.put(methodName, new MethodMapper(methodName, method, APPLICATION_JSON, APPLICATION_JSON));
+ return this;
}
/**
- * Add a {@link MethodMapper} used by a {@link org.sonatype.restsimple.creator.ServiceDefinitionCreator} when
+ * Add a {@link MethodMapper} used by a {@link ServiceDefinitionBuilder} when
* generating {@link org.sonatype.restsimple.api.ServiceDefinition} from any POJO/Class.
- * @param methodMapper
+ *
+ * @param methodName a method name used for the mapping
+ * @param method the HTTP Method type
+ * @param produceMediaType a {@link MediaType} the method will produce
+ * @param consumeMediaType a {@link MediaType} the method will consume
* @return this
*/
- public ServiceDefinitionCreatorConfig addMethodMapper(MethodMapper methodMapper) {
- methodMappers.put(methodMapper.getMethodMappedTo(), methodMapper);
+ public ServiceDefinitionCreatorConfig map(String methodName, METHOD method, MediaType produceMediaType, MediaType consumeMediaType) {
+ methodMappers.put(methodName, new MethodMapper(methodName, method, produceMediaType, consumeMediaType));
return this;
}
/**
* Return the {@link MethodMapper} associated with the method's name, or null if there is no mapping.
+ *
* @param methodName a method name
* @return
*/
- public MethodMapper map(String methodName) {
+ protected MethodMapper map(String methodName) {
for (String m : methodMappers.keySet()) {
@@ -92,7 +114,7 @@ public MethodMapper map(String methodName) {
* A utility class used when translating a Class into a ServiceDefinition. This class hold the information
* used to generate the ServiceDefinition and it's associated URI mapping.
*/
- public static final class MethodMapper {
+ protected static final class MethodMapper {
private final String methodMappedTo;
private final METHOD method;
private final MediaType produceMediaType;
View
18 ...c/test/java/org/sonatype/restsimple/tests/creator/ServiceDefinitionCreatorConfigTest.java
@@ -24,8 +24,7 @@
import org.sonatype.restsimple.api.ServiceDefinition;
import org.sonatype.restsimple.client.WebException;
import org.sonatype.restsimple.client.WebProxy;
-import org.sonatype.restsimple.creator.MethodBasedServiceDefinitionCreator;
-import org.sonatype.restsimple.creator.ServiceDefinitionCreatorConfig;
+import org.sonatype.restsimple.creator.MethodServiceDefinitionBuilder;
import org.sonatype.restsimple.tests.creator.model.Person;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -35,12 +34,14 @@
import java.util.LinkedHashMap;
import java.util.Map;
+import static org.sonatype.restsimple.creator.ServiceDefinitionCreatorConfig.METHOD;
+import static org.sonatype.restsimple.creator.ServiceDefinitionCreatorConfig.config;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
public class ServiceDefinitionCreatorConfigTest {
- private MethodBasedServiceDefinitionCreator creator = new MethodBasedServiceDefinitionCreator();
+ private MethodServiceDefinitionBuilder serviceDefinitionBuilder = new MethodServiceDefinitionBuilder();
private static final Logger logger = LoggerFactory.getLogger(ServiceDefinitionCreatorConfigTest.class);
@@ -51,14 +52,11 @@
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
- ServiceDefinitionCreatorConfig config = new ServiceDefinitionCreatorConfig();
+ serviceDefinition = serviceDefinitionBuilder.type(AddressFooBook.class)
+ .config(config().map("foo", METHOD.POST)
+ .map("bar", METHOD.GET)
+ .map("pong", METHOD.DELETE)).build();
- config.addMethodMapper(new ServiceDefinitionCreatorConfig.MethodMapper("foo", ServiceDefinitionCreatorConfig.METHOD.POST))
- .addMethodMapper(new ServiceDefinitionCreatorConfig.MethodMapper("bar", ServiceDefinitionCreatorConfig.METHOD.GET))
- .addMethodMapper(new ServiceDefinitionCreatorConfig.MethodMapper("pong", ServiceDefinitionCreatorConfig.METHOD.DELETE));
-
-
- serviceDefinition = creator.create(AddressFooBook.class, config);
webDriver = WebDriver.getDriver().serviceDefinition(serviceDefinition);
targetUrl = webDriver.getUri();
logger.info("Local HTTP server started successfully");
View
6 ...tor/src/test/java/org/sonatype/restsimple/tests/creator/ServiceDefinitionCreatorTest.java
@@ -25,7 +25,7 @@
import org.sonatype.restsimple.api.ServiceDefinition;
import org.sonatype.restsimple.client.WebException;
import org.sonatype.restsimple.client.WebProxy;
-import org.sonatype.restsimple.creator.MethodBasedServiceDefinitionCreator;
+import org.sonatype.restsimple.creator.MethodServiceDefinitionBuilder;
import org.sonatype.restsimple.creator.ServiceDefinitionCreatorConfig;
import org.sonatype.restsimple.tests.creator.model.Person;
import org.testng.annotations.AfterClass;
@@ -40,7 +40,7 @@
public class ServiceDefinitionCreatorTest {
- private MethodBasedServiceDefinitionCreator creator = new MethodBasedServiceDefinitionCreator();
+ private MethodServiceDefinitionBuilder serviceDefinitionBuilder = new MethodServiceDefinitionBuilder();
private static final Logger logger = LoggerFactory.getLogger(ServiceDefinitionCreatorTest.class);
@@ -50,7 +50,7 @@
@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
- serviceDefinition = creator.create(AddressBook.class);
+ serviceDefinition = serviceDefinitionBuilder.type(AddressBook.class).build();
webDriver = WebDriver.getDriver().serviceDefinition(serviceDefinition);
targetUrl = webDriver.getUri();
logger.info("Local HTTP server started successfully");

0 comments on commit e5fe102

Please sign in to comment.