@Test
  public void testWriteCompressed_retrieveByLayerDigest()
      throws IOException, CacheDirectoryCreationException, CacheCorruptedException {
    Cache cache = Cache.withDirectory(temporaryFolder.newFolder().toPath());

    verifyIsLayer1(cache.writeCompressedLayer(compress(layerBlob1)));
    verifyIsLayer1(cache.retrieve(layerDigest1).orElseThrow(AssertionError::new));
    Assert.assertFalse(cache.retrieve(layerDigest2).isPresent());
  }
Gets the size of {@code blob}.

@param blob the {@link Blob}
@return the size (in bytes) of {@code blob}
@throws IOException if an I/O exception occurs
jib-core/src/test/java/com/google/cloud/tools/jib/cache/CacheTest.java