### Question:
DescriptorDigest { public static DescriptorDigest fromDigest(String digest) throws DigestException { if (!digest.matches(DIGEST_REGEX)) { throw new DigestException("Invalid digest: " + digest); } String hash = digest.substring(DIGEST_PREFIX.length()); return new DescriptorDigest(hash); } private  DescriptorDigest(String hash); static DescriptorDigest fromHash(String hash); static DescriptorDigest fromDigest(String digest); String getHash(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final int HASH_LENGTH; }### Answer:
@Test public void testCreateFromDigest_fail() { String badDigest = "sha256:not a valid digest"; try { DescriptorDigest.fromDigest(badDigest); Assert.fail("Invalid digest should have caused digest creation failure."); } catch (DigestException ex) { Assert.assertEquals("Invalid digest: " + badDigest, ex.getMessage()); } }