Commits

Anonymous committed 0049a9d

Extract interfaces for Deposit/Collection specification, so we can take advantage of IntelliJ's closure-esque code folding

  • Participants
  • Parent commits cf762af

Comments (0)

Files changed (10)

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

 package net.chempound.acceptance.dsl.driver;
 
-public class CollectionSpecification {
+public interface CollectionSpecification {
 
-    public static CollectionSpecification withSlug(final String slug) {
-        return new CollectionSpecification() {
-            @Override
-            protected void apply(final CreateCollectionInstruction instruction) {
-                instruction.slug = slug;
-            }
-        };
-    }
+    void apply(CreateCollectionInstruction instruction);
 
-    public static CollectionSpecification withTitle(final String title) {
-        return new CollectionSpecification() {
-            @Override
-            protected void apply(final CreateCollectionInstruction instruction) {
-                instruction.title = title;
-            }
-        };
-    }
-
-    public static CollectionSpecification withParent(final Collection parent) {
-        return new CollectionSpecification() {
-            @Override
-            protected void apply(final CreateCollectionInstruction instruction) {
-                instruction.parent = parent.getUri();
-            }
-        };
-    }
-
-    protected void apply(final CreateCollectionInstruction instruction) {
-        throw new UnsupportedOperationException();
-    }
 }

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

+package net.chempound.acceptance.dsl.driver;
+
+public class CollectionSpecifications {
+
+    public static CollectionSpecification withSlug(final String slug) {
+        return new CollectionSpecification() {
+            public void apply(final CreateCollectionInstruction instruction) {
+                instruction.slug = slug;
+            }
+        };
+    }
+
+    public static CollectionSpecification withTitle(final String title) {
+        return new CollectionSpecification() {
+            public void apply(final CreateCollectionInstruction instruction) {
+                instruction.title = title;
+            }
+        };
+    }
+
+    public static CollectionSpecification withParent(final Collection parent) {
+        return new CollectionSpecification() {
+            public void apply(final CreateCollectionInstruction instruction) {
+                instruction.parent = parent.getUri();
+            }
+        };
+    }
+
+}

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

 package net.chempound.acceptance.dsl.driver;
 
-import com.hp.hpl.jena.rdf.model.Model;
+public interface DepositSpecification {
 
-import static java.util.Arrays.asList;
+    void apply(DepositInstruction instruction);
 
-public class DepositSpecification {
-
-    public static DepositSpecification withSlug(final String slug) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.slug = slug;
-            }
-        };
-    }
-
-    public static DepositSpecification withTitle(final String title) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.title = title;
-            }
-        };
-    }
-
-    public static DepositSpecification withFile(final Resource file) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.files.add(file);
-            }
-        };
-    }
-
-    public static DepositSpecification withFiles(final Resource... files) {
-        return withFiles(asList(files));
-    }
-
-    public static DepositSpecification withFiles(final java.util.Collection<Resource> files) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.files.addAll(files);
-            }
-        };
-    }
-
-    public static DepositSpecification withMetadata(final Model metadata) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.metadata = metadata;
-            }
-        };
-    }
-
-    public static DepositSpecification asMultipart(final boolean multipart) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.multipart = multipart;
-            }
-        };
-    }
-
-    public static DepositSpecification inProgress(final boolean inProgress) {
-        return new DepositSpecification() {
-            @Override
-            protected void apply(final DepositInstruction instruction) {
-                instruction.inProgress = inProgress;
-            }
-        };
-    }
-
-    protected void apply(final DepositInstruction instruction) {
-        throw new UnsupportedOperationException();
-    }
 }

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

