DigestDocument extends CommonDocument { @Override public InputStream openStream() { throw new DSSException("Not possible with Digest document"); } DigestDocument();  DigestDocument(final DigestAlgorithm digestAlgorithm, final String base64EncodeDigest);  DigestDocument(final DigestAlgorithm digestAlgorithm, final String base64EncodeDigest, final String name); void addDigest(final DigestAlgorithm digestAlgorithm, final String base64EncodeDigest); @Override String getDigest(final DigestAlgorithm digestAlgorithm); Digest getExistingDigest(); @Override InputStream openStream(); @Override void save(String filePath);  }
@Test public void testOpenStream() { String base64EncodeDigest = "aaa"; DigestDocument doc = new DigestDocument(DigestAlgorithm.SHA1, base64EncodeDigest); Exception exception = assertThrows(DSSException.class, () -> doc.openStream()); assertEquals("Not possible with Digest document", exception.getMessage()); }