@Test
  public void testCreateContainerBuilder_packagedMode()
      throws InvalidImageReferenceException, IOException, CacheDirectoryCreationException,
          URISyntaxException {
    Path jar = temporaryFolder.newFile("final-name.jar").toPath();
    when(mockBuild.getDirectory()).thenReturn(temporaryFolder.getRoot().toString());
    when(mockBuild.getFinalName()).thenReturn("final-name");

    ContainerBuilderLayers layers =
        new ContainerBuilderLayers(setUpBuildContext(ContainerizingMode.PACKAGED));

    Path dependenciesPath = getResource("maven/application/dependencies");
    assertThat(layers.dependenciesLayer).isNotNull();
    assertThat(layers.dependenciesLayer.getEntries())
        .comparingElementsUsing(SOURCE_FILE_OF)
        .containsExactly(
            testRepository.artifactPathOnDisk("com.test", "dependency", "1.0.0"),
            dependenciesPath.resolve("more/dependency-1.0.0.jar"),
            dependenciesPath.resolve("another/one/dependency-1.0.0.jar"),
            dependenciesPath.resolve("libraryA.jar"),
            dependenciesPath.resolve("libraryB.jar"),
            dependenciesPath.resolve("library.jarC.jar"));
    assertThat(layers.snapshotsLayer).isNotNull();
    assertThat(layers.snapshotsLayer.getEntries())
        .comparingElementsUsing(SOURCE_FILE_OF)
        .containsExactly(
            testRepository.artifactPathOnDisk("com.test", "dependencyX", "1.0.0-SNAPSHOT"));
    assertThat(layers.extraFilesLayer).isNotNull();
    assertThat(layers.extraFilesLayer.getEntries())
        .comparingElementsUsing(SOURCE_FILE_OF)
        .containsExactly(jar);
    assertThat(layers.resourcesLayer).isNull();
    assertThat(layers.classesLayer).isNull();

    assertThat(layers.dependenciesLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly(
            "/my/app/libs/dependency-1.0.0-200.jar",
            "/my/app/libs/dependency-1.0.0-480.jar",
            "/my/app/libs/dependency-1.0.0-770.jar",
            "/my/app/libs/library.jarC.jar",
            "/my/app/libs/libraryA.jar",
            "/my/app/libs/libraryB.jar");
    assertThat(layers.snapshotsLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly("/my/app/libs/dependencyX-1.0.0-SNAPSHOT.jar");
    assertThat(layers.extraFilesLayer.getEntries())
        .comparingElementsUsing(EXTRACTION_PATH_OF)
        .containsExactly("/my/app/classpath/final-name.jar");
  }
Helper for reading back layers in a {@link BuildContext}.
jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesTest.java