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"));
}
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"));
}
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"));
}
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"));
}
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"));
}
Aggregations