+package net.chempound.acceptance.dsl.driver;
+
+import com.hp.hpl.jena.rdf.model.Model;
+
+import static java.util.Arrays.asList;
+
+public class DepositSpecifications {
+
+    public static DepositSpecification withSlug(final String slug) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.slug = slug;
+            }
+        };
+    }
+
+    public static DepositSpecification withTitle(final String title) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.title = title;
+            }
+        };
+    }
+
+    public static DepositSpecification withFile(final Resource file) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.files.add(file);
+            }
+        };
+    }
+
+    public static DepositSpecification withFiles(final Resource... files) {
+        return withFiles(asList(files));
+    }
+
+    public static DepositSpecification withFiles(final java.util.Collection<Resource> files) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.files.addAll(files);
+            }
+        };
+    }
+
+    public static DepositSpecification withMetadata(final Model metadata) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.metadata = metadata;
+            }
+        };
+    }
+
+    public static DepositSpecification asMultipart(final boolean multipart) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.multipart = multipart;
+            }
+        };
+    }
+
+    public static DepositSpecification inProgress(final boolean inProgress) {
+        return new DepositSpecification() {
+            public void apply(final DepositInstruction instruction) {
+                instruction.inProgress = inProgress;
+            }
+        };
+    }
+
+}

acceptance-tests/src/test/java/net/chempound/acceptance/PingbackAcceptanceTest.java

 
 import java.net.URI;
 
-import static net.chempound.acceptance.dsl.driver.DepositSpecification.withTitle;
+import static net.chempound.acceptance.dsl.driver.DepositSpecifications.withTitle;
 import static net.chempound.acceptance.dsl.driver.ItemMatchers.hasPingbacks;
 import static net.chempound.webapp.pingback.PingbackFault.*;
 

acceptance-tests/src/test/java/net/chempound/acceptance/chemistry/GaussianLogAcceptanceTest.java

 import java.util.ArrayList;
 import java.util.List;
 
-import static net.chempound.acceptance.dsl.driver.DepositSpecification.*;
+import static net.chempound.acceptance.dsl.driver.DepositSpecifications.*;
 
 /**
  * @author Sam Adams

acceptance-tests/src/test/java/net/chempound/acceptance/chemistry/NwChemLogAcceptanceTest.java

 import java.util.ArrayList;
 import java.util.List;
 
-import static net.chempound.acceptance.dsl.driver.DepositSpecification.*;
+import static net.chempound.acceptance.dsl.driver.DepositSpecifications.*;
 
 /**
  * @author Sam Adams

acceptance-tests/src/test/java/net/chempound/acceptance/sword/DepositAcceptanceTest.java

 import org.junit.Ignore;
 import org.junit.Test;
 
-import static net.chempound.acceptance.dsl.driver.DepositSpecification.*;
+import static net.chempound.acceptance.dsl.driver.DepositSpecifications.*;
 import static net.chempound.acceptance.dsl.driver.ItemMatchers.*;
 
 /**

acceptance-tests/src/test/java/net/chempound/acceptance/ui/CollectionAcceptanceTest.java

 import org.junit.Test;
 
 import static net.chempound.acceptance.dsl.driver.CollectionMatchers.*;
-import static net.chempound.acceptance.dsl.driver.CollectionSpecification.withParent;
-import static net.chempound.acceptance.dsl.driver.CollectionSpecification.withSlug;
-import static net.chempound.acceptance.dsl.driver.CollectionSpecification.withTitle;
+import static net.chempound.acceptance.dsl.driver.CollectionSpecifications.withParent;
+import static net.chempound.acceptance.dsl.driver.CollectionSpecifications.withSlug;
+import static net.chempound.acceptance.dsl.driver.CollectionSpecifications.withTitle;
 
 /**
  * @author Sam Adams

acceptance-tests/src/test/java/net/chempound/acceptance/ui/WebUIAcceptanceTest.java

 
 import java.util.Random;
 
-import static net.chempound.acceptance.dsl.driver.DepositSpecification.*;
+import static net.chempound.acceptance.dsl.driver.DepositSpecifications.*;
 import static net.chempound.acceptance.dsl.driver.ItemMatchers.*;
 
 /**