use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method sourceDoesNotExist.
/**
* Has AssemblyFileSet#directory and AssemblyConfiguration#targetDir options.
*
* Source directory doesn't exist
*
* Should do nothing.
*/
@Test
public void sourceDoesNotExist() throws Exception {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(new File(sourceDirectory, "non-existent")).build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("deployments").build();
// When
final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
// Then
assertThat(result).isEmpty();
FileAssertions.assertThat(new File(outputDirectory, "deployments")).doesNotExist();
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method fileSetDirectoryAndRelativeOutputDirectory.
/**
* No options provided except of the AssemblyFileSet#directory, relative outputDirectory and AssemblyConfiguration#targetDir.
*
* Should copy contents of AssemblyFileSet#directory to the outputDirectory in a relative subdirectory with path
* composed of AssemblyConfiguration#targetDir and the relative outputDirectory.
*/
@Test
public void fileSetDirectoryAndRelativeOutputDirectory() throws Exception {
// Given
final File relativeOutputDirectory = new File("relative-output");
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).outputDirectory(relativeOutputDirectory).build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("MyNameIsAl").targetDir("/deployments/").build();
// When
final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
// Then
assertThat(result).hasSize(16);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("relative-output", "relative-output/1.txt", "relative-output/3.other", "relative-output/37", "relative-output/one", "relative-output/one/1.txt", "relative-output/one/3.other", "relative-output/one/37", "relative-output/two", "relative-output/two/1.txt", "relative-output/two/3.other", "relative-output/two/37", "relative-output/three", "relative-output/three/1.txt", "relative-output/three/3.other", "relative-output/three/37").doesNotContainSequence("source-directory");
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method wildcardIncludeAndExcludeAcrossDirectories.
@Test
public void wildcardIncludeAndExcludeAcrossDirectories() throws IOException {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("**.*").exclude("**.txt").fileMode("0766").build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").targetDir("/deployments").build();
// When
final List<AssemblyFileEntry> result = processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac);
// Then
assertThat(result).hasSize(4);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/3.other", "source-directory/one", "source-directory/one/3.other", "source-directory/two", "source-directory/two/3.other", "source-directory/three", "source-directory/three/3.other");
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows.
@Test
public void getAssemblyFileOutputDirectoryWithAbsoluteDirectoryShouldReturnSameWindows() throws IOException {
// Given
assumeTrue(isWindows());
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("C:\\")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
assertEquals("C:\\", result.getAbsolutePath());
}
use of org.eclipse.jkube.kit.common.AssemblyConfiguration in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryRequired.
@Test
public void getAssemblyFileOutputDirectoryRequired() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().build();
// When
final NullPointerException result = assertThrows(NullPointerException.class, () -> {
getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
fail("Should fail as output directory should not be null");
});
// Then
assertEquals("Assembly Configuration output dir is required", result.getMessage());
}
Aggregations