@Test
    void testArchiveCreationNoDockerfileWithExecutableAssemblies(@TempDir Path tmpDir,
        @Mock final PlexusIoResource resource,
        @Mock final ArchiveEntry archiveEntry) throws MojoExecutionException, NoSuchArchiverException, IOException {
        MojoParameters mojoParams = mockMojoParams(mockMavenProject());

        FileItem testFile = new FileItem();
        testFile.setDestName("test.txt");
        testFile.setSource("test.in");

        Assembly testAssembly = new Assembly();
        testAssembly.addFile(testFile);

        Mockito.doReturn("test").when(archiveEntry).getName();
        Mockito.doReturn(0_644).when(archiveEntry).getMode();
        Mockito.doReturn(resource).when(archiveEntry).getResource();

        Mockito.doReturn(true).when(resource).isExisting();
        Mockito.doReturn(true).when(resource).isFile();
        Mockito.doReturn(new ByteArrayInputStream(new byte[0])).when(resource).getContents();

        Mockito.doReturn(new ResourceIterator() {
            boolean consumed = false;

            @Override
            public boolean hasNext() {
                return !consumed;
            }

            @Override
            public ArchiveEntry next() {
                if (consumed) {
                    return null;
                }
                consumed = true;
                return archiveEntry;
            }
        }).when(tarArchiver).getResources();

        BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder()
            .assemblies(Collections.singletonList(
                new AssemblyConfiguration.Builder()
                    .name("first")
                    .mode(AssemblyMode.tar.name())
                    .assemblyDef(testAssembly)
                    .permissions(AssemblyConfiguration.PermissionMode.exec.name())
                    .build()
            ))
            .build();
        buildImageConfiguration.initAndValidate(logger);

        Mockito.doReturn(tarArchiver).when(archiverManager).getArchiver("tar");
        Mockito.doReturn(tmpDir.resolve("damt.tar").toFile()).when(tarArchiver).getDestFile();

        File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
        Assertions.assertNotNull(tarArchive);

        List<ArchivedFileSet> archivedFileSets = getArchivedFileSetsToVerify("target/test_image/build/Dockerfile", "Dockerfile", 1);
        Assertions.assertEquals(new File("target/test_image/build/first.tar").getAbsoluteFile(), archivedFileSets.get(0).getArchive());
        Assertions.assertEquals("first/", archivedFileSets.get(0).getPrefix());

        // We cannot intercept the tarArchiver that AllFilesExecCustomizer creates.
        // TODO: Should AllFilesExecCustomizer lookup tarArchive wth archiverManager.getArchiver("tar");
        // Mockito.verify(tarArchiver)
        //     .addResource(Mockito.any(PlexusIoResource.class), Mockito.eq("test"), Mockito.eq(0_755));
    }
