use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method directoryExcludes.
@Test
public void directoryExcludes() throws Exception {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).fileMode("0764").exclude("one/**").exclude("one").exclude("two{/**,}").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(8);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/3.other", "source-directory/37", "source-directory/three", "source-directory/three/1.txt", "source-directory/three/3.other", "source-directory/three/37");
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method assemblyFileSetHasNoDirectory_shouldThrowException.
@Test
public void assemblyFileSetHasNoDirectory_shouldThrowException() {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().build();
final Assembly layer = new Assembly();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().name("deployments").build();
// When
final NullPointerException result = Assert.assertThrows(NullPointerException.class, () -> processAssemblyFileSet(baseDirectory, outputDirectory, afs, layer, ac));
// Then
assertThat(result).hasMessage("Assembly FileSet directory is required");
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method minimumRequiredFields.
/**
* Has AssemblyFileSet#directory and AssemblyConfiguration#targetDir options.
*
* Should copy the AssemblyFileSet#directory to the outputDirectory in a subdirectory named as the AssemblyConfiguration#targetDir.
*
* n.b. this is the only case where the source directory and not its contents is copied.
*/
@Test
public void minimumRequiredFields() throws Exception {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).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).hasSize(16);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/3.other", "source-directory/37", "source-directory/one", "source-directory/one/1.txt", "source-directory/one/3.other", "source-directory/one/37", "source-directory/two", "source-directory/two/1.txt", "source-directory/two/3.other", "source-directory/two/37", "source-directory/three", "source-directory/three/1.txt", "source-directory/three/3.other", "source-directory/three/37");
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileSetUtilsProcessAssemblyFileSetTest method hierarchicalInclude.
/**
* Has AssemblyFileSet#directory and includes for files in several hierarchic levels.
* Has AssemblyConfiguration targetDir.
*
* Should copy contents of AssemblyFileSet#directory to the outputDirectory in a subdirectory named as the AssemblyConfiguration#targetDir.
*/
@Test
public void hierarchicalInclude() throws Exception {
// Given
final AssemblyFileSet afs = AssemblyFileSet.builder().directory(sourceDirectory).include("1.txt").include("one/1.txt").include("two").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(6);
FileAssertions.assertThat(new File(outputDirectory, "deployments")).exists().fileTree().containsExactlyInAnyOrder("source-directory", "source-directory/1.txt", "source-directory/one", "source-directory/one/1.txt", "source-directory/two", "source-directory/two/1.txt", "source-directory/two/3.other", "source-directory/two/37");
}
use of org.eclipse.jkube.kit.common.Assembly in project jkube by eclipse.
the class AssemblyFileUtilsTest method getAssemblyFileOutputDirectoryWithRelativeDirectoryAndAssemblyIdShouldReturnComputedPath.
@Test
public void getAssemblyFileOutputDirectoryWithRelativeDirectoryAndAssemblyIdShouldReturnComputedPath() throws IOException {
// Given
final AssemblyFile af = AssemblyFile.builder().outputDirectory(new File("target")).build();
final File outputDirectoryForRelativePaths = temporaryFolder.newFolder("output");
final Assembly layer = Assembly.builder().id("layer-1").build();
final AssemblyConfiguration ac = AssemblyConfiguration.builder().targetDir("/project").build();
// When
final File result = getAssemblyFileOutputDirectory(af, outputDirectoryForRelativePaths, layer, ac);
// Then
final String expectedPath = outputDirectoryForRelativePaths.toPath().resolve("layer-1").resolve("project").resolve("target").toAbsolutePath().toString();
assertEquals(expectedPath, result.getAbsolutePath());
}
Aggregations