DigestDocument extends CommonDocument { @Override public String getDigest(final DigestAlgorithm digestAlgorithm) { String base64EncodeDigest = base64EncodeDigestMap.get(digestAlgorithm); if (base64EncodeDigest == null) { throw new DSSException("The digest document does not contain a digest value for the algorithm : " + digestAlgorithm); } return base64EncodeDigest; } 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 test() { String base64EncodeDigest = "aaa"; DigestDocument doc = new DigestDocument(DigestAlgorithm.SHA1, base64EncodeDigest); assertEquals(base64EncodeDigest, doc.getDigest(DigestAlgorithm.SHA1)); }
@Test public void testUnknownDigest() { String base64EncodeDigest = "aaa"; DigestDocument doc = new DigestDocument(DigestAlgorithm.SHA1, base64EncodeDigest); Exception exception = assertThrows(DSSException.class, () -> doc.getDigest(DigestAlgorithm.SHA256)); assertEquals("The digest document does not contain a digest value for the algorithm : SHA256", exception.getMessage()); }