Search in sources :

Example 16 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet in project jkube by eclipse.

the class AssemblyFileSetUtilsTest method calculateFilePermissionsDirectoryWithDirectoryMode.

@Test
public void calculateFilePermissionsDirectoryWithDirectoryMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directoryMode("040777").build();
    final File sourceDirectory = temp.newFolder("source-directory");
    final File sourceSubdirectory = new File(sourceDirectory, "subdirectory");
    FileUtils.forceMkdir(sourceSubdirectory);
    final File sourceFile = new File(sourceDirectory, "file.txt");
    assertThat(sourceFile.createNewFile()).isTrue();
    final File aDirectory = temp.newFolder("just-a-directory");
    final File aSubdirectory = new File(aDirectory, "subdirectory");
    FileUtils.forceMkdir(aSubdirectory);
    final File aFile = new File(aDirectory, "file.txt");
    assertThat(aFile.createNewFile()).isTrue();
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceDirectory, aDirectory, afs);
    // Then
    assertThat(result).hasSize(3).containsExactlyInAnyOrder(new AssemblyFileEntry(sourceDirectory, aDirectory, "040777"), new AssemblyFileEntry(sourceSubdirectory, aSubdirectory, "040777"), new AssemblyFileEntry(sourceFile, aFile, "0644"));
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File) Test(org.junit.Test)

Example 17 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet in project jkube by eclipse.

the class AssemblyFileSetUtilsTest method calculateFilePermissionsDirectoryAndNestedDirectoryAndFileWithDirectoryAndFileMode.

@Test
public void calculateFilePermissionsDirectoryAndNestedDirectoryAndFileWithDirectoryAndFileMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().directoryMode("040755").fileMode("0755").build();
    final File sourceDirectory = temp.newFolder("source-directory");
    final File sourceSubdirectory = new File(sourceDirectory, "subdirectory");
    FileUtils.forceMkdir(sourceSubdirectory);
    final File sourceFile = new File(sourceDirectory, "file.txt");
    assertThat(sourceFile.createNewFile()).isTrue();
    final File aDirectory = temp.newFolder("just-a-directory");
    final File aSubdirectory = new File(aDirectory, "subdirectory");
    FileUtils.forceMkdir(aSubdirectory);
    final File aFile = new File(aDirectory, "file.txt");
    assertThat(aFile.createNewFile()).isTrue();
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceDirectory, aDirectory, afs);
    // Then
    assertThat(result).hasSize(3).containsExactlyInAnyOrder(new AssemblyFileEntry(sourceDirectory, aDirectory, "040755"), new AssemblyFileEntry(sourceSubdirectory, aSubdirectory, "040755"), new AssemblyFileEntry(sourceFile, aFile, "0755"));
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File) Test(org.junit.Test)

Example 18 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet in project jkube by eclipse.

the class AssemblyFileSetUtilsTest method calculateFilePermissionsFileWithNoFileMode.

@Test
public void calculateFilePermissionsFileWithNoFileMode() throws Exception {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().build();
    final File sourceFile = temp.newFile("source-file.txt");
    final File aFile = temp.newFile("just-a-file.txt");
    // When
    final List<AssemblyFileEntry> result = calculateFilePermissions(sourceFile, aFile, afs);
    // Then
    assertThat(result).hasSize(1).contains(new AssemblyFileEntry(sourceFile, aFile, "0644"));
}
Also used : AssemblyFileEntry(org.eclipse.jkube.kit.common.AssemblyFileEntry) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) File(java.io.File) Test(org.junit.Test)

Example 19 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet in project jkube by eclipse.

the class AssemblyFileSetUtilsExcludesTest method isNotExcluded_withExcludes.

@Test
public void isNotExcluded_withExcludes() {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().exclude("**/.git/**").exclude("**/other/**").build();
    // When
    final List<Path> filtered = paths.stream().filter(AssemblyFileSetUtils.isNotExcluded(Paths.get(""), afs)).collect(Collectors.toList());
    // Then
    assertThat(filtered).isNotEmpty().containsExactlyInAnyOrder(Paths.get("usr", "bin"), Paths.get("usr", ".git"), Paths.get("var", ".git", "..", "normalized"));
}
Also used : Path(java.nio.file.Path) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) Test(org.junit.Test)

Example 20 with AssemblyFileSet

use of org.eclipse.jkube.kit.common.AssemblyFileSet in project jkube by eclipse.

the class AssemblyFileSetUtilsExcludesTest method isNotExcluded_withNoExcludes.

@Test
public void isNotExcluded_withNoExcludes() {
    // Given
    final AssemblyFileSet afs = AssemblyFileSet.builder().build();
    // When
    final List<Path> filtered = paths.stream().filter(AssemblyFileSetUtils.isNotExcluded(Paths.get(""), afs)).collect(Collectors.toList());
    // Then
    assertThat(filtered).isNotEmpty().containsExactlyInAnyOrder(Paths.get("usr", "bin"), Paths.get("usr", ".git"), Paths.get("var", ".git", "refs"), Paths.get("var", ".git", "..", "normalized"));
}
Also used : Path(java.nio.file.Path) AssemblyFileSet(org.eclipse.jkube.kit.common.AssemblyFileSet) Test(org.junit.Test)

Aggregations

AssemblyFileSet (org.eclipse.jkube.kit.common.AssemblyFileSet)33 Test (org.junit.Test)30 File (java.io.File)26 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)21 AssemblyFileSetUtils.processAssemblyFileSet (org.eclipse.jkube.kit.common.archive.AssemblyFileSetUtils.processAssemblyFileSet)19 Assembly (org.eclipse.jkube.kit.common.Assembly)18 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)18 Path (java.nio.file.Path)6 HashMap (java.util.HashMap)2 Nonnull (javax.annotation.Nonnull)2 GeneratorContext (org.eclipse.jkube.generator.api.GeneratorContext)2 IOException (java.io.IOException)1 FileSystems (java.nio.file.FileSystems)1 Files (java.nio.file.Files)1 PathMatcher (java.nio.file.PathMatcher)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Objects (java.util.Objects)1