### Question:
StreamDocument extends CommonDocument { @Override public String getDigest(DigestAlgorithm digestAlgorithm) { logger.debug("Digest algorithm: " + digestAlgorithm); byte[] digestBytes; try { digestBytes = DSSUtils.digest(digestAlgorithm, getTemporaryFileAsStream()); } catch (FileNotFoundException e) { logger.error(e.getMessage()); throw new DSSException(e); } return Base64.encodeBase64String(digestBytes); } StreamDocument(InputStream stream, String documentName, MimeType mimeType); @Override InputStream openStream(); @Override void setName(String s); @Override String getAbsolutePath(); @Override MimeType getMimeType(); @Override void setMimeType(MimeType mimeType); @Override void save(String filePath); @Override String getDigest(DigestAlgorithm digestAlgorithm);  }### Answer:
@Test public void getDigest() throws Exception { Assert.assertEquals("VZrq0IJk1XldOQlxjN0Fq9SVcuhP5VWQ7vMaiKCP3/0=", document.getDigest(DigestAlgorithm.SHA256)); }
@Test(expected = DSSException.class) public void testGetDigestThrowsException() throws Exception { new MockStreamDocument().getDigest(DigestAlgorithm.SHA1); }