### Question:
SimpleObjectDepositHandler extends AbstractDepositHandler { @Override public PID doDeposit(PID destination, DepositData deposit) throws DepositException { log.debug("Preparing to perform a Simple Object deposit to {}", destination.getQualifiedId()); PID depositPID = pidMinter.mintDepositRecordPid(); File created = writeStreamToDataDir(depositPID, deposit); deposit.setSourceUri(created.toPath().normalize().toUri()); Map<String, String> options = new HashMap<>(); options.put(DepositField.excludeDepositRecord.name(), "true"); registerDeposit(depositPID, destination, deposit, options); return depositPID; }  @Override PID doDeposit(PID destination, DepositData deposit);  }### Answer:
@Test(expected = DepositException.class) public void testNoInputStream() throws Exception { DepositData deposit = new DepositData(null, FILENAME, MIMETYPE, SIMPLE_OBJECT, DEPOSIT_METHOD, depositingAgent); depositHandler.doDeposit(destPid, deposit); }
@Test public void testValidDeposit() throws Exception { InputStream fileStream = new ByteArrayInputStream(FILE_CONTENT.getBytes()); DepositData deposit = new DepositData(fileStream, FILENAME, MIMETYPE, SIMPLE_OBJECT, DEPOSIT_METHOD, depositingAgent); deposit.setDepositorEmail(DEPOSITOR_EMAIL); PID depositPid = depositHandler.doDeposit(destPid, deposit); verify(depositStatusFactory).save(eq(depositPid.getId()), statusCaptor.capture()); Map<String, String> status = statusCaptor.getValue(); verifyDepositFields(depositPid, status); }
@Test public void testFilenameWithModifiers() throws Exception { String modifierFilename = ".././" + FILENAME; InputStream fileStream = new ByteArrayInputStream(FILE_CONTENT.getBytes()); DepositData deposit = new DepositData(fileStream, modifierFilename, MIMETYPE, SIMPLE_OBJECT, DEPOSIT_METHOD, depositingAgent); deposit.setDepositorEmail(DEPOSITOR_EMAIL); PID depositPid = depositHandler.doDeposit(destPid, deposit); verify(depositStatusFactory).save(eq(depositPid.getId()), statusCaptor.capture()); Map<String, String> status = statusCaptor.getValue(); verifyDepositFields(depositPid, status); }
@Test(expected = DepositException.class) public void testDepositsDirNotAvailable() throws Exception { depositsDir.delete(); InputStream fileStream = new ByteArrayInputStream(FILE_CONTENT.getBytes()); DepositData deposit = new DepositData(fileStream, FILENAME, MIMETYPE, SIMPLE_OBJECT, DEPOSIT_METHOD, depositingAgent); depositHandler.doDeposit(destPid, deposit); }