Commits

Anonymous committed 5cfabbd

Add sword binary deposit AT

Comments (0)

Files changed (4)

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

 package net.chempound.acceptance.dsl.driver;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
 /**
  * @author Sam Adams
  */
         return content;
     }
 
+    public InputStream getStream() {
+        return new ByteArrayInputStream(content);
+    }
+
 }

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

         final DepositInstruction instruction = createDepositInstruction(specifications);
         final URI collection = instruction.parent != null ? instruction.parent : context.getContentRoot();
         final DepositReceipt depositReceipt = swordClient.deposit(collection.toString(), createDeposit(instruction));
+        depositReceipt.getEntry().writeTo(System.err);
         return new SwordDepositReceipt(depositReceipt);
     }
 
         final Deposit deposit = new Deposit();
         deposit.setSlug(context.actual(instruction.slug));
 
-        final EntryPart entryPart = new EntryPart();
-        entryPart.getEntry().setTitle(context.actual(instruction.title));
-        deposit.setEntryPart(entryPart);
+        if (instruction.title != null) {
+            final EntryPart entryPart = new EntryPart();
+            entryPart.getEntry().setTitle(context.actual(instruction.title));
+            deposit.setEntryPart(entryPart);
+        }
+        if (!instruction.files.isEmpty()) {
+            if (instruction.files.size() != 1) {
+                throw new UnsupportedOperationException();
+            }
+            deposit.setFilename(instruction.files.get(0).getPath());
+            deposit.setMimeType(instruction.files.get(0).getMimeType());
+            deposit.setFile(instruction.files.get(0).getStream());
+        }
 
         return deposit;
     }

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

     }
 
     @Test
-//    @Ignore("work in progress")
     public void shouldRemoveDeletedItemFromParentCollection() throws Exception {
         final SwordResult response = swordDriver.deleteItem(item.getEditUri().toString());
 

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

 
 import net.chempound.acceptance.dsl.AbstractAcceptanceTest;
 import net.chempound.acceptance.dsl.Verifier;
+import net.chempound.acceptance.dsl.driver.Resource;
 import net.chempound.acceptance.dsl.driver.api.APIDriver;
 import net.chempound.acceptance.dsl.driver.sword.SwordClientDriver;
 import net.chempound.acceptance.dsl.driver.sword.SwordDepositReceipt;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import static net.chempound.acceptance.dsl.driver.DepositSpecifications.withFile;
 import static net.chempound.acceptance.dsl.driver.DepositSpecifications.withSlug;
 import static net.chempound.acceptance.dsl.driver.DepositSpecifications.withTitle;
+import static net.chempound.acceptance.dsl.driver.ItemMatchers.hasFiles;
 import static net.chempound.acceptance.dsl.driver.ItemMatchers.hasSlug;
 import static net.chempound.acceptance.dsl.driver.ItemMatchers.hasTitle;
 import static org.junit.Assert.fail;
     }
 
     @Test
-//    @Ignore("work in progress")
     public void shouldSupportMetaDataOnlyDeposit() throws Exception {
         final SwordDepositReceipt depositReceipt = swordDriver.depositItem(withSlug("slug"), withTitle("title"));
         Verifier.verify(depositReceipt, hasTitle("title"), hasSlug("slug"));
     @Test
     @Ignore("work in progress")
     public void shouldSupportBinaryDeposit() throws Exception {
-        fail();
+        final Resource file = newResource("file");
+        final SwordDepositReceipt depositReceipt = swordDriver.depositItem(withSlug("slug"), withFile(file));
+        Verifier.verify(depositReceipt, hasSlug("slug"), hasFiles("file"));
     }
 
     @Test