", "Dockerfile.test" }, fileSets.get(1).getExcludes());
        Assertions.assertNull(fileSets.get(1).getIncludes());
    }

    private List<FileSet> getFileSetsToVerify(int invocations) {
        ArgumentCaptor<FileSet> fileSetCapture = ArgumentCaptor.forClass(FileSet.class);
        Mockito.verify(tarArchiver, Mockito.times(invocations)).addFileSet(fileSetCapture.capture());

        return fileSetCapture.getAllValues();
    }

    private List<ArchivedFileSet> getArchivedFileSetsToVerify(String input, String destFileName, int count) {
        Mockito.verify(tarArchiver).addFile(new File(input).getAbsoluteFile(), destFileName);

        ArgumentCaptor<ArchivedFileSet> archivedFileSetCapture = ArgumentCaptor.forClass(ArchivedFileSet.class);
        Mockito.verify(tarArchiver, Mockito.times(count)).addArchivedFileSet(archivedFileSetCapture.capture());

        return archivedFileSetCapture.getAllValues();
    }

    @Test
    void testArchiveCreationDockerfileWithDirAssembly() throws MojoExecutionException, NoSuchArchiverException {
        MojoParameters mojoParams = mockMojoParams(mockMavenProject());

        BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder()
            .dockerFile(DockerAssemblyManagerTest.class.getResource("/docker/Dockerfile.test").getPath())
            .assembly(new AssemblyConfiguration.Builder()
                .mode(AssemblyMode.dir.name())
                .build()
            )
            .build();
        buildImageConfiguration.initAndValidate(logger);

        Mockito.doReturn(tarArchiver).when(archiverManager).getArchiver("tar");
        File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
        Assertions.assertNotNull(tarArchive);

        verifyArchiveManager();
    }

    @Test
    void testArchiveCreationDockerfileWithArchiveAssembly() throws MojoExecutionException, NoSuchArchiverException {
        MojoParameters mojoParams = mockMojoParams(mockMavenProject());

        BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder()
            .dockerFile(DockerAssemblyManagerTest.class.getResource("/docker/Dockerfile.test").getPath())
            .assembly(new AssemblyConfiguration.Builder()
                .mode(AssemblyMode.tar.name())
                .assemblyDef(new Assembly())
                .build()
            )
            .build();
        buildImageConfiguration.initAndValidate(logger);

        Mockito.doReturn(tarArchiver).when(archiverManager).getArchiver("tar");
        File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
        Assertions.assertNotNull(tarArchive);

        List<FileSet> fileSets= getFileSetsToVerify(1);
        Assertions.assertArrayEquals(new String[] { "target/**", "Dockerfile.test" }, fileSets.get(0).getExcludes());
        Assertions.assertNull(fileSets.get(0).getIncludes());

        List<ArchivedFileSet> archivedFileSets = getArchivedFileSetsToVerify("target/test_image/build/Dockerfile.test", "Dockerfile.test", 1);
        Assertions.assertEquals(new File("target/test_image/build/maven.tar").getAbsoluteFile(), archivedFileSets.get(0).getArchive());
        Assertions.assertEquals("maven/", archivedFileSets.get(0).getPrefix());
    }

    @Test
    void testArchiveCreationDockerfileWithMultipleArchiveAssemblies() throws MojoExecutionException, NoSuchArchiverException {
        MojoParameters mojoParams = mockMojoParams(mockMavenProject());

        BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder()
            .dockerFile(DockerAssemblyManagerTest.class.getResource("/docker/Dockerfile.test").getPath())
            .assemblies(Arrays.asList(
                new AssemblyConfiguration.Builder()
                    .name("first")
                    .mode(AssemblyMode.tar.name())
                    .assemblyDef(new Assembly())
                    .build(),
                new AssemblyConfiguration.Builder()
                    .name("second")
                    .mode(AssemblyMode.tar.name())
                    .assemblyDef(new Assembly())
                    .build()
            ))
            .build();
        buildImageConfiguration.initAndValidate(logger);

        Mockito.doReturn(tarArchiver).when(archiverManager).getArchiver("tar");
        File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
        Assertions.assertNotNull(tarArchive);

        List<FileSet> fileSets = getFileSetsToVerify(1);
        Assertions.assertArrayEquals(new String[] { "target/**", "Dockerfile.test" }, fileSets.get(0).getExcludes());
        Assertions.assertNull(fileSets.get(0).getIncludes());

        List<ArchivedFileSet> archivedFileSets = getArchivedFileSetsToVerify("target/test_image/build/Dockerfile.test", "Dockerfile.test", 2);
        Assertions.assertEquals(new File("target/test_image/build/first.tar").getAbsoluteFile(), archivedFileSets.get(0).getArchive());
        Assertions.assertEquals("first/", archivedFileSets.get(0).getPrefix());
        Assertions.assertEquals(new File("target/test_image/build/second.tar").getAbsoluteFile(), archivedFileSets.get(1).getArchive());
        Assertions.assertEquals("second/", archivedFileSets.get(1).getPrefix());
    }

    @Test
    void testArchiveCreationNoDockerfileWithMultipleArchiveAssemblies() throws MojoExecutionException, NoSuchArchiverException {
        MojoParameters mojoParams = mockMojoParams(mockMavenProject());

        BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder()
            .assemblies(Arrays.asList(
                new AssemblyConfiguration.Builder()
                    .name("first")
                    .mode(AssemblyMode.tar.name())
                    .assemblyDef(new Assembly())
                    .build(),
                new AssemblyConfiguration.Builder()
                    .name("second")
                    .mode(AssemblyMode.tar.name())
                    .assemblyDef(new Assembly())
                    .build()
            ))
            .build();
        buildImageConfiguration.initAndValidate(logger);

        Mockito.doReturn(tarArchiver).when(archiverManager).getArchiver("tar");
        File tarArchive = assemblyManager.createDockerTarArchive("test_image", mojoParams, buildImageConfiguration, logger, null);
        Assertions.assertNotNull(tarArchive);

        /*
            tarArchiver.addFile(new File("target/test_image/build/Dockerfile").getAbsoluteFile(), "Dockerfile");

            List<ArchivedFileSet> archivedFileSets = new ArrayList<>();
            tarArchiver.addArchivedFileSet(withCapture(archivedFileSets));
src/test/java/io/fabric8/maven/docker/assembly/DockerAssemblyManagerTest.java