Commits

Sam Adams committed aa40d5c

Refactoring ATs

Comments (0)

Files changed (3)

acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/AbstractAcceptanceTest.java

 import org.restlet.data.Protocol;
 
 import java.io.File;
+import java.net.URI;
 import java.util.UUID;
 
 /**
  */
 public abstract class AbstractAcceptanceTest {
 
+    private static final URI ROOT = URI.create("http://localhost:12345/chempound/");
+
     private static Component component;
     private static File workspace;
     private static int port;
     protected final DriverFactory driverFactory;
 
     protected AbstractAcceptanceTest() {
-        this.driverFactory = new SeleniumDriverFactory(testContext);
+        this.driverFactory = new SeleniumDriverFactory(testContext, ROOT);
     }
 
     @After

acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/SeleniumDriverFactory.java

 import org.openqa.selenium.firefox.FirefoxDriver;
 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
 
+import java.net.URI;
+
 /**
  * @author Sam Adams
  */
 public class SeleniumDriverFactory implements DriverFactory {
 
     private final TestContext context;
+    private final URI root;
     private final WebDriver webDriver;
 
-    public SeleniumDriverFactory(final TestContext testContext) {
+    public SeleniumDriverFactory(final TestContext testContext, final URI root) {
         this.context = testContext;
+        this.root = root;
         this.webDriver = createWebDriver();
     }
 
 
     @Override
     public APIDriver createAPIDriver() {
-        return new APIDriver(context);
+        return new APIDriver(context, root);
     }
 
     @Override

acceptance-test-driver/src/main/java/net/chempound/acceptance/dsl/driver/APIDriver.java

     private final ChempoundClient client;
     private final TestContext context;
 
-    public APIDriver(final TestContext context) {
+    private final URI contentRoot;
+
+    public APIDriver(final TestContext context, final URI root) {
         this.context = context;
         this.client = new DefaultChempoundClient();
+        this.contentRoot = root.resolve("content/");
     }
     
     public CreateCollectionInstruction createCollection() {
 
     Collection createCollection(final CreateCollectionInstruction config) {
         final CreateCollectionRequest request = new CreateCollectionRequest()
-            .withUri(config.parent != null ? config.parent : URI.create("http://localhost:12345/chempound/content/"))
+            .withUri(config.parent != null ? config.parent : contentRoot)
             .withTitle(context.actual(config.title))
             .withSlug(context.actual(config.slug));
 
 
     DepositReceipt depositItem(final DepositInstruction config) {
         final DepositItemRequest request = new DepositItemRequest()
-            .withUri(config.parent != null ? config.parent : URI.create("http://localhost:12345/chempound/content/"))
+            .withUri(config.parent != null ? config.parent : contentRoot)
             .withTitle(context.actual(config.title))
             .withSlug(context.actual(config.slug));