### Question:
CountingDigestOutputStream extends DigestOutputStream { public BlobDescriptor computeDigest() { try { byte[] hashedBytes = digest.digest(); StringBuilder stringBuilder = new StringBuilder(2 * hashedBytes.length); for (byte b : hashedBytes) { stringBuilder.append(String.format("%02x", b)); } String hash = stringBuilder.toString(); BlobDescriptor blobDescriptor = new BlobDescriptor(bytesSoFar, DescriptorDigest.fromHash(hash)); bytesSoFar = 0; return blobDescriptor; } catch (DigestException ex) { throw new RuntimeException("SHA-256 algorithm produced invalid hash: " + ex.getMessage(), ex); } } CountingDigestOutputStream(OutputStream outputStream); BlobDescriptor computeDigest(); @Override void write(byte[] data, int offset, int length); @Override void write(int singleByte);  }### Answer:
@Test public void test_smokeTest() throws IOException, DigestException { for (Map.Entry<String, String> knownHash : KNOWN_SHA256_HASHES.entrySet()) { String toHash = knownHash.getKey(); String expectedHash = knownHash.getValue(); OutputStream underlyingOutputStream = new ByteArrayOutputStream(); CountingDigestOutputStream countingDigestOutputStream = new CountingDigestOutputStream(underlyingOutputStream); byte[] bytesToHash = toHash.getBytes(StandardCharsets.UTF_8); InputStream toHashInputStream = new ByteArrayInputStream(bytesToHash); ByteStreams.copy(toHashInputStream, countingDigestOutputStream); BlobDescriptor blobDescriptor = countingDigestOutputStream.computeDigest(); Assert.assertEquals(DescriptorDigest.fromHash(expectedHash), blobDescriptor.getDigest()); Assert.assertEquals(bytesToHash.length, blobDescriptor.getSize()); } }