@Test
  public void testRun()
      throws LayerPropertyNotFoundException, IOException, CacheCorruptedException {
    ImmutableList<FileEntriesLayer> fakeLayerConfigurations =
        ImmutableList.of(
            fakeDependenciesLayerConfiguration,
            fakeSnapshotDependenciesLayerConfiguration,
            fakeResourcesLayerConfiguration,
            fakeClassesLayerConfiguration,
            fakeExtraFilesLayerConfiguration);
    Mockito.when(mockBuildContext.getLayerConfigurations()).thenReturn(fakeLayerConfigurations);

    // Populates the cache.
    List<Layer> applicationLayers = buildFakeLayersToCache();
    Assert.assertEquals(5, applicationLayers.size());

    ImmutableList<FileEntry> dependenciesLayerEntries =
        ImmutableList.copyOf(fakeLayerConfigurations.get(0).getEntries());
    ImmutableList<FileEntry> snapshotDependenciesLayerEntries =
        ImmutableList.copyOf(fakeLayerConfigurations.get(1).getEntries());
    ImmutableList<FileEntry> resourcesLayerEntries =
        ImmutableList.copyOf(fakeLayerConfigurations.get(2).getEntries());
    ImmutableList<FileEntry> classesLayerEntries =
        ImmutableList.copyOf(fakeLayerConfigurations.get(3).getEntries());
    ImmutableList<FileEntry> extraFilesLayerEntries =
        ImmutableList.copyOf(fakeLayerConfigurations.get(4).getEntries());

    CachedLayer dependenciesCachedLayer =
        cache.retrieve(dependenciesLayerEntries).orElseThrow(AssertionError::new);
    CachedLayer snapshotDependenciesCachedLayer =
        cache.retrieve(snapshotDependenciesLayerEntries).orElseThrow(AssertionError::new);
    CachedLayer resourcesCachedLayer =
        cache.retrieve(resourcesLayerEntries).orElseThrow(AssertionError::new);
    CachedLayer classesCachedLayer =
        cache.retrieve(classesLayerEntries).orElseThrow(AssertionError::new);
    CachedLayer extraFilesCachedLayer =
        cache.retrieve(extraFilesLayerEntries).orElseThrow(AssertionError::new);

    // Verifies that the cached layers are up-to-date.
    Assert.assertEquals(
        applicationLayers.get(0).getBlobDescriptor().getDigest(),
        dependenciesCachedLayer.getDigest());
    Assert.assertEquals(
        applicationLayers.get(1).getBlobDescriptor().getDigest(),
        snapshotDependenciesCachedLayer.getDigest());
    Assert.assertEquals(
        applicationLayers.get(2).getBlobDescriptor().getDigest(), resourcesCachedLayer.getDigest());
    Assert.assertEquals(
        applicationLayers.get(3).getBlobDescriptor().getDigest(), classesCachedLayer.getDigest());
    Assert.assertEquals(
        applicationLayers.get(4).getBlobDescriptor().getDigest(),
        extraFilesCachedLayer.getDigest());

    // Verifies that the cache reader gets the same layers as the newest application layers.
    assertBlobsEqual(applicationLayers.get(0).getBlob(), dependenciesCachedLayer.getBlob());
    assertBlobsEqual(applicationLayers.get(1).getBlob(), snapshotDependenciesCachedLayer.getBlob());
    assertBlobsEqual(applicationLayers.get(2).getBlob(), resourcesCachedLayer.getBlob());
    assertBlobsEqual(applicationLayers.get(3).getBlob(), classesCachedLayer.getBlob());
    assertBlobsEqual(applicationLayers.get(4).getBlob(), extraFilesCachedLayer.getBlob());
  }
Lists the files in the {@code resourcePath} resources directory and creates a {@link
FileEntriesLayer} with entries from those files.
jib-core/src/test/java/com/google/cloud/tools/jib/builder/steps/BuildAndCacheApplicationLayerStepTest